Add pbkdf2 digest sh512

This commit is contained in:
Hugo Pointcheval 2020-04-29 23:04:41 +02:00
parent 46b1a5248c
commit 03beb35dbc
2 changed files with 3 additions and 2 deletions

View File

@ -52,7 +52,7 @@ class _MyAppState extends State<MyApp> {
if (password.isEmpty) {
output = 'Password is empty';
} else {
key = await KeyGenerator().pbkdf2(password, 'salt', digest: Digest.sha1);
key = await KeyGenerator().pbkdf2(password, 'salt', digest: Digest.sha512);
output = 'Key successfully derived.';
}
setState(() {

View File

@ -16,7 +16,7 @@ const String TAG_DEBUG = 'debug.native_crypto.symmetric_crypto';
enum KeySize { bits128, bits192, bits256 }
/// Defines all available digest.
enum Digest { sha1, sha256 }
enum Digest { sha1, sha256, sha512 }
/// Defines all available ciphers.
enum Cipher { AES }
@ -68,6 +68,7 @@ class KeyGenerator {
String algo;
if (digest == Digest.sha1) algo = 'sha1';
if (digest == Digest.sha256) algo = 'sha256';
if (digest == Digest.sha512) algo = 'sha512';
try {
key = await NativeCrypto().pbkdf2( password, salt, keyLength: keyLength, iteration: iteration, algorithm: algo);