Last active
June 12, 2021 05:53
-
-
Save ctkqiang/eaefa0e2283e1363518cd8e1b77ca175 to your computer and use it in GitHub Desktop.
This file contains hidden or 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"; | |
import "dart:convert"; | |
class _encryption { | |
static int theKeyLength = 32; | |
static int theLengthOfInitialisationVector = 16; | |
static var key = Key.fromLength(theKeyLength); | |
static var iv = IV.fromLength(theLengthOfInitialisationVector); | |
static var AESENCRYPTOR = Encrypter(AES(key)); | |
// AES-Symmetric, padding: random | |
encrypt_string(String sendMessage) { | |
var encrypted = AESENCRYPTOR.encrypt(sendMessage, iv:iv); | |
String encryptedHashes = encrypted.base64; | |
decrypt_string(encrypted); | |
return encryptedHashes; | |
} | |
decrypt_string(var encrypted) { | |
var decrypted = AESENCRYPTOR.decrypt(encrypted, iv:iv); | |
String DecryptedHashes = decrypted; | |
return DecryptedHashes; | |
} | |
} | |
void main () { | |
_encryption test = new _encryption(); | |
var a = test.encrypt_string("hahslkjdflkjsdflksjdflksjdfslkdfjsldkfjah"); | |
List <int> b = utf8.encode(a); | |
print(a); | |
print(b); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment