hashlib library

Secure hash algorithms in pure dart.

Classes

Argon2
Creates a context for Argon2 password hashing.
Argon2Context
The configuration used by the Argon2 algorithm
Argon2HashDigest
Argon2Security
This contains some recommended values of memory, iteration and parallelism values for Argon2 algorithm.
Bcrypt
BcryptContext
The configuration used by the Bcrypt algorithm
BcryptHashDigest
BcryptSecurity
This contains some recommended parameters for Bcrypt algorithm.
Blake2b
Blake2b is a highly secure cryptographic hash function optimized for 64-bit platforms. It generates hash values of data ranging from 1 to 64 bytes in size. It doesn't require a separate keying mechanism and can be used in various applications, serving as a more efficient alternative to other hash algorithms like SHA and HMAC-SHA.
Blake2bHash
The implementation is derived from RFC-7693 document for "The BLAKE2 Cryptographic Hash and Message Authentication Code (MAC)".
Blake2bMAC
Blake2s
Blake2s is a cryptographic hash function optimized for 8-bit to 32-bit platforms. It generates hash values of data ranging from 1 to 32 bytes in size. Blake2s is highly secure and can be used in various applications as a fast and secure replacement for legacy algorithms like MD5 and HMAC-MD5.
Blake2sHash
The implementation is derived from RFC-7693 document for "The BLAKE2 Cryptographic Hash and Message Authentication Code (MAC)".
Blake2sMAC
BlockHashBase<T extends BlockHashSink>
BlockHashRegistry
A registry to find a block hash algorithm by name
BlockHashSink
HashBase<T extends HashDigestSink>
The base class used by the hash algorithm implementations. It implements the StreamTransformer and exposes few convenient methods to handle any types of data source.
HashDigest
HashDigestSink
This sink allows adding arbitrary length byte arrays and produces a HashDigest on close.
HashRegistry
A registry to find a hash algorithm by name
HMAC<T extends BlockHashBase<BlockHashSink>>
HMAC is a hash-based message authentication code that can be used to simultaneously verify both the data integrity and authenticity of a message.
HOTP
An HMAC-based One-Time Password (HOTP) algorithm implementation derived from rfc4226.
KeyDerivatorBase
MACHash<T extends HashDigestSink>
MACHashBase<T extends HashDigestSink>
This can be used as a mixin for MAC algorithm interfaces
MACSinkBase
OTPAuth
Represents an abstract class for implementing One-Time Password (OTP) authentication methods in Dart.
PBKDF2
This is an implementation of Password Based Key Derivation Algorithm, PBKDF2 derived from RFC-8081, which internally uses a MAC based Pseudo Random Function (PRF) for key derivation.
PBKDF2Security
This contains some recommended parameters for PBKDF2 algorithm.
Poly1305
Poly1305Sink
This implementation is derived from the The Poly1305 Algorithms described in the ChaCha20 and Poly1305 for IETF Protocols document.
Scrypt
This is an implementation of Password Based Key Derivation Algorithm, scrypt derived from RFC-7914, which internally uses PBKDF2.
ScryptSecurity
This contains some recommended values of memory, iteration and parallelism values for Scrypt algorithm.
Shake128
SHAKE-128 is a member of SHA-3 family which uses 128-bit blocks to generate a message digest of arbitrary length.
Shake256
SHAKE-256 is a member of SHA-3 family which uses 256-bit blocks to generate a message digest of arbitrary length.
TOTP
A Time-based One-Time Password (TOTP) algorithm implementation derived from rfc6238.
XXH128
This is an implementation of 128-bit XXH3 hash algorithm of xxHash family derived from https://github.com/Cyan4973/xxHash
XXH3
This is an implementation of 64-bit XXH3 hash algorithm of xxHash family derived from https://github.com/Cyan4973/xxHash
XXHash32
XXHash32 is a fast and efficient non-cryptographic hash function for 32-bit platforms. It is designed for producing a quick and reliable hash value for a given data, which can be used for many applications, such as checksum, data validation, etc. In addition, it has a good distribution of hash values, which helps to reduce collisions.
XXHash64
XXHash64 is a fast and efficient non-cryptographic hash function for 64-bit platforms. It is designed for producing a quick and reliable hash value for a given data, which can be used for many applications, such as checksum, data validation, etc. In addition, it has a good distribution of hash values, which helps to reduce collisions.

