better_cryptography 1.0.0+1 copy "better_cryptography: ^1.0.0+1" to clipboard
better_cryptography: ^1.0.0+1 copied to clipboard

Cryptographic algorithms for encryption, digital signatures, key agreement, authentication, and hashing. AES, Chacha20, ED25519, X25519, and more. Web Crypto support.

example/lib/example.dart

import 'package:better_cryptography/better_cryptography.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}');
}
copied to clipboard
4
likes
130
points
11
downloads

Publisher

unverified uploader

Weekly Downloads

2024.09.26 - 2025.04.10

Cryptographic algorithms for encryption, digital signatures, key agreement, authentication, and hashing. AES, Chacha20, ED25519, X25519, and more. Web Crypto support.

Repository (GitHub)

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

collection, crypto, fixnum, js, meta, typed_data

More

Packages that depend on better_cryptography