verifyHashBytesSync method
bool
verifyHashBytesSync(
- List<
int> password, - List<
int> encodedHash, { - Argon2Type type = Argon2Type.i,
The method to verify a List
Needs a List of type int password
, a List of type int encodedHash
, as well as an
Argon2Type type
used for the actual hash.
Returns a bool with a true for a success and false for a failed verification.
Implementation
bool verifyHashBytesSync(List<int> password, List<int> encodedHash,
{Argon2Type type = Argon2Type.i}) {
//Create pointers to pass to the C method
var passPointer = _setPtr(password);
var hashPointer = utf8.decode(encodedHash).toNativeUtf8();
// var hashPointer = _setPtr(encodedHash);
//Get the result
var result = LocalBinder.instance
.verifyHash(hashPointer, passPointer, password.length, type.index);
//Free the pointers
malloc.free(passPointer);
malloc.free(hashPointer);
if (DArgon2ErrorCode.values[result.abs()] != DArgon2ErrorCode.ARGON2_OK) {
throw DArgon2Exception(
LocalBinder.instance.getErrorMessage(result).toDartString(),
DArgon2ErrorCode.values[result.abs()]);
}
return result == 0;
}