Solution 1 :
As @zapl pointed out encrypting this password will not achieve anything … anyone can just extract it from your app source code.
If you are just looking for a way to dynamically encrypt data in Flutter have a look at this package. There are dedicated APIs to store data securely in both Android and IOS. This package simply accesses the native secure storage.
Problem :
I just want to ask best way to use encrypt password in flutter
I already use this but I think it’s not the best way for security
String encryptAES(plainText) {
final key = encrypt.Key.fromUtf8('my32lengthsupersecretnooneknows1');
final iv = IV.fromLength(16);
final encrypter = Encrypter(AES(key));
encrypted = encrypter.encrypt(plainText, iv: iv);
return encrypted!.base64;
}
Comments
Comment posted by zapl
Security does not improve if you encrypt data in an app that also contains the encryption key hardcoded inside. Every user can simply unzip your app and read the encryption key. Assume that all source code, assets, … in your app is public.