Enum HashAlgorithm
-
- All Implemented Interfaces:
-
java.io.Serializable,kotlin.Comparable
public enum HashAlgorithm extends Enum<HashAlgorithm>
An enum of supported hash algorithms. Each algorithm has one or more aliases associated to it, where the first alias is the definite name.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classHashAlgorithm.Companion
-
Field Summary
Fields Modifier and Type Field Description private final Array<out String>aliasesprivate final Booleanverifiableprivate final Stringnameprivate final Integerordinalprivate final EnumEntries<HashAlgorithm>entries
-
Enum Constant Summary
Enum Constants Enum Constant Description NONENo hash algorithm.
UNKNOWNAn unknown hash algorithm.
MD5The Message-Digest 5 hash algorithm, see MD5.
SHA1The Secure Hash Algorithm 1, see SHA-1.
SHA256The Secure Hash Algorithm 2 with 256 bits, see SHA-256.
SHA384The Secure Hash Algorithm 2 with 384 bits, see SHA-384.
SHA512The Secure Hash Algorithm 2 with 512 bits, see SHA-512.
SHA1GITThe Secure Hash Algorithm 1, but calculated on a Git "blob" object, see
https://git-scm.com/book/en/v2/Git-Internals-Git-Objects#_object_storage
https://docs.softwareheritage.org/devel/swh-model/persistent-identifiers.html#git-compatibility
-
Method Summary
Modifier and Type Method Description StringtoString()Convert the hash algorithm to a string representation. final Stringcalculate(File file)Return the hexadecimal digest of this hash for the given file. final Stringcalculate(ByteArray bytes)Return the hexadecimal digest of this hash for the given bytes. final Stringcalculate(String resourceName)Return the hexadecimal digest of this hash for the given resourceName. final HashAlgorithmvalueOf(String value)Returns the enum constant of this type with the specified name. final Array<HashAlgorithm>values()Returns an array containing the constants of this enum type, in the order they're declared. final Array<out String>getAliases()final BooleangetVerifiable()final EnumEntries<HashAlgorithm>getEntries()An enum of supported hash algorithms. -
-
Method Detail
-
calculate
final String calculate(File file)
Return the hexadecimal digest of this hash for the given file.
-
calculate
final String calculate(ByteArray bytes)
Return the hexadecimal digest of this hash for the given bytes.
-
calculate
final String calculate(String resourceName)
Return the hexadecimal digest of this hash for the given resourceName.
-
valueOf
final HashAlgorithm valueOf(String value)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
-
values
final Array<HashAlgorithm> values()
Returns an array containing the constants of this enum type, in the order they're declared.
This method may be used to iterate over the constants.
-
getAliases
final Array<out String> getAliases()
-
getVerifiable
final Boolean getVerifiable()
-
getEntries
final EnumEntries<HashAlgorithm> getEntries()
An enum of supported hash algorithms. Each algorithm has one or more aliases associated to it, where the first alias is the definite name.
-
-
-
-