Created
June 25, 2021 06:58
-
-
Save pinkeshdarji/a0ef427f74030cb66430149dda5502c0 to your computer and use it in GitHub Desktop.
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
final Uint8List iv = Uint8List.fromList('Initialization Vector'.codeUnits); | |
Future<String> encrypt(String message) async { | |
// 1. | |
aesGcmSecretKey = await AesGcmSecretKey. | |
(derivedBits); | |
// 2. | |
List<int> list = message.codeUnits; | |
Uint8List data = Uint8List.fromList(list); | |
// 3. | |
Uint8List encryptedBytes = await aesGcmSecretKey.encryptBytes(data, iv); | |
// 4. | |
String encryptedString = String.fromCharCodes(encryptedBytes); | |
print('encryptedString $encryptedString'); | |
return encryptedString; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment