Cryptography class abstract
A factory for cryptographic algorithms.
This is used by factories in the cryptographic algorithm classes. For example, Chacha20.poly1305Aead calls the Cryptography.instance method chacha20Poly1305Aead.
Implementations
 DartCryptography
 BrowserCryptography
 FlutterCryptography (package:cryptography_flutter)
Setting implementation
In shipped application, it's a good practice to freeze the value of static variable with freezeInstance:
import 'package:cryptography/cryptography.dart';
void main() {
Cryptography.freezeInstance(yourInstance);
// ...
}
Writing you own subclass
import 'package:cryptography/browser.dart';
import 'package:cryptography/cryptography.dart';
class MyCryptography extends BrowserCryptography {
@override
Sha256 get sha256 {
return SomeOtherSha256Implementation();
}
}
void main() {
// Change the default cryptography
Cryptography.freezeInstance(MyCryptography());
final sha256 = Sha256(); // > SomeOtherSha256Implementation
}
 Implementers
Constructors
 Cryptography()

const
Properties
 hashCode → int

The hash code for this object.
no setterinherited
 runtimeType → Type

A representation of the runtime type of the object.
no setterinherited
Methods

aesCbc(
{required MacAlgorithm macAlgorithm, PaddingAlgorithm paddingAlgorithm = PaddingAlgorithm.pkcs7, int secretKeyLength = 32}) → AesCbc  A factory used by AesCbc.

aesCtr(
{required MacAlgorithm macAlgorithm, int secretKeyLength = 32, int counterBits = 64}) → AesCtr  A factory used by AesCtr.

aesGcm(
{int secretKeyLength = 32, int nonceLength = 12}) → AesGcm  A factory used by AesGcm.

argon2id(
{required int memory, required int parallelism, required int iterations, required int hashLength}) → Argon2id  A factory used by Argon2id.

blake2b(
{int hashLengthInBytes = 64}) → Blake2b  A factory used by Blake2b.

blake2s(
{int hashLengthInBytes = 32}) → Blake2s  A factory used by Blake2s.

chacha20(
{required MacAlgorithm macAlgorithm}) → Chacha20  A factory used by Chacha20.

chacha20Poly1305Aead(
) → Chacha20  A factory used by Chacha20.poly1305Aead.

ecdhP256(
{required int length}) → Ecdh  A factory used by Ecdh.p256.

ecdhP384(
{required int length}) → Ecdh  A factory used by Ecdh.p384.

ecdhP521(
{required int length}) → Ecdh  A factory used by Ecdh.p521.

ecdsaP256(
HashAlgorithm hashAlgorithm) → Ecdsa  A factory used by Ecdsa.p256.

ecdsaP384(
HashAlgorithm hashAlgorithm) → Ecdsa  A factory used by Ecdsa.p384.

ecdsaP521(
HashAlgorithm hashAlgorithm) → Ecdsa  A factory used by Ecdsa.p521.

ed25519(
) → Ed25519  A factory used by Ed25519.

hchacha20(
) → Hchacha20  A factory used by Hchacha20.

hkdf(
{required Hmac hmac, required int outputLength}) → Hkdf  A factory used by Hkdf.

hmac(
HashAlgorithm hashAlgorithm) → Hmac  A factory used by Hmac.

noSuchMethod(
Invocation invocation) → dynamic 
Invoked when a nonexistent method or property is accessed.
inherited

pbkdf2(
{required MacAlgorithm macAlgorithm, required int iterations, required int bits}) → Pbkdf2  A factory used by Pbkdf2.

poly1305(
) → Poly1305  A factory used by Poly1305.

rsaPss(
HashAlgorithm hashAlgorithm, {required int nonceLengthInBytes}) → RsaPss  A factory used by RsaPss.

rsaSsaPkcs1v15(
HashAlgorithm hashAlgorithm) → RsaSsaPkcs1v15  A factory used by RsaSsaPkcs1v15.

sha1(
) → Sha1  A factory used by Sha1.

sha224(
) → Sha224  A factory used by Sha224.

sha256(
) → Sha256  A factory used by Sha256.

sha384(
) → Sha384  A factory used by Sha384.

sha512(
) → Sha512  A factory used by Sha512.

toString(
) → String 
A string representation of this object.
inherited

withRandom(
Random random) → Cryptography 
x25519(
) → X25519  A factory used by X25519.

xchacha20(
{required MacAlgorithm macAlgorithm}) → Xchacha20  A factory used by Xchacha20.

xchacha20Poly1305Aead(
) → Xchacha20  A factory used by Xchacha20.poly1305Aead.
Operators

operator ==(
Object other) → bool 
The equality operator.
inherited
Static Properties
 defaultInstance → Cryptography

Default value of instance.
final
 instance ↔ Cryptography

Static variable that holds the Cryptography used by
package:cryptography classes.
getter/setter pair
Static Methods

freezeInstance(
Cryptography cryptography) → void  Sets Cryptography.instance and prevents further mutations.