convert method
Generate a derived key from a password
Implementation
@override
HashDigest convert(List<int> password) {
int i, j, k, t;
Uint8List hash, block;
var result = Uint8List(derivedKeyLength);
// Initialize the MAC with provided password
var sink = algo.by(password).createSink();
k = 0;
for (i = 1; k < derivedKeyLength; i++) {
// Generate the first HMAC: U_1
sink.reset();
sink.add(salt);
sink.add([i >>> 24, i >>> 16, i >>> 8, i]);
hash = sink.digest().bytes;
// For storing the combined XORs
block = hash;
// Subsequence HMAC generation: U_2 .. U_c
for (t = 1; t < iterations; ++t) {
sink.reset();
sink.add(hash);
hash = sink.digest().bytes;
for (j = 0; j < hash.length; ++j) {
block[j] ^= hash[j];
}
}
// Append the hash to the result
for (j = 0; j < hash.length && k < derivedKeyLength; ++j, ++k) {
result[k] = block[j];
}
}
return HashDigest(result);
}