I am using AES for encryption purposes in my Flutter mobile application. For the key, I am getting a 4-digit PIN as input from the user. But the AES key must be 32 digits for encryption/decryption. I tried using base64 encoding but couldn't get the desired output. Also, I tried searching for a secured random number generator with a seed (when a seed is given, the secured random number generator should return the same output) in Dart and did not find one. Can you suggest what can be done to convert those 4 digits to 32 digits?
Asked
Active
Viewed 96 times
0
-
2Use a key derivation like Argon2 or PBKDF2 – Michael Fehr Jun 01 '23 at 06:12
-
Look at the RNG in pointycastle. pointycastle also scrypt as a KDF. – Richard Heap Jun 01 '23 at 14:52
-
1Do not misuse a (cryptographically secure) pseudo random number generator as a key derivation function, s. [here](https://stackoverflow.com/a/20134336/9014097) (the article refers to SHA1PRNG from the Java world, though, but the warning applies in general). Use a KDF as recommended in the first comment, see [here](https://cryptobook.nakov.com/mac-and-key-derivation/modern-key-derivation-functions). – Topaco Jun 01 '23 at 17:35
-
PBKDF2 works well. Thanks. I made use of https://pub.dev/packages/cryptography to achieve PBKDF2. – Kirthana Jun 07 '23 at 09:51