dartage 0.1.1 copy "dartage: ^0.1.1" to clipboard
dartage: ^0.1.1 copied to clipboard

Pure Dart implementation of the age v1 file encryption format with X25519 recipients: encrypt, decrypt, ASCII armor, and identity/recipient key handling, verified against the reference implementation.

example/main.dart

// Generate a keypair, encrypt to it, and decrypt back.
//
// Run it with:
//   dart run example/main.dart

import 'dart:convert';
import 'dart:typed_data';

import 'package:dartage/dartage.dart';

Future<void> main() async {
  final identity = generateIdentity();
  final recipient = await identityToRecipient(identity);

  print('recipient: $recipient');

  final encrypter = AgeEncrypter()..addRecipient(recipient);
  final ciphertext = await encrypter.encrypt(
    Uint8List.fromList(utf8.encode('secret')),
  );

  // `armorEncode` produces the PEM-style text form for storing in a file.
  print(armorEncode(ciphertext).split('\n').first);

  final decrypter = AgeDecrypter()..addIdentity(identity);
  final plaintext = await decrypter.decrypt(ciphertext);

  print('decrypted: ${utf8.decode(plaintext)}');
}
0
likes
150
points
372
downloads

Documentation

API reference

Publisher

verified publishertinyrack.net

Weekly Downloads

Pure Dart implementation of the age v1 file encryption format with X25519 recipients: encrypt, decrypt, ASCII armor, and identity/recipient key handling, verified against the reference implementation.

Topics

#age #encryption #cryptography

License

MIT (license)

Dependencies

cryptography

More

Packages that depend on dartage