AES Encryption in flutter

6,232

Do you have any particular attachment to flutter_string_encryption? I wrote a custom package based off PointyCastle and written entirely in Dart which can solve AES for you.

https://pub.dev/packages/steel_crypt

It looks something like this implemented:

var fortunaKey = CryptKey().genFortuna(); //generate 32 byte key with Fortuna; you can also enter your own
var nonce = CryptKey().genDart(len: 12); //generate IV for AES with Dart Random.secure(); you can also enter your own
var aesEncrypter = AesCrypt(key: fortunaKey, padding: PaddingAES.pkcs7); //generate AES encrypter with key and PKCS7 padding
String encrypted = aesEncrypter.gcm.encrypt(inp: 'somedatahere', iv: nonce); //encrypt using GCM
String decrypted = aesEncrypter.gcm.decrypt(inp: encrypted, iv: nonce); //decrypt
Share:
6,232
user3526826
Author by

user3526826

Updated on December 09, 2022

Comments

  • user3526826
    user3526826 over 1 year

    I want to AES encrypt data for the http requests in flutter. I have password and plaintext string which I want to encrypt. I am using flutter_string_encryption. I have achieved in iOS app but both the output differs.

    final salt = await cryptor.generateSalt();
    final generatedKey = await cryptor.generateKeyFromPassword(password, salt);
    final String encrypted = await cryptor.encrypt(string, generatedKey);