box library

Encrpyt messages with public and secret key. Maps libsodium's crypto_box_* api.

Classes

KeyPair
Generates a pair of public- and secret-key.

Properties

nonceBytes int
final
publicKeyBytes int
final
secretKeyBytes int
final
seedBytes int
final

Functions

beforeNumerous(Uint8List publicKey, Uint8List secretKey) Uint8List
Generates a shared key to improve performance. publicKey must be publicKeyBytes long; secretKey must be secretKeyBytes long. Throws BeforeNumerousError when computing shared key fails.
easy(Uint8List message, Uint8List nonce, Uint8List publicKey, Uint8List secretKey) Uint8List
Encrypts message with the recipient's publicKey and the senders secretKey. publicKey must be publicKeyBytes long; secretKey must be secretKeyBytes long. nonce must be nonceBytes long and must be a unique value. Throws EncryptionError when encrypting message fails.
easyAfterNumerous(Uint8List message, Uint8List nonce, Uint8List key) Uint8List
Encrypts message with a shared key generated by beforeNumerous. nonce must be nonceBytes long and must bea unique value. Throws EncryptionError when encrypting message fails.
openEasy(Uint8List ciphertext, Uint8List nonce, Uint8List publicKey, Uint8List secretKey) Uint8List
Opens message encrypted by easy. Throws DecryptionError when decrypting message fails.
openEasyAfterNumerous(Uint8List ciphertext, Uint8List nonce, Uint8List key) Uint8List
Decrypts ciphertext generated by easyAfterNumerous. Throws DecryptionError when decrypting message fails.

Exceptions / Errors

BeforeNumerousError
KeyPairException