sealed class SecureHash : OpaqueBytes
Container for a cryptographically secure hash value. Provides utilities for generating a cryptographic hash using different algorithms (currently only SHA-256 supported).
Companion |
companion object Companion : Internable<SecureHash> |
HASH |
class HASH : SecureHash |
SHA256 |
SHA-256 is part of the SHA-2 hash function family. Generated hash is fixed size, 256-bits (32-bytes). class SHA256 : SecureHash |
concatenate |
Append a second hash value to this hash value, and then compute the hash of the result. fun concatenate(other: SecureHash): SecureHash |
concatenateAs |
Append a second hash value to this hash value, and then compute the hash of the result using the specified algorithm. fun concatenateAs(concatAlgorithm: String, other: SecureHash): SecureHash |
generate |
open fun generate(data: ByteArray): SecureHash |
hashConcat |
Append a second hash value to this hash value, and then compute the SHA-256 hash of the result. fun hashConcat(other: SecureHash): SHA256 |
prefixChars |
Returns the first prefixLen hexadecimal digits of the SecureHash value. fun prefixChars(prefixLen: Int = 6): String |
reHash |
fun reHash(): SecureHash |
toHexString |
fun toHexString(): String |
toString |
open fun toString(): String |
allOnesHash |
A SHA-256 hash value consisting of 32 0xFF bytes. This field provides more intuitive access from Java. val allOnesHash: SHA256 |
DELIMITER |
const val DELIMITER: Char |
interner |
val interner: PrivateInterner<SecureHash> |
SHA2_256 |
const val SHA2_256: String |
SHA2_384 |
const val SHA2_384: String |
SHA2_512 |
const val SHA2_512: String |
zeroHash |
A SHA-256 hash value consisting of 32 0x00 bytes. This field provides more intuitive access from Java. val zeroHash: SHA256 |
allOnesHashFor |
fun allOnesHashFor(algorithm: String): SecureHash |
componentHashAs |
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 DigestAlgorithm. fun componentHashAs(algorithm: String, bytes: ByteArray): SecureHash |
create |
Converts a SecureHash hash value represented as a {algorithm:}hexadecimal String into a SecureHash. fun create(str: String?): SecureHash |
createSHA256 |
Factory method for SHA256 to be used in preference to the constructor. fun createSHA256(bytes: ByteArray): SHA256 |
digestLengthFor |
fun digestLengthFor(algorithm: String): Int |
getAllOnesHash |
A SHA-256 hash value consisting of 32 0xFF bytes. This function is provided for API stability. fun getAllOnesHash(): SHA256 |
getZeroHash |
A SHA-256 hash value consisting of 32 0x00 bytes. This function is provided for API stability. fun getZeroHash(): SHA256 |
hashAs |
Computes the hash value of the ByteArray. fun hashAs(algorithm: String, bytes: ByteArray): SecureHash |
nonceHashAs |
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 DigestAlgorithm. fun nonceHashAs(algorithm: String, bytes: ByteArray): SecureHash |
parse |
Converts a SHA-256 hash value represented as a hexadecimal String into a SecureHash. fun parse(str: String?): SHA256 |
random |
Generates a random hash value. fun random(algorithm: String): SecureHash |
randomSHA256 |
Generates a random SHA-256 value. fun randomSHA256(): SHA256 |
sha256 |
Computes the SHA-256 hash value of the ByteArray. fun sha256(bytes: ByteArray): SHA256
Computes the SHA-256 hash of the String's UTF-8 byte contents. fun sha256(str: String): SHA256 |
sha256Twice |
Computes the SHA-256 hash of the ByteArray, and then computes the SHA-256 hash of the hash. fun sha256Twice(bytes: ByteArray): SHA256 |
zeroHashFor |
fun zeroHashFor(algorithm: String): SecureHash |
algorithm |
Hash algorithm. val SecureHash.algorithm: String |
isZero |
val OpaqueBytes.isZero: Boolean |
deserialize |
Convenience extension method for deserializing a ByteSequence, utilising the defaults. fun <T : Any> ByteSequence.deserialize(serializationFactory: SerializationFactory = SerializationFactory.defaultFactory, context: SerializationContext = serializationFactory.defaultContext): T |
deserializeWithCompatibleContext |
Additionally returns SerializationContext which was used for encoding. It might be helpful to know SerializationContext to use the same encoding in the reply. fun <T : Any> ByteSequence.deserializeWithCompatibleContext(serializationFactory: SerializationFactory = SerializationFactory.defaultFactory, context: SerializationContext = serializationFactory.defaultContext): ObjectWithCompatibleContext<T> |
hashAs |
Compute the algorithm hash for the contents of the OpaqueBytes. fun OpaqueBytes.hashAs(algorithm: String): SecureHash |
sha256 |
Compute the SHA-256 hash for the contents of the OpaqueBytes. fun OpaqueBytes.sha256(): SHA256 |