Browse Source

Add sha512 pbkdf2 support on Android

Hugo Pointcheval 5 months ago
parent
commit
027b6ca1fe

+ 3 - 1
android/src/main/kotlin/fr/pointcheval/native_crypto/NativeCryptoPlugin.kt

@@ -116,8 +116,10 @@ public class NativeCryptoPlugin : FlutterPlugin, MethodCallHandler {
116 116
         val spec = PBEKeySpec(chars, salt.toByteArray(), iteration, keyLength * 8)
117 117
         val skf: SecretKeyFactory = if (algorithm == "sha1") {
118 118
             SecretKeyFactory.getInstance("PBKDF2withHmacSHA1")
119
-        } else {
119
+        } else if (algorithm == "sha256") {
120 120
             SecretKeyFactory.getInstance("PBKDF2WithHmacSHA256")
121
+        } else {
122
+            SecretKeyFactory.getInstance("PBKDF2withHmacSHA512")
121 123
         }
122 124
         return skf.generateSecret(spec).encoded
123 125
     }