DigestAlgorithm extension type
A message digest algorithm, by the name OpenSSL knows it under.
The digest and HMAC APIs take the algorithm as a String, which is how
EVP_get_digestbyname wants it — and how a typo becomes a runtime error.
This type carries the same string but gives the usual algorithms a name the
compiler checks. It is a String underneath, so it goes wherever the API
takes an algorithm name, with no wrapping or conversion:
final mac = openSsl.hmac(DigestAlgorithm.sha256, key, data);
final hex = openSsl.digestHex(DigestAlgorithm.sha512, bytes);
final digest = openSsl.startDigest(DigestAlgorithm.sha3_256);
Algorithms not listed here can still be named by string, or wrapped with
DigestAlgorithm.new for callers that want the type at their own API
boundary: const DigestAlgorithm('whirlpool').
Everything listed is in OpenSSL 3's default provider, so none of it needs
the legacy provider loaded. md5 and sha1 are here for checksums and
interoperability, not for anything that has to resist an attacker.
- on
- Implemented types
- Available extensions
Constructors
- DigestAlgorithm(String opensslName)
-
const
Properties
-
codeUnits
→ List<
int> -
An unmodifiable list of the UTF-16 code units of this string.
no setterinherited
- hashCode → int
-
A hash code derived from the code units of the string.
no setterinherited
- isEmpty → bool
-
Whether this string is empty.
no setterinherited
- isNotEmpty → bool
-
Whether this string is not empty.
no setterinherited
- length → int
-
The length of the string.
no setterinherited
- opensslName → String
-
final
- runes → Runes
-
An Iterable of Unicode code-points of this string.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- toJS → JSString
-
Available on String, provided by the StringToJSString extension
Converts this String to a JSString.no setter
Methods
-
allMatches(
String string, [int start = 0]) → Iterable< Match> -
Matches this pattern against the string repeatedly.
inherited
-
codeUnitAt(
int index) → int -
Returns the 16-bit UTF-16 code unit at the given
index.inherited -
compareTo(
String other) → int -
Compares this string to
other.inherited -
contains(
Pattern other, [int startIndex = 0]) → bool -
Whether this string contains a match of
other.inherited -
endsWith(
String other) → bool -
Whether this string ends with
other.inherited -
indexOf(
Pattern pattern, [int start = 0]) → int -
Returns the position of the first match of
patternin this string, starting atstart, inclusive:inherited -
lastIndexOf(
Pattern pattern, [int? start]) → int -
The starting position of the last match
patternin this string.inherited -
matchAsPrefix(
String string, [int start = 0]) → Match? -
Matches this pattern against the start of
string.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
padLeft(
int width, [String padding = ' ']) → String -
Pads this string on the left if it is shorter than
width.inherited -
padRight(
int width, [String padding = ' ']) → String -
Pads this string on the right if it is shorter than
width.inherited -
replaceAll(
Pattern from, String replace) → String -
Replaces all substrings that match
fromwithreplace.inherited -
replaceAllMapped(
Pattern from, String replace(Match match)) → String -
Replace all substrings that match
fromby a computed string.inherited -
replaceFirst(
Pattern from, String to, [int startIndex = 0]) → String -
Creates a new string with the first occurrence of
fromreplaced byto.inherited -
replaceFirstMapped(
Pattern from, String replace(Match match), [int startIndex = 0]) → String -
Replace the first occurrence of
fromin this string.inherited -
replaceRange(
int start, int? end, String replacement) → String -
Replaces the substring from
starttoendwithreplacement.inherited -
split(
Pattern pattern) → List< String> -
Splits the string at matches of
patternand returns a list of substrings.inherited -
splitMapJoin(
Pattern pattern, {String onMatch(Match)?, String onNonMatch(String)?}) → String -
Splits the string, converts its parts, and combines them into a new
string.
inherited
-
startsWith(
Pattern pattern, [int index = 0]) → bool -
Whether this string starts with a match of
pattern.inherited -
substring(
int start, [int? end]) → String -
The substring of this string from
start, inclusive, toend, exclusive.inherited -
toLowerCase(
) → String -
Converts all characters in this string to lower case.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
toUpperCase(
) → String -
Converts all characters in this string to upper case.
inherited
-
trim(
) → String -
The string without any leading and trailing whitespace.
inherited
-
trimLeft(
) → String -
The string without any leading whitespace.
inherited
-
trimRight(
) → String -
The string without any trailing whitespace.
inherited
Operators
-
operator *(
int times) → String -
Creates a new string by concatenating this string with itself a number
of times.
inherited
-
operator +(
String other) → String -
Creates a new string by concatenating this string with
other.inherited -
operator ==(
Object other) → bool -
Whether
otheris aStringwith the same sequence of code units.inherited -
operator [](
int index) → String -
The character (as a single-code-unit String) at the given
index.inherited
Constants
- blake2b512 → const DigestAlgorithm
- BLAKE2b with a 64-byte digest.
- blake2s256 → const DigestAlgorithm
- BLAKE2s with a 32-byte digest.
- md5 → const DigestAlgorithm
- MD5, 16 bytes. Broken for collision resistance; checksums only.
- sha1 → const DigestAlgorithm
- SHA-1, 20 bytes. Broken for collision resistance; legacy interop only.
- sha3_224 → const DigestAlgorithm
- SHA3-224, 28 bytes.
- sha3_256 → const DigestAlgorithm
- SHA3-256, 32 bytes.
- sha3_384 → const DigestAlgorithm
- SHA3-384, 48 bytes.
- sha3_512 → const DigestAlgorithm
- SHA3-512, 64 bytes.
- sha224 → const DigestAlgorithm
- SHA-224, 28 bytes.
- sha256 → const DigestAlgorithm
- SHA-256, 32 bytes. The default choice.
- sha384 → const DigestAlgorithm
- SHA-384, 48 bytes.
- sha512 → const DigestAlgorithm
- SHA-512, 64 bytes.
- sha512_224 → const DigestAlgorithm
- SHA-512/224, 28 bytes: SHA-512 truncated, with its own IV.
- sha512_256 → const DigestAlgorithm
- SHA-512/256, 32 bytes: SHA-512 truncated, with its own IV.
- sm3 → const DigestAlgorithm
- SM3, 32 bytes (Chinese national standard).
-
values
→ const List<
DigestAlgorithm> - Every algorithm this type names, for tests and pickers.