Skip to content

Instantly share code, notes, and snippets.

@AmruthPillai
Created March 8, 2020 12:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AmruthPillai/3d99758a3836b909d331a90601023f53 to your computer and use it in GitHub Desktop.
Save AmruthPillai/3d99758a3836b909d331a90601023f53 to your computer and use it in GitHub Desktop.
Be Thrifty Today - Encryption
import 'package:encrypt/encrypt.dart';
const CRYPT_KEY = '';
String encrypt(String text) {
if (text == null || text.isEmpty) return null;
final key = Key.fromUtf8(CRYPT_KEY);
final encrypter = Encrypter(AES(key, mode: AESMode.ecb));
return encrypter.encrypt(text).base64;
}
String decrypt(String text) {
if (text == null || text.isEmpty) return null;
final key = Key.fromUtf8(CRYPT_KEY);
final encrypter = Encrypter(AES(key, mode: AESMode.ecb));
return encrypter.decrypt64(text);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment