SecureHash.Companion
Keywords: net.corda.core.crypto.SecureHash.Companion class
Date: 2023-09-18

net.corda.core.crypto

## Class SecureHash.Companion

- net.corda.core.crypto.SecureHash.Companion

- Enclosing class:
    SecureHash

      public static class SecureHash.Companion

- - ### Method Detail

    - #### getInterner

          @NotNull
          public net.corda.core.internal.utilities.PrivateInterner<net.corda.core.crypto.SecureHash> getInterner()

    - #### create

          @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`.

      Parameters:
        `str` - An optional algorithm id followed by a delimiter and the sequence of hexadecimal digits that represents a hash value.
      Throws:
        `IllegalArgumentException` - The input string does not contain the expected number of hexadecimal digits, or it contains incorrectly-encoded characters.
      See Also:
        String, `class SecureHash`

    - #### parse

          @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`.

      Parameters:
        `str` - A sequence of 64 hexadecimal digits that represents a SHA-256 hash value.
      Throws:
        `IllegalArgumentException` - The input string does not contain 64 hexadecimal digits, or it contains incorrectly-encoded characters.
      See Also:
        String, `class SecureHash`

    - #### createSHA256

          @JvmStatic
           @NotNull
          public net.corda.core.crypto.SecureHash.SHA256 createSHA256(@NotNull
                                                                                           kotlin.Array[] bytes)

      Factory method for SHA256 to be used in preference to the constructor.

    - #### digestLengthFor

          public int digestLengthFor(@NotNull
                                     java.lang.String algorithm)

      Parameters:
        `algorithm` - The MessageDigest algorithm to query.
      Returns:
        The length in bytes of this MessageDigest.

    - #### hashAs

          @JvmStatic
           @NotNull
          public SecureHash hashAs(@NotNull
                                                        java.lang.String algorithm,
                                                        @NotNull
                                                        kotlin.Array[] bytes)

      Computes the hash value of the ByteArray.

      Parameters:
        `algorithm` - Java provider name of the digest algorithm.
        `bytes` - The ByteArray to hash.
      See Also:
        ByteArray

    - #### componentHashAs

          @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`.

      Parameters:
        `algorithm` - The MessageDigest algorithm to use.
        `bytes` - The ByteArray to hash.
      See Also:
        ByteArray, MessageDigest, `interface DigestAlgorithm`

    - #### nonceHashAs

          @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`.

      Parameters:
        `algorithm` - The MessageDigest algorithm to use.
        `bytes` - The ByteArray to hash.
      See Also:
        ByteArray, MessageDigest, `interface DigestAlgorithm`

    - #### sha256

          @JvmStatic
           @NotNull
          public net.corda.core.crypto.SecureHash.SHA256 sha256(@NotNull
                                                                                     kotlin.Array[] bytes)

      Computes the SHA-256 hash value of the ByteArray.

      Parameters:
        `bytes` - The ByteArray to hash.
      See Also:
        ByteArray

    - #### sha256Twice

          @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.

      Parameters:
        `bytes` - The ByteArray to hash.
      See Also:
        ByteArray

    - #### sha256

          @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.

      Parameters:
        `str` - String whose UTF-8 contents will be hashed.
      See Also:
        String

    - #### randomSHA256

          @JvmStatic
           @NotNull
          public net.corda.core.crypto.SecureHash.SHA256 randomSHA256()

      Generates a random SHA-256 value.

    - #### random

          @JvmStatic
           @NotNull
          public SecureHash random(@NotNull
                                                        java.lang.String algorithm)

      Generates a random hash value.

    - #### getZeroHash

          @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.

    - #### getAllOnesHash

          @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.

    - #### zeroHashFor

          @JvmStatic
           @NotNull
          public SecureHash zeroHashFor(@NotNull
                                                             java.lang.String algorithm)

    - #### allOnesHashFor

          @JvmStatic
           @NotNull
          public SecureHash allOnesHashFor(@NotNull
                                                                java.lang.String algorithm)