Encryption Services

Argon 2

argon2Hash()

generates an Argon2 hash using the ARGON2id type.

  • parameters:
    • password : String : the password to hash
    • base64EncodedSalt : String : the salt to use, base 64 encoded to a String
    • parallelism : int : the number of threads to use
    • resultLength : int : the desired tagLength, this is the desired number of bytes in the hash. Note that is not equal to the length of this function's result
    • memorySizeInKb : int : amount of memory (in kilobytes) to use
    • iterations : int : number of iterations to perform
  • return value:

An encoded hash. This encoded hash contains all parameters used to calculate the hash, so it alone suffices to verify a password.

argon2Verify()

Verifies a given password against a argon2 encoded hash string

  • parameters:
    • password : String : the password to verify
    • encodedHash : String : the encoded Argon hash string
  • return value:
    • boolean : true if the password was successfully verified, false otherwise

Example

function argon2Hash (workitem){
	var service = tb.getService('Argon2');
	var pwd = 'passw';
	var b64 = tb.base64Encode('some random string', true);
	var parallelism = 4;
	var resultLength = 64;
	var memorySizeInKb = 4096;
	var iterations = 10;
	var hash = service.argon2Hash(pwd, b64,parallelism,resultLength,memorySizeInKb,iterations);
	
	tb.log(hash);
}


function argon2Verify (workitem){
	var service = tb.getService('Argon2');
	var pwd = 'passw';
	var hash = '';
	var result = service.argon2Verify(pwd, hash);
	tb.log(result?'success':'fail');
}
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.