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

This package consolidates some common cryptographic utilities used across our applications, particularly primitives related to keys, encryption, and decryption in a pure Dart implementation.

turnkey-crypto #

This package provides cryptographic utilities used across our applications, specifically for key generation, encryption, and decryption.

Example usage (Hpke E2E):

final senderKeyPair = generateP256KeyPair();
final receiverKeyPair = generateP256KeyPair();

final receiverPublicKeyUncompressed =
    uncompressRawPublicKey(hexToUint8List(receiverKeyPair.publicKey));

final plainText = "Hello, this is a secure message!";
final plainTextBuf = Uint8List.fromList(utf8.encode(plainText));

final encryptedData = hpkeEncrypt(
    plainTextBuf: plainTextBuf,
    encappedKeyBuf: receiverPublicKeyUncompressed,
    senderPriv: senderKeyPair.privateKey,
);

// Extract the encapsulated key buffer and the ciphertext
final encappedKeyBuf = encryptedData.sublist(0, 33);
final ciphertextBuf = encryptedData.sublist(33);

final decryptedData = hpkeDecrypt(
    ciphertextBuf: ciphertextBuf,
    encappedKeyBuf: uncompressRawPublicKey(encappedKeyBuf),
    receiverPriv: receiverKeyPair.privateKey,
);

// Convert decrypted data back to a string
final decryptedText = utf8.decode(decryptedData);
copied to clipboard
1
likes
120
points
50
downloads

Publisher

verified publisherturnkey.com

Weekly Downloads

2024.09.14 - 2025.03.29

This package consolidates some common cryptographic utilities used across our applications, particularly primitives related to keys, encryption, and decryption in a pure Dart implementation.

Repository (GitHub)

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

base58check, bs58, cryptography, pointycastle, turnkey_encoding

More

Packages that depend on turnkey_crypto