public static class SecureHash.Companion
@JvmStatic @NotNull public SecureHash create(@Nullable java.lang.String str)
Converts a SecureHash hash value represented as a {algorithm:}hexadecimal String into a class SecureHash
.
str
- An optional algorithm id followed by a delimiter and the sequence of hexadecimal digits that represents a hash value.IllegalArgumentException
- The input string does not contain the expected number of hexadecimal digits, or it contains incorrectly-encoded characters.class SecureHash
@JvmStatic @NotNull public net.corda.core.crypto.SecureHash.SHA256 parse(@Nullable java.lang.String str)
Converts a SHA-256 hash value represented as a hexadecimal String into a class SecureHash
.
str
- A sequence of 64 hexadecimal digits that represents a SHA-256 hash value.IllegalArgumentException
- The input string does not contain 64 hexadecimal digits, or it contains incorrectly-encoded characters.class SecureHash
public int digestLengthFor(@NotNull java.lang.String algorithm)
algorithm
- The MessageDigest algorithm to query.@JvmStatic @NotNull public SecureHash hashAs(@NotNull java.lang.String algorithm, @NotNull kotlin.Array[] bytes)
Computes the hash value of the ByteArray.
@JvmStatic @NotNull public SecureHash componentHashAs(@NotNull java.lang.String algorithm, @NotNull kotlin.Array[] bytes)
Computes the digest of the ByteArray which is resistant to pre-image attacks.
It computes the hash of the hash for SHA2-256 and other algorithms loaded via JCA MessageDigest.
For custom algorithms the strategy can be modified via interface DigestAlgorithm
.
algorithm
- The MessageDigest algorithm to use.bytes
- The ByteArray to hash.interface DigestAlgorithm
@JvmStatic @NotNull public SecureHash nonceHashAs(@NotNull java.lang.String algorithm, @NotNull kotlin.Array[] bytes)
Computes the digest of the ByteArray which is resistant to pre-image attacks.
It computes the hash of the hash for SHA2-256 and other algorithms loaded via JCA MessageDigest.
For custom algorithms the strategy can be modified via interface DigestAlgorithm
.
algorithm
- The MessageDigest algorithm to use.bytes
- The ByteArray to hash.interface DigestAlgorithm
@JvmStatic @NotNull public net.corda.core.crypto.SecureHash.SHA256 sha256(@NotNull kotlin.Array[] bytes)
Computes the SHA-256 hash value of the ByteArray.
@JvmStatic @NotNull public net.corda.core.crypto.SecureHash.SHA256 sha256Twice(@NotNull kotlin.Array[] bytes)
Computes the SHA-256 hash of the ByteArray, and then computes the SHA-256 hash of the hash.
@JvmStatic @NotNull public net.corda.core.crypto.SecureHash.SHA256 sha256(@NotNull java.lang.String str)
Computes the SHA-256 hash of the String's UTF-8 byte contents.
@JvmStatic @NotNull public net.corda.core.crypto.SecureHash.SHA256 randomSHA256()
Generates a random SHA-256 value.
@JvmStatic @NotNull public SecureHash random(@NotNull java.lang.String algorithm)
Generates a random hash value.
@NotNull public net.corda.core.crypto.SecureHash.SHA256 getZeroHash()
A SHA-256 hash value consisting of 32 0x00 bytes. This function is provided for API stability.
@NotNull public net.corda.core.crypto.SecureHash.SHA256 getAllOnesHash()
A SHA-256 hash value consisting of 32 0xFF bytes. This function is provided for API stability.
@JvmStatic @NotNull public SecureHash zeroHashFor(@NotNull java.lang.String algorithm)
@JvmStatic @NotNull public SecureHash allOnesHashFor(@NotNull java.lang.String algorithm)