QuickCrypto class
QuickCrypto provides a set of utility methods for cryptographic operations.
This class contains static methods for generating random bytes, hashing data, and performing other cryptographic operations commonly used in various applications.
Constructors
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
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
Static Methods
-
aes<
T extends Object?> (List< int> key, T use(BuBlockCipher cipher)) → T -
Runs
usewith a fresh AES block cipher built fromkey, then wipes it. The instance must be clean after you don't need it; this method guarantees that, even ifusethrows. -
aesCtr<
T extends Object?> (List< int> key, List<int> counter, T use(BuAesCtr cipher)) → T -
Runs
usewith a fresh AES-CTR cipher built fromkey/counter, then wipes it. The instance must be clean after you don't need it; this method guarantees that, even ifusethrows. -
aesCtrInstance(
List< int> key, List<int> counter) → BuAesCtr -
aesEcb<
T extends Object?> (List< int> key, T use(BuAesEcb cipher), {PaddingAlgorithm? padding = PaddingAlgorithm.pkcs7}) → T -
Runs
usewith a fresh AES-ECB cipher, then wipes it. The instance must be clean after you don't need it; this method guarantees that, even ifusethrows. -
aesEcbDecrypt(
List< int> key, List<int> data, {PaddingAlgorithm? paddingAlgorithm}) → BuBytes - Decrypt the input data using AES(ECB)
-
aesEcbEncrypt(
List< int> key, List<int> data, {PaddingAlgorithm? paddingAlgorithm}) → BuBytes - Encrypt the input data using AES(ECB)
-
aesEcbInstance(
List< int> key, {PaddingAlgorithm? padding = PaddingAlgorithm.pkcs7}) → BuAesEcb -
aesInstance(
List< int> key) → BuBlockCipher -
blake2b<
T extends Object?> (T use(BuSerializableHash< BuHashState> cipher), {int digestLength = 64, Blake2Config? config}) → T -
Runs
usewith a fresh BLAKE2b hash, then wipes it. The instance must be clean after you don't need it; this method guarantees that, even ifusethrows. -
blake2b128Hash(
List< int> data, {List<int> ? key, List<int> ? salt, List<int> ? personalization, List<List< extraBlocks = const []}) → BuBytesint> > - Calculate the BLAKE2b-128 hash of the input data
-
blake2b160Hash(
List< int> data, {List<int> ? key, List<int> ? salt, List<int> ? personalization, List<List< extraBlocks = const []}) → BuBytesint> > - Calculate the BLAKE2b-160 hash of the input data
-
blake2b224Hash(
List< int> data, {List<int> ? key, List<int> ? salt, List<int> ? personalization, List<List< extraBlocks = const []}) → BuBytesint> > - Calculate the BLAKE2b-224 hash of the input data
-
blake2b256Hash(
List< int> data, {List<int> ? key, List<int> ? salt, List<int> ? personalization, List<List< extraBlocks = const []}) → BuBytesint> > - Calculate the BLAKE2b-256 hash of the input data
-
blake2b32Hash(
List< int> data, {List<int> ? key, List<int> ? salt, List<int> ? personalization, List<List< extraBlocks = const []}) → BuBytesint> > - Calculate the BLAKE2b-32 hash of the input data
-
blake2b40Hash(
List< int> data, {List<int> ? key, List<int> ? salt, List<int> ? personalization, List<List< extraBlocks = const []}) → BuBytesint> > - Calculate the BLAKE2b-40 hash of the input data
-
blake2b512Hash(
List< int> data, {List<int> ? key, List<int> ? salt, List<int> ? personalization, List<List< extraBlocks = const []}) → BuBytesint> > - Calculate the BLAKE2b-512 hash of the input data
-
blake2b64Hash(
List< int> data, {List<int> ? key, List<int> ? salt, List<int> ? personalization, List<List< extraBlocks = const []}) → BuBytesint> > - Calculate the BLAKE2b-64 hash of the input data
-
blake2bHash(
List< int> ? data, int digestSize, {List<int> ? key, List<int> ? salt, List<int> ? personalization, List<List< batch = const []}) → BuBytesint> > -
blake2bInstance(
{int digestLength = 64, Blake2Config? config}) → BuSerializableHash< BuHashState> -
blake2s<
T extends Object?> (T use(BuSerializableHash< BuHashState> cipher), {int digestLength = 32, Blake2Config? config}) → T -
Runs
usewith a fresh BLAKE2s hash, then wipes it. The instance must be clean after you don't need it; this method guarantees that, even ifusethrows. -
blake2s256Hash(
List< int> data, {List<int> ? key, List<int> ? salt, List<int> ? personalization, List<List< extraBlocks = const []}) → BuBytesint> > - Calculate the BLAKE2s-256 hash of the input data
-
blake2sInstance(
{int digestLength = 32, Blake2Config? config}) → BuSerializableHash< BuHashState> -
chacha20<
T extends Object?> (List< int> key, T use(BuStreamCipher cipher)) → T -
Runs
usewith a fresh ChaCha20 stream cipher built fromkey, then wipes it. The instance must be clean after you don't need it; this method guarantees that, even ifusethrows. -
chacha20Instance(
List< int> key) → BuStreamCipher -
chacha20Poly1305<
T extends Object?> (List< int> key, T use(BuAead cipher)) → T -
Runs
usewith a fresh ChaCha20-Poly1305 AEAD built fromkey, then wipes it. The instance must be clean after you don't need it; this method guarantees that, even ifusethrows. -
chaCha20Poly1305Decrypt(
{required List< int> key, required List<int> nonce, required List<int> cipherText, List<int> ? assocData}) → BuBytes - Decrypt data using the ChaCha20-Poly1305 authenticated encryption algorithm. Requires a key, nonce, ciphertext, and optional associated data.
-
chaCha20Poly1305Encrypt(
{required List< int> key, required List<int> nonce, required List<int> plainText, List<int> ? assocData}) → BuBytes - Encrypt data using the ChaCha20-Poly1305 authenticated encryption algorithm. Requires a key, nonce, plaintext, and optional associated data.
-
chacha20Poly1305Instance(
List< int> key) → BuAead -
generateRandom(
{int length = 32}) → BuBytes -
This function generates a random
List<int>of the specified size (default is 32 bytes). -
generateRandomFromRng(
{int length = 32, Rng? rng}) → BuBytes -
This function generates a random
List<int>of the specified size (default is 32 bytes). -
generateRandomHex(
[int size = 32]) → String -
generateRandomInt(
int max) → int -
generateRandomString(
int length, {String charset = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'}) → String -
generateRandoomBool(
) → bool -
generateUniqueRandom(
{int length = 32, List< List< existingKeys = const []}) → BuBytesint> > -
generateUniqueRandomHex(
{int length = 32, List< List< existingKeys = const []}) → Stringint> > -
generateX25519XKeyPair(
{List< int> ? seed}) → X25519Keypair -
hash160(
List< int> data) → BuBytes - Calculate the RIPEMD-160 hash of the SHA-256 hash of the input data
-
hkdfDeriveSha256(
{required List< int> ikm, int length = 32, List<int> ? salt, List<int> ? info}) → BuBytes -
Strict RFC 5869 HKDF-SHA-256 quick call, routed through the active
backend (pure-Dart or native Rust). Always Extract-then-Expand;
omitted
saltdefaults to 32 zeros (§2.2) on every backend. Prefer this overhdfkDerivefor interoperable derivations. -
hkdfDeriveSha512(
{required List< int> ikm, int length = 32, List<int> ? salt, List<int> ? info}) → BuBytes -
Strict RFC 5869 HKDF-SHA-512 quick call, routed through the active
backend (pure-Dart or native Rust). Always Extract-then-Expand;
omitted
saltdefaults to 64 zeros (§2.2) on every backend. Prefer this overhdfkDerivefor interoperable derivations. -
hmacSha256<
T extends Object?> (List< int> key, T use(BuSerializableHash<BuHashState> cipher)) → T -
Runs
usewith a fresh HMAC-SHA-256 built fromkey, then wipes it. The instance must be clean after you don't need it; this method guarantees that, even ifusethrows. -
hmacsha256Hash(
List< int> key, List<int> data) → BuBytes - Calculate the HMAC-SHA-256 hash of the input data using the provided key
-
hmacSha256Instance(
List< int> key) → BuSerializableHash<BuHashState> -
hmacSha384<
T extends Object?> (List< int> key, T use(BuSerializableHash<BuHashState> cipher)) → T -
Runs
usewith a fresh HMAC-SHA-384 built fromkey, then wipes it. The instance must be clean after you don't need it; this method guarantees that, even ifusethrows. -
hmacSha384Hash(
List< int> key, List<int> data) → BuBytes - Calculate the HMAC-SHA-384 hash of the input data using the provided key
-
hmacSha384Instance(
List< int> key) → BuSerializableHash<BuHashState> -
hmacSha512<
T extends Object?> (List< int> key, T use(BuSerializableHash<BuHashState> cipher)) → T -
Runs
usewith a fresh HMAC-SHA-512 built fromkey, then wipes it. The instance must be clean after you don't need it; this method guarantees that, even ifusethrows. -
hmacSha512Hash(
List< int> key, List<int> data) → BuBytes - Calculate the HMAC-SHA-512 hash of the input data using the provided key
-
hmacSha512HashHalves(
List< int> key, List<int> data) → (BuBytes, BuBytes) - Calculate the HMAC-SHA-512 hash of the input data using the provided key and split the result into two halves. Return a tuple containing both halves
-
hmacSha512Instance(
List< int> key) → BuSerializableHash<BuHashState> -
keccak<
T extends Object?> (T use(BuSerializableHash< BuHashState> cipher), {int digestLength = 64}) → T -
Runs
usewith a fresh Keccak hash, then wipes it. The instance must be clean after you don't need it; this method guarantees that, even ifusethrows. -
keccak256Hash(
List< int> data) → BuBytes - Calculate the Keccak-256 hash of the input data
-
keccakF1600(
BuBytes src) → BuBytes -
keccakInstance(
{int digestLength = 64}) → BuSerializableHash< BuHashState> -
md4<
T extends Object?> (T use(BuSerializableHash< BuHashState> cipher)) → T -
Runs
usewith a fresh MD4 hash, then wipes it. The instance must be clean after you don't need it; this method guarantees that, even ifusethrows. -
md4Instance(
) → BuSerializableHash< BuHashState> -
md5<
T extends Object?> (T use(BuSerializableHash< BuHashState> cipher)) → T -
Runs
usewith a fresh MD5 hash, then wipes it. The instance must be clean after you don't need it; this method guarantees that, even ifusethrows. -
md5Hash(
List< int> data) → BuBytes -
md5Instance(
) → BuSerializableHash< BuHashState> -
nextU32(
) → int -
nextU64(
) → BigInt -
pbkdf2Sha256DeriveKey(
{required List< int> password, required List<int> salt, required int iterations, int? dklen}) → BuBytes -
pbkdf2Sha512DeriveKey(
{required List< int> password, required List<int> salt, required int iterations, int? dklen}) → BuBytes - Derive a key from a password using PBKDF2 algorithm
-
processCtr(
{required List< int> key, required List<int> iv, required List<int> data}) → BuBytes -
ripemd128<
T extends Object?> (T use(BuSerializableHash< BuHashState> cipher)) → T -
Runs
usewith a fresh RIPEMD-128 hash, then wipes it. The instance must be clean after you don't need it; this method guarantees that, even ifusethrows. -
ripemd128Instance(
) → BuSerializableHash< BuHashState> -
ripemd160<
T extends Object?> (T use(BuSerializableHash< BuHashState> cipher)) → T -
Runs
usewith a fresh RIPEMD-160 hash, then wipes it. The instance must be clean after you don't need it; this method guarantees that, even ifusethrows. -
ripemd160Hash(
List< int> data) → BuBytes - Calculate the RIPEMD-160 hash of the input data
-
ripemd160Instance(
) → BuSerializableHash< BuHashState> -
ripemd256<
T extends Object?> (T use(BuSerializableHash< BuHashState> cipher)) → T -
Runs
usewith a fresh RIPEMD-256 hash, then wipes it. The instance must be clean after you don't need it; this method guarantees that, even ifusethrows. -
ripemd256Instance(
) → BuSerializableHash< BuHashState> -
ripemd320<
T extends Object?> (T use(BuSerializableHash< BuHashState> cipher)) → T -
Runs
usewith a fresh RIPEMD-320 hash, then wipes it. The instance must be clean after you don't need it; this method guarantees that, even ifusethrows. -
ripemd320Instance(
) → BuSerializableHash< BuHashState> -
salsaBoxBeforenm(
{required List< int> peerPublicKey, required List<int> secretKey}) → BuBytes -
NaCl
crypto_box_beforenmquick call, routed through the active backend (Dart today, native automatically once the connector gains box support). Returns the 32-byte transport key. -
salsaBoxDecrypt(
{required List< int> peerPublicKey, required List<int> secretKey, required List<int> nonce, required List<int> sealed}) → BuBytes? -
NaCl
crypto_box_open_easydetached decrypt quick call, routed through the active backend. Returns plaintext, ornullon authentication failure. -
salsaBoxEncrypt(
{required List< int> peerPublicKey, required List<int> secretKey, required List<int> nonce, required List<int> plainText}) → BuBytes -
NaCl
crypto_box_easydetached encrypt quick call, routed through the active backend. Explicit 24-bytenonce; returnsTAG || CIPHERTEXT. -
salsaBoxOpen(
{required List< int> peerPublicKey, required List<int> secretKey, required List<int> sealed}) → BuBytes? -
Opens a
NONCE || TAG || CIPHERTEXTblob, routed through the active backend. Returnsnullwhen truncated or unauthenticated. -
salsaBoxSeal(
{required List< int> peerPublicKey, required List<int> secretKey, required List<int> plainText, List<int> ? nonce}) → BuBytes -
NaCl
crypto_boxseal quick call for TON Connect, routed through the active backend: X25519 + XSalsa20-Poly1305, returningNONCE || TAG || CIPHERTEXT. Generates a fresh random 24-byte nonce (web-safe Fortuna PRNG) whennonceis omitted; pass an explicit nonce for deterministic vectors/tests. -
scryptDerive(
List< int> password, List<int> salt, {int dkLen = 32, int r = 8, int n = 8192, int p = 1}) → BuBytes -
seal(
) → void - One-way latch: after seal, setupPRNG, setupRandom and setupBackendRng throw. Call once during app startup to prevent any later code from swapping the random source (e.g. with a deterministic generator that makes keys predictable). Tests never seal.
-
setupBackendRng(
{bool seal = false}) → void -
Routes generateRandom through the active backend RNG
(
blockchainUtils.api.rng, seeded below when necessary). -
setupPRNG(
Rng prng, {bool seal = false}) → void -
setupRandom(
CbGenerateRandom? random, {bool seal = false}) → void -
sha1<
T extends Object?> (T use(BuSerializableHash< BuHashState> cipher)) → T -
Runs
usewith a fresh SHA-1 hash, then wipes it. The instance must be clean after you don't need it; this method guarantees that, even ifusethrows. -
sha1Hash(
List< int> data) → BuBytes -
sha1Instance(
) → BuSerializableHash< BuHashState> -
sha224Hash(
List< int> data) → BuBytes - Calculate the SHA-256 hash of the input data
-
sha256<
T extends Object?> (T use(BuSerializableHash< BuHashState> cipher)) → T -
Runs
usewith a fresh SHA-256 hash, then wipes it. The instance must be clean after you don't need it; this method guarantees that, even ifusethrows. -
sha256DoubleHash(
List< int> data) → BuBytes - Calculate the SHA-256 hash of the SHA-256 hash of the input data
-
sha256Hash(
List< int> data) → BuBytes - Calculate the SHA-256 hash of the input data
-
sha256Instance(
) → BuSerializableHash< BuHashState> -
sha3<
T extends Object?> (T use(BuSerializableHash< BuHashState> cipher), {int digestLength = 32}) → T -
Runs
usewith a fresh SHA-3 hash, then wipes it. The instance must be clean after you don't need it; this method guarantees that, even ifusethrows. -
sha3256Hash(
List< int> data) → BuBytes - Calculate the SHA-3-256 hash of the input data
-
sha384Hash(
List< int> data) → BuBytes - Calculate the SHA-512 hash of the input data
-
sha3Instance(
{int digestLength = 32}) → BuSerializableHash< BuHashState> -
sha512<
T extends Object?> (T use(BuSerializableHash< BuHashState> cipher)) → T -
Runs
usewith a fresh SHA-512 hash, then wipes it. The instance must be clean after you don't need it; this method guarantees that, even ifusethrows. -
sha512256<
T extends Object?> (T use(BuSerializableHash< BuHashState> cipher)) → T -
Runs
usewith a fresh SHA-512/256 hash, then wipes it. The instance must be clean after you don't need it; this method guarantees that, even ifusethrows. -
sha512256Hash(
List< int> data) → BuBytes - Calculate the SHA-512/256 hash of the input data
-
sha512256Instance(
) → BuSerializableHash< BuHashState> -
sha512Hash(
List< int> data) → BuBytes - Calculate the SHA-512 hash of the input data
-
sha512HashHalves(
List< int> data) → (BuBytes, BuBytes) - Computes the SHA512 hash of the input data and returns its halves.
-
sha512Instance(
) → BuSerializableHash< BuHashState> -
shake128<
T extends Object?> (T use(BuSerializableHash< BuHashState> cipher)) → T -
Runs
usewith a fresh SHAKE-128 XOF, then wipes it. The instance must be clean after you don't need it; this method guarantees that, even ifusethrows. -
shake128Instance(
) → BuSerializableHash< BuHashState> -
shake256<
T extends Object?> (T use(BuSerializableHash< BuHashState> cipher)) → T -
Runs
usewith a fresh SHAKE-256 XOF, then wipes it. The instance must be clean after you don't need it; this method guarantees that, even ifusethrows. -
shake256Hash(
List< int> data, int outlen) → BuBytes -
shake256Instance(
) → BuSerializableHash< BuHashState> -
tryChaCha20Poly1305Decrypt(
{required List< int> key, required List<int> nonce, required List<int> cipherText, List<int> ? assocData}) → BuBytes? - Decrypt data using the ChaCha20-Poly1305 authenticated encryption algorithm. Requires a key, nonce, ciphertext, and optional associated data.
-
twoX128(
List< int> data) → BuBytes -
twoX256(
List< int> data) → BuBytes -
twoX64(
List< int> data) → BuBytes -
xsalsa20Poly1305<
T extends Object?> (List< int> key, T use(BuAead cipher)) → T -
Runs
usewith a fresh XSalsa20-Poly1305 AEAD built fromkey, then wipes it. The instance must be clean after you don't need it; this method guarantees that, even ifusethrows. -
xsalsa20Poly1305Decrypt(
{required List< int> key, required List<int> nonce, required List<int> cipherText}) → BuBytes -
Decrypt with XSalsa20-Poly1305. Throws
CryptoExceptionon authentication failure. -
xsalsa20Poly1305Encrypt(
{required List< int> key, required List<int> nonce, required List<int> plainText}) → BuBytes -
Encrypt with XSalsa20-Poly1305 (NaCl secretbox order:
16-byte tag || ciphertext). -
xsalsa20Poly1305Instance(
List< int> key) → BuAead -
XSalsa20-Poly1305 (NaCl secretbox) AEAD from a 32-byte
key. Strict 24-byte nonce. Pure-Dart on every backend (web-safe). -
xxHash<
T extends Object?> (T use(BuSerializableHash< BuHashState> cipher), {int bitLength = 64}) → T -
Runs
usewith a fresh XXHash, then wipes it. The instance must be clean after you don't need it; this method guarantees that, even ifusethrows. -
xxHashInstance(
{int bitLength = 64}) → BuSerializableHash< BuHashState>
Constants
- blake2b32DigestSize → const int
- Define the size of BLAKE2b-32 digests, which is 4 bytes (32 bits)
- blake2b40DigestSize → const int
- Define the size of BLAKE2b-40 digests, which is 5 bytes (40 bits)
- blake2b64DigestSize → const int
- Define the size of BLAKE2b-32 digests, which is 4 bytes (32 bits)
- blake2b128DigestSize → const int
- Define the size of BLAKE2b-160 digests, which is 20 bytes (128 bits)
- blake2b160DigestSize → const int
- Define the size of BLAKE2b-160 digests, which is 20 bytes (160 bits)
- blake2b224DigestSize → const int
- Define the size of BLAKE2b-224 digests, which is 28 bytes (224 bits)
- blake2b256DigestSize → const int
- Define the size of BLAKE2b-256 digests, which is 32 bytes (256 bits)
- blake2b512DigestSize → const int
- Define the size of BLAKE2b-512 digests, which is 64 bytes (512 bits)
- chacha20Polu1305Keysize → const int
- Define the key size for ChaCha20-Poly1305, which is 32 bytes
- chacha20Polu1305Taglenght → const int
- Define the tag length for ChaCha20-Poly1305, which is 16 bytes
- hash160DigestSize → const int
- Define the size of RIPEMD-160 digests, which is 20 bytes (160 bits)
- hmacSha512DigestSize → const int
- Define the size of HMAC-SHA-512 digests, which is 64 bytes (512 bits)
- sha256DigestSize → const int
- Static property that defines the size of SHA-256 digests in bytes
- sha512DigestLength → const int
- Gets the length of the SHA512 digest.
- sha3256DigestSize → const int
- Define the size of SHA-3-256 digests, which is 32 bytes (256 bits)
- twoX64DigestSize → const int
- twoX128DigestSize → const int
- twoX256DigestSize → const int
- xsalsa20Poly1305KeySize → const int
- Define the key size for XSalsa20-Poly1305, which is 32 bytes
- xsalsa20Poly1305NonceSize → const int
- Define the nonce size for XSalsa20-Poly1305, which is 24 bytes
- xsalsa20Poly1305TagLength → const int
- Define the tag length for XSalsa20-Poly1305, which is 16 bytes