digest static method
Returns the hash keys as raw bytes (Uint8List) for the specified algorithm.
This retrieves the signatures from the platform via KeystoreHashPlatform
and applies the chosen hash algorithm to each signature.
Implementation
static Future<List<Uint8List>> digest(HashAlgorithm algorithm) async {
final bytesList = await KeystoreSignaturePlatform.instance.getSignatures();
final formatted = bytesList.map((bytes) {
final Digest digest;
switch (algorithm) {
case HashAlgorithm.sha1:
digest = sha1.convert(bytes);
break;
case HashAlgorithm.sha256:
digest = sha256.convert(bytes);
break;
case HashAlgorithm.sha512:
digest = sha512.convert(bytes);
break;
case HashAlgorithm.md5:
digest = md5.convert(bytes);
break;
}
return digest.bytes;
});
return formatted.map((bytes) => Uint8List.fromList(bytes)).toList();
}