Enums

Argon2Type
Argon2Version
The Argon2 version
BcryptVersion

Extensions

Argon2VersionValue on Argon2Version
HashBaseFileSupport on HashBase<HashDigestSink>
HMAConBlockHashBase on T
Extension on BlockHashBase to get an HMAC instance
PBKDF2onBlockHashBase on BlockHashBase<BlockHashSink>
Extension on BlockHashBase to get an PBKDF2 instance
PBKDF2onMACHashBase on MACHash<HashDigestSink>
Extension to the HashBase to get an PBKDF2 instance

Constants

alder32 → const HashBase<HashDigestSink>
Adler-32 is composed of two sums accumulated per byte.
blake2b160 → const Blake2b
For generating un-keyed message digest with BLAKE2b-160.
blake2b256 → const Blake2b
For generating un-keyed message digest with BLAKE2b-256.
blake2b384 → const Blake2b
For generating un-keyed message digest with BLAKE2b-384.
blake2b512 → const Blake2b
For generating un-keyed message digest with BLAKE2b-512.
blake2s128 → const Blake2s
For generating un-keyed message digest with BLAKE2s-128.
blake2s160 → const Blake2s
For generating un-keyed message digest with BLAKE2s-160.
blake2s224 → const Blake2s
For generating un-keyed message digest with BLAKE2s-224.
blake2s256 → const Blake2s
For generating un-keyed message digest with BLAKE2s-256.
crc16 → const HashBase<HashDigestSink>
A CRC or cyclic redundancy check is code commonly used for error detection and correction of digital data. This generates a 16-bit number as output.
crc32 → const HashBase<HashDigestSink>
A CRC-32 code generator with IEEE 802.3 CRC-32 polynomial.
crc64 → const HashBase<HashDigestSink>
A CRC-64 code generator with ISO CRC-64 polynomial.
hmac_sha256 → const HMAC<BlockHashBase<BlockHashSink>>
The HMAC/SHA-256 algorithm
keccak224 → const BlockHashBase<BlockHashSink>
Keccak-224 is a member of Keccak family hash functions that generates a 224-bit hash.
keccak256 → const BlockHashBase<BlockHashSink>
Keccak-256 is a member of Keccak family hash functions that generates a 256-bit hash.
keccak384 → const BlockHashBase<BlockHashSink>
Keccak-384 is a member of Keccak family hash functions that generates a 384-bit hash.
keccak512 → const BlockHashBase<BlockHashSink>
Keccak-512 is a member of Keccak family hash functions that generates a 512-bit hash.
md4 → const BlockHashBase<BlockHashSink>
MD4 can be used as a checksum to verify data integrity against unintentional corruption. Although it was widely used as a cryptographic hash function once, it has been found to suffer from extensive vulnerabilities.
md5 → const BlockHashBase<BlockHashSink>
MD5 can be used as a checksum to verify data integrity against unintentional corruption. Although it was widely used as a cryptographic hash function once, it has been found to suffer from extensive vulnerabilities.
poly1305 → const _Poly1305
The Poly1305 MAC (message authentication code) generator for an input message using either 16 or 32-byte long authentication key.
ripemd128 → const BlockHashBase<BlockHashSink>
RIPEMD-128 (RACE Integrity Primitives Evaluation Message Digest) is a cryptographic hash function that produces a fixed-size, 128-bit hash value.
ripemd160 → const BlockHashBase<BlockHashSink>
RIPEMD-160 (RACE Integrity Primitives Evaluation Message Digest) is a cryptographic hash function that produces a fixed-size, 160-bit hash value. It is used to verify the integrity and authenticity of messages and is resistant to various types of attacks, including collisions and preimage attacks. It is commonly used in security protocols and applications.
ripemd256 → const BlockHashBase<BlockHashSink>
RIPEMD-256 (RACE Integrity Primitives Evaluation Message Digest) is a cryptographic hash function that produces a fixed-size, 256-bit hash value.
ripemd320 → const BlockHashBase<BlockHashSink>
RIPEMD-320 (RACE Integrity Primitives Evaluation Message Digest) is a cryptographic hash function that produces a fixed-size, 320-bit hash value.
sha1 → const BlockHashBase<BlockHashSink>
SHA-1 produces a message digest based on principle similar to MD5, except it can generate a 160-bit hash. Since 2005, SHA-1 has not been considered secure and NIST formally deprecated it in 2001. It is no longer allowed in digital signatures, however it is safe to use it as a checksum to verify data integrity.
sha224 → const BlockHashBase<BlockHashSink>
SHA-224 is a member of SHA-2 family which uses 256-bit internal state to generate a message digest of 224-bit long.
sha256 → const BlockHashBase<BlockHashSink>
SHA-256 is a member of SHA-2 family which uses 256-bit internal state to generate a message digest of 256-bit long.
sha384 → const BlockHashBase<BlockHashSink>
SHA-384 is a member of SHA-2 family which uses 512-bit internal state to generate a message digest of 384-bit long.
sha3_224 → const BlockHashBase<BlockHashSink>
SHA3-224 is a member of SHA-3 family which uses 224-bit blocks to generate a message digest of 224-bit long.
sha3_256 → const BlockHashBase<BlockHashSink>
SHA3-256 is a member of SHA-3 family which uses 256-bit blocks to generate a message digest of 256-bit long.
sha3_384 → const BlockHashBase<BlockHashSink>
SHA3-384 is a member of SHA-3 family which uses 384-bit blocks to generate a message digest of 384-bit long.
sha3_512 → const BlockHashBase<BlockHashSink>
SHA3-512 is a member of SHA-3 family which uses 512-bit blocks to generate a message digest of 512-bit long.
sha512 → const BlockHashBase<BlockHashSink>
SHA-512 is a member of SHA-2 family which uses 512-bit internal state to generate a message digest of 512-bit long.
sha512t224 → const BlockHashBase<BlockHashSink>
SHA-512/224 is a variation of SHA-512 which uses 512-bit internal state to generate a message digest of 224-bit long truncating the last bits.
sha512t256 → const BlockHashBase<BlockHashSink>
SHA-512/256 is a variation of SHA-512 which uses 512-bit internal state to generate a message digest of 256-bit long truncating the last bits.
shake128 → const _Shake128Builder
SHAKE-128 is a member of SHA-3 family which uses 128-bit blocks to generate a message digest of arbitrary length.
shake128_128 → const Shake128
Shake128 instance to generate a 128-bit message digest.
shake128_160 → const Shake128
Shake128 instance to generate a 160-bit message digest.
shake128_224 → const Shake128
Shake128 instance to generate a 224-bit message digest.
shake128_256 → const Shake128
Shake128 instance to generate a 256-bit message digest.
shake128_384 → const Shake128
Shake128 instance to generate a 384-bit message digest.
shake128_512 → const Shake128
Shake128 instance to generate a 512-bit message digest.
shake256 → const _Shake256Builder
SHAKE-256 is a member of SHA-3 family which uses 256-bit blocks to generate a message digest of arbitrary length.
shake256_128 → const Shake256
Shake256 instance to generate a 128-bit message digest.
shake256_160 → const Shake256
Shake256 instance to generate a 160-bit message digest.
shake256_224 → const Shake256
Shake256 instance to generate a 224-bit message digest.
shake256_256 → const Shake256
Shake256 instance to generate a 256-bit message digest.
shake256_384 → const Shake256
Shake256 instance to generate a 384-bit message digest.
shake256_512 → const Shake256
Shake256 instance to generate a 512-bit message digest.
sm3 → const BlockHashBase<BlockHashSink>
SM3 ISO.IEC.10118-3 GBT.32905-2016 is a cryptographic hash algorithm published by the State Cryptography Administration (SCA) of China as an authorized cryptographic hash algorithm for the use within China.
xxh128 → const XXH128
An instance of XXH128 with seed = 0
xxh3 → const XXH3
An instance of XXH3 with seed = 0
xxh32 → const XXHash32
An instance of XXHash32 with seed = 0
xxh3_128 → const XXH128
An instance of XXH128 with seed = 0
xxh3_64 → const XXH3
An instance of XXH3 with seed = 0
xxh64 → const XXHash64
An instance of XXHash64 with seed = 0

