better_cryptography library

Cryptographic algorithms for Dart / Flutter developers.

Algorithm types

Implementation factory

Cryptography.instance determines which implementation of an algorithm is used when you call factory method such as Sha256().

Classes

AesCbc
AES-CBC (cipher block chaining mode) Cipher.
AesCtr
AES-CTR (counter mode) Cipher.
AesGcm
AES-GCM (Galois/Counter Mode) Cipher.
Argon2id
Argon2id (draft-irtf-cfrg-argon2-03) password hashing function.
Blake2b
BLAKE2B (RFC 7693) HashAlgorithm.
Blake2s
BLAKE2S (RFC 7693) HashAlgorithm.
Chacha20
ChaCha20 (RFC 7539) StreamingCipher.
Cipher
A cipher that supports encrypt() and decrypt().
Cryptography
Returns cryptographic algorithm implementations.
Ecdh
ECDH with P-256 / P-384 / P-521 elliptic curve.
Ecdsa
ECDSA with P-256 / P-384 / P-521 elliptic curve.
EcKeyPair
An opaque reference to P-256 / P-384 / P-521 key pair.
EcKeyPairData
P-256 / P-384 / P-521 key pair.
EcPublicKey
Public key of P-256 / P-384 / P-521 key pair.
Ed25519
Ed25519 (RFC 8032) signature algorithm.
Hash
A digest calculated with some HashAlgorithm.
HashAlgorithm
A hash algorithm that produces a Hash.
HashSink
A sink for calculating Hash for long sequences.
Hchacha20
Hchacha20 (draft-irtf-cfrg-xchacha) key derivation algorithm.
Hkdf
HKDF (RFC 5869) key derivation algorithm.
Hmac
HMAC MacAlgorithm.
KdfAlgorithm
Abstract superclass for Key Derivation Algorithms (KDFs).
KeyExchangeAlgorithm
A key exchange algorithm that supports newKeyPair() and sharedSecretKey().
KeyPair
A key pair composed of a private key (KeyPairData) and PublicKey.
KeyPairData
Extracted data of a KeyPair.
KeyPairType<S extends KeyPairData, P extends PublicKey>
Static information about a key pair type.
Mac
A Message Authentication Code (MAC). Usually obtained from some MacAlgorithm.
MacAlgorithm
A Message Authentication Code (MAC) algorithm.
MacSink
A sink for calculating a Mac.
Pbkdf2
PBKDF2 password hashing algorithm implemented in pure Dart.
Poly1305
Poly1305 (RFC 7539) MacAlgorithm.
PublicKey
A public key of some KeyPair.
RsaKeyPair
Opaque reference to RSA key pair.
RsaKeyPairData
RSA private key.
RsaPss
RSA-PSS SignatureAlgorithm.
RsaPublicKey
RSA public key.
RsaSsaPkcs1v15
RSA-SSA-PKCS1v15 SignatureAlgorithm.
SecretBox
Output of encrypting bytes with a Cipher.
SecretKey
An opaque reference to a secret sequence of bytes.
SecretKeyData
A SecretKey that is stored in memory.
Sha1
SHA-1 HashAlgorithm.
Sha224
SHA-224 (SHA2-224) HashAlgorithm.
Sha256
SHA-256 (SHA2-256) HashAlgorithm.
Sha384
SHA-384 (SHA2-384) HashAlgorithm.
Sha512
SHA-512 (SHA2-512) HashAlgorithm.
Signature
A digital signature made of bytes and publicKey.
SignatureAlgorithm
An digital signature algorithm that supports newKeyPair(), sign(), verify().
SimpleKeyPair
A key pair that is made of two simple byte sequences.
SimpleKeyPairData
Data of SimpleKeyPair.
SimplePublicKey
A PublicKey that is a sequence of bytes.
StreamingCipher
Superclass of streaming ciphers such as AesGcm and Chacha20 that allow encrypter/decrypter to choose offset in the keystream.
X25519
X25519 (RFC 7748) KeyExchangeAlgorithm.
Xchacha20
Xchacha20 (draft-irtf-cfrg-xchacha). cipher.

Exceptions / Errors

SecretBoxAuthenticationError
Error thrown by Cipher.decrypt when SecretBox has incorrect Mac.