cryptography_plus 2.7.1 cryptography_plus: ^2.7.1 copied to clipboard
Cryptographic algorithms for encryption, digital signatures, key agreement, authentication, and hashing. AES, Chacha20, ED25519, X25519, Argon2, and more. Good cross-platform support.
import 'package:cryptography_plus/cryptography_plus.dart';
Future<void> main() async {
final algorithm = AesGcm.with256bits();
// Generate a random 256-bit secret key
final secretKey = await algorithm.newSecretKey();
// Generate a random 96-bit nonce.
final nonce = algorithm.newNonce();
// Encrypt
final clearText = [1, 2, 3];
final secretBox = await algorithm.encrypt(
clearText,
secretKey: secretKey,
nonce: nonce,
);
print('Ciphertext: ${secretBox.cipherText}');
print('MAC: ${secretBox.mac}');
}