암/복호화

대칭키(AES) 암호화
final key = encrypt.Key.fromSecureRandom(32);
final iv = encrypt.IV.fromSecureRandom(16);
final encrypter = encrypt.Encrypter(encrypt.AES(key));
final encrypted = encrypter.encrypt(plainText, iv: iv);
final decrypted = encrypter.decrypt(encrypted, iv: iv);결과
비대칭키(RSA) 암호화
final publicPem = await rootBundle.loadString('assets/pem/public.pem');
final publicKey = RSAKeyParser().parse(publicPem) as RSAPublicKey;
final privatePem = await rootBundle.loadString('assets/pem/private.pem');
final privKey = RSAKeyParser().parse(privatePem) as RSAPrivateKey;
final encrypter = encrypt.Encrypter(
encrypt.RSA(publicKey: publicKey, privateKey: privKey));
final encrypted = encrypter.encrypt(plainText);
final decrypted = encrypter.decrypt(encrypted);결과
Last updated

