Hi guys,
I battling to decrypt a string that was encrypted using this
encrypt | Dart Package. link in flutter.
AES Encryption
privateKEY = “%8R=&PfC5SXT:pRF2vF[5zCTy}M7CX]J”
privateINV = “}Lq5Wu~nkr\Vdfm~”
Encrypted string = “rMCS4wiyvQH7nXx6slP6rA==”
Actual massage should be = “Fantastic”
The flutter code to encrypt is
Using this library to encrypt text only.
import 'package:encrypt/encrypt.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
class EncryptAESData {
static Encrypted encrypted;
static var decrypted;
static String encryptAES(data) {
final key = Key.fromUtf8(dotenv.env['privateKEY']);
final iv = IV.fromUtf8(dotenv.env['privateINV']);
final encrypter = Encrypter(AES(key));
encrypted = encrypter.encrypt(data, iv: iv);
return encrypted.base64;
}
static decryptAES(data) {
final key = Key.fromUtf8(dotenv.env['privateKEY']);
final iv = IV.fromUtf8(dotenv.env['privateINV']);
final encrypter = Encrypter(AES(key));
String decrypted = "";
if (data != "") {
try {
decrypted = encrypter.decrypt(Encrypted.fromBase64(data), iv: iv);
} catch (exception) {
decrypted = data;
}
}
return decrypted;
}
}
I’m getting nothing back and i suspect the :crypto.crypto_one_time function i’m using is getting the wrong binary arguments
Here is an example of how i’m getting the binary from the string, if thats even what i’m supposed to do
b_password = :crypto.hash(:md5, privateKEY)