Created
March 8, 2020 12:01
-
-
Save AmruthPillai/3d99758a3836b909d331a90601023f53 to your computer and use it in GitHub Desktop.
Be Thrifty Today - Encryption
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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