Skip to content

Instantly share code, notes, and snippets.

@pinkeshdarji
Created June 25, 2021 06:58
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 pinkeshdarji/a0ef427f74030cb66430149dda5502c0 to your computer and use it in GitHub Desktop.
Save pinkeshdarji/a0ef427f74030cb66430149dda5502c0 to your computer and use it in GitHub Desktop.
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