public class SecureHash extends OpaqueBytes
Container for a cryptographically secure hash value. Provides utilities for generating a cryptographic hash using different algorithms (currently only SHA-256 supported).
Modifier and Type | Class and Description |
---|---|
static class |
SecureHash.Companion |
static class |
SecureHash.SHA256
SHA-256 is part of the SHA-2 hash function family. Generated hash is fixed size, 256-bits (32-bytes).
|
Modifier and Type | Field and Description |
---|---|
static SecureHash.Companion |
Companion |
static SecureHash.SHA256 |
allOnesHash
A SHA-256 hash value consisting of 32 0xFF bytes.
This field provides more intuitive access from Java.
|
static SecureHash.SHA256 |
zeroHash
A SHA-256 hash value consisting of 32 0x00 bytes.
This field provides more intuitive access from Java.
|
Modifier and Type | Method and Description |
---|---|
SecureHash.SHA256 |
hashConcat(SecureHash other)
Append a second hash value to this hash value, and then compute the SHA-256 hash of the result.
|
static SecureHash.SHA256 |
parse(java.lang.String str)
Converts a SHA-256 hash value represented as a hexadecimal String into a
class SecureHash . |
java.lang.String |
prefixChars(int prefixLen)
Returns the first prefixLen hexadecimal digits of the
class SecureHash value. |
static SecureHash.SHA256 |
randomSHA256()
Generates a random SHA-256 value.
|
static SecureHash.SHA256 |
sha256(byte[] bytes)
Computes the SHA-256 hash value of the ByteArray.
|
static SecureHash.SHA256 |
sha256(java.lang.String str)
Computes the SHA-256 hash of the String's UTF-8 byte contents.
|
static SecureHash.SHA256 |
sha256Twice(byte[] bytes)
Computes the SHA-256 hash of the ByteArray, and then computes the SHA-256 hash of the hash.
|
java.lang.String |
toString()
Convert the hash value to an uppercase hexadecimal String.
|
getBytes, of
public static SecureHash.SHA256 zeroHash
A SHA-256 hash value consisting of 32 0x00 bytes. This field provides more intuitive access from Java.
public static SecureHash.SHA256 allOnesHash
A SHA-256 hash value consisting of 32 0xFF bytes. This field provides more intuitive access from Java.
public static SecureHash.Companion Companion
public java.lang.String toString()
Convert the hash value to an uppercase hexadecimal String.
public java.lang.String prefixChars(int prefixLen)
Returns the first prefixLen hexadecimal digits of the class SecureHash
value.
prefixLen
- The number of characters in the prefix.class SecureHash
public SecureHash.SHA256 hashConcat(SecureHash other)
Append a second hash value to this hash value, and then compute the SHA-256 hash of the result.
other
- The hash to append to this one.public static SecureHash.SHA256 parse(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.class SecureHash
public static SecureHash.SHA256 sha256(byte[] bytes)
Computes the SHA-256 hash value of the ByteArray.
public static SecureHash.SHA256 sha256Twice(byte[] bytes)
Computes the SHA-256 hash of the ByteArray, and then computes the SHA-256 hash of the hash.
public static SecureHash.SHA256 sha256(java.lang.String str)
Computes the SHA-256 hash of the String's UTF-8 byte contents.
public static SecureHash.SHA256 randomSHA256()
Generates a random SHA-256 value.