Functions

alder32code(String input, [Encoding? encoding]) int
Gets the Alder-32 value of a String
argon2d(List<int> password, List<int> salt, {int? hashLength, List<int>? key, List<int>? personalization, Argon2Security security = _defaultSecurity}) Argon2HashDigest
Encode a password using default Argon2d algorithm
argon2i(List<int> password, List<int> salt, {int? hashLength, List<int>? key, List<int>? personalization, Argon2Security security = _defaultSecurity}) Argon2HashDigest
Encode a password using default Argon2i algorithm
argon2id(List<int> password, List<int> salt, {int? hashLength, List<int>? key, List<int>? personalization, Argon2Security security = _defaultSecurity}) Argon2HashDigest
Encode a password using default Argon2id algorithm
argon2Verify(String encoded, List<int> password) bool
Verifies if the original password was derived from the encoded Argon2 hash.
bcrypt(List<int> password, [String? salt]) String
Generates a secure password using the Bcrypt algorithm, and returns a 60-byte encoded string containing the version, cost, salt, and password.
bcryptDigest(List<int> password, {List<int>? salt, BcryptVersion version = BcryptVersion.$2b, BcryptSecurity security = BcryptSecurity.good, int? nb}) BcryptHashDigest
Generate a secure password using the Bcrypt algorithm.
bcryptSalt({int? nb, BcryptVersion version = BcryptVersion.$2b, BcryptSecurity security = BcryptSecurity.good}) String
Generate the encoded salt to be used by the Bcrypt algorithm.
bcryptVerify(String encoded, List<int> plain) bool
Verifies if the plain password was derived from the encoded hash.
crc16code(String input, [Encoding? encoding]) int
Gets the CRC-16 value of a String
crc32code(String input, [Encoding? encoding]) int
Gets the CRC-32 value of a String
crc64code(String input, [Encoding? encoding]) int
Gets the CRC-64 value of a String.
crc64sum(String input, [Encoding? encoding]) String
Gets the CRC-64 hash of a String in hexadecimal.
keccak224sum(String input, [Encoding? encoding, bool uppercase = false]) String
Generates a Keccak-224 checksum in hexadecimal
keccak256sum(String input, [Encoding? encoding, bool uppercase = false]) String
Generates a Keccak-256 checksum in hexadecimal
keccak384sum(String input, [Encoding? encoding, bool uppercase = false]) String
Generates a Keccak-384 checksum in hexadecimal
keccak512sum(String input, [Encoding? encoding, bool uppercase = false]) String
Generates a Keccak-512 checksum in hexadecimal
md4sum(String input, [Encoding? encoding, bool uppercase = false]) String
Generates a MD4 checksum in hexadecimal
md5sum(String input, [Encoding? encoding, bool uppercase = false]) String
Generates a MD5 checksum in hexadecimal
pbkdf2(List<int> password, List<int> salt, [int? iterations, int? keyLength]) HashDigest
This is an implementation of Password Based Key Derivation Algorithm, PBKDF2 derived from RFC-8081, which internally uses sha256 hash function for key derivation.
poly1305auth(List<int> message, List<int> keypair) HashDigest
Computes the Poly1305 MAC (message authentication code) of the given message using the given the 16 or 32-byte long keypair for authentication.
ripemd128sum(String input, [Encoding? encoding, bool uppercase = false]) String
Generates a RIPEMD-128 hash in hexadecimal
ripemd160sum(String input, [Encoding? encoding, bool uppercase = false]) String
Generates a RIPEMD-160 hash in hexadecimal
ripemd256sum(String input, [Encoding? encoding, bool uppercase = false]) String
Generates a RIPEMD-256 hash in hexadecimal
ripemd320sum(String input, [Encoding? encoding, bool uppercase = false]) String
Generates a RIPEMD-320 hash in hexadecimal
scrypt(List<int> password, List<int> salt, {int? N, int? r, int? p, int dklen = 64, ScryptSecurity security = ScryptSecurity.good}) HashDigest
Generate a secure password using the scrypt algorithm.
sha1sum(String input, [Encoding? encoding, bool uppercase = false]) String
Generates a SHA-1 checksum in hexadecimal
sha224sum(String input, [Encoding? encoding, bool uppercase = false]) String
Generates a SHA-224 checksum in hexadecimal
sha256sum(String input, [Encoding? encoding, bool uppercase = false]) String
Generates a SHA-256 checksum in hexadecimal
sha384sum(String input, [Encoding? encoding, bool uppercase = false]) String
Generates a SHA-384 checksum in hexadecimal
sha3_224sum(String input, [Encoding? encoding, bool uppercase = false]) String
Generates a SHA3-224 checksum in hexadecimal
sha3_256sum(String input, [Encoding? encoding, bool uppercase = false]) String
Generates a SHA3-256 checksum in hexadecimal
sha3_384sum(String input, [Encoding? encoding, bool uppercase = false]) String
Generates a SHA3-384 checksum in hexadecimal
sha3_512sum(String input, [Encoding? encoding, bool uppercase = false]) String
Generates a SHA3-512 checksum in hexadecimal
sha512sum(String input, [Encoding? encoding, bool uppercase = false]) String
Generates a SHA-512 checksum in hexadecimal
sha512t224sum(String input, [Encoding? encoding, bool uppercase = false]) String
Generates a SHA-512/224 checksum in hexadecimal
sha512t256sum(String input, [Encoding? encoding, bool uppercase = false]) String
Generates a SHA-512/256 checksum in hexadecimal
shake128generator([List<int>? seed]) Iterable<int>
Creates a SHAKE-128 based infinite hash generator.
shake128sum(String input, int outputSize, [Encoding? encoding, bool uppercase = false]) String
Generates a SHAKE-128 checksum in hexadecimal of arbitrary length
shake256generator([List<int>? seed]) Iterable<int>
Creates a SHAKE-256 based infinite hash generator.
shake256sum(String input, int outputSize, [Encoding? encoding, bool uppercase = false]) String
Generates a SHAKE-256 checksum in hexadecimal of arbitrary length
sm3sum(String input, [Encoding? encoding, bool uppercase = false]) String
Generates a SM3 checksum in hexadecimal
xxh128sum(String input, [Encoding? encoding]) String
Gets the 128-bit XXH3 hash of a String in hexadecimal.
xxh32code(String input, [Encoding? encoding]) int
Gets the 32-bit xxHash value of a String
xxh32sum(String input, [Encoding? encoding]) String
Gets the 32-bit xxHash hash of a String in hexadecimal.
xxh3code(String input, [Encoding? encoding]) int
Gets the 64-bit XXH3 value of a String.
xxh3sum(String input, [Encoding? encoding]) String
Gets the 64-bit XXH3 hash of a String in hexadecimal.
xxh64code(String input, [Encoding? encoding]) int
Gets the 64-bit xxHash value of a String.
xxh64sum(String input, [Encoding? encoding]) String
Gets the 64-bit xxHash hash of a String in hexadecimal.