From 027b6ca1fef90648c44be5d1ece9d942b614b9e4 Mon Sep 17 00:00:00 2001 From: Hugo Pointcheval Date: Wed, 29 Apr 2020 23:14:52 +0200 Subject: [PATCH] Add sha512 pbkdf2 support on Android --- .../kotlin/fr/pointcheval/native_crypto/NativeCryptoPlugin.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/android/src/main/kotlin/fr/pointcheval/native_crypto/NativeCryptoPlugin.kt b/android/src/main/kotlin/fr/pointcheval/native_crypto/NativeCryptoPlugin.kt index b6271dc..729da34 100644 --- a/android/src/main/kotlin/fr/pointcheval/native_crypto/NativeCryptoPlugin.kt +++ b/android/src/main/kotlin/fr/pointcheval/native_crypto/NativeCryptoPlugin.kt @@ -116,8 +116,10 @@ public class NativeCryptoPlugin : FlutterPlugin, MethodCallHandler { val spec = PBEKeySpec(chars, salt.toByteArray(), iteration, keyLength * 8) val skf: SecretKeyFactory = if (algorithm == "sha1") { SecretKeyFactory.getInstance("PBKDF2withHmacSHA1") - } else { + } else if (algorithm == "sha256") { SecretKeyFactory.getInstance("PBKDF2WithHmacSHA256") + } else { + SecretKeyFactory.getInstance("PBKDF2withHmacSHA512") } return skf.generateSecret(spec).encoded }