Documentation / @cashconnect-js/core / primitives/hasher
Hasher
Defined in: cashconnect-js/packages/core/src/primitives/hasher.ts:17
Represents a hash primitive that provides various cryptographic hashing capabilities. This class handles conversions between different formats (bytes, hex, UTF-8) and supports multiple hashing algorithms (SHA256, RIPEMD160, Hash160, Hash256).
Constructors
Constructor
new Hasher(bytes): Hasher;Defined in: cashconnect-js/packages/core/src/primitives/hasher.ts:22
Creates a new Hash instance.
Parameters
| Parameter | Type | Description |
|---|---|---|
bytes | Uint8Array | The byte array representation of the data to be hashed |
Returns
Methods
fromBytes()
static fromBytes(bytes): Hasher;Defined in: cashconnect-js/packages/core/src/primitives/hasher.ts:29
Creates a Hash instance from a byte array.
Parameters
| Parameter | Type | Description |
|---|---|---|
bytes | Uint8Array | The byte array to create the hash from |
Returns
A new Hash instance containing the provided bytes
fromBase64()
static fromBase64(base64): Hasher;Defined in: cashconnect-js/packages/core/src/primitives/hasher.ts:39
Creates a Hash instance from a Base64 string.
Parameters
| Parameter | Type | Description |
|---|---|---|
base64 | string | The Base64 string to create the hash from |
Returns
A new Hash instance containing the bytes converted from the Base64 string
Throws
If the provided string is not valid Base64
fromHex()
static fromHex(hex): Hasher;Defined in: cashconnect-js/packages/core/src/primitives/hasher.ts:54
Creates a Hash instance from a hexadecimal string.
Parameters
| Parameter | Type | Description |
|---|---|---|
hex | string | The hexadecimal string to create the hash from |
Returns
A new Hash instance containing the bytes converted from the hex string
Throws
If the provided string is not valid hexadecimal
fromUTF8()
static fromUTF8(utf8): Hasher;Defined in: cashconnect-js/packages/core/src/primitives/hasher.ts:68
Creates a Hash instance from a UTF-8 string.
Parameters
| Parameter | Type | Description |
|---|---|---|
utf8 | string | The UTF-8 string to create the hash from |
Returns
A new Hash instance containing the bytes converted from the UTF-8 string
toSHA256Bytes()
toSHA256Bytes(): Uint8Array;Defined in: cashconnect-js/packages/core/src/primitives/hasher.ts:76
Computes the SHA256 hash of the stored bytes.
Returns
Uint8Array
A Uint8Array containing the SHA256 hash
toSHA256Hex()
toSHA256Hex(): string;Defined in: cashconnect-js/packages/core/src/primitives/hasher.ts:84
Computes the SHA256 hash of the stored bytes and returns it as a hexadecimal string.
Returns
string
The SHA256 hash as a hexadecimal string
toRIPEMD160Bytes()
toRIPEMD160Bytes(): Uint8Array;Defined in: cashconnect-js/packages/core/src/primitives/hasher.ts:92
Computes the RIPEMD160 hash of the stored bytes.
Returns
Uint8Array
A Uint8Array containing the RIPEMD160 hash
toRIPEMD160Hex()
toRIPEMD160Hex(): string;Defined in: cashconnect-js/packages/core/src/primitives/hasher.ts:100
Computes the RIPEMD160 hash of the stored bytes and returns it as a hexadecimal string.
Returns
string
The RIPEMD160 hash as a hexadecimal string
toHash160Bytes()
toHash160Bytes(): Uint8Array;Defined in: cashconnect-js/packages/core/src/primitives/hasher.ts:109
Computes the Hash160 (RIPEMD160(SHA256(x))) of the stored bytes. This is commonly used in cryptocurrency addresses.
Returns
Uint8Array
A Uint8Array containing the Hash160 value
toHash160Hex()
toHash160Hex(): string;Defined in: cashconnect-js/packages/core/src/primitives/hasher.ts:117
Computes the Hash160 (RIPEMD160(SHA256(x))) of the stored bytes and returns it as a hexadecimal string.
Returns
string
The Hash160 value as a hexadecimal string
toHash256Bytes()
toHash256Bytes(): Uint8Array;Defined in: cashconnect-js/packages/core/src/primitives/hasher.ts:126
Computes the Hash256 (SHA256(SHA256(x))) of the stored bytes. This is commonly used for computing block hashes in Bitcoin.
Returns
Uint8Array
A Uint8Array containing the Hash256 value
toHash256Hex()
toHash256Hex(): string;Defined in: cashconnect-js/packages/core/src/primitives/hasher.ts:134
Computes the Hash256 (SHA256(SHA256(x))) of the stored bytes and returns it as a hexadecimal string.
Returns
string
The Hash256 value as a hexadecimal string
Properties
| Property | Modifier | Type | Description | Defined in |
|---|---|---|---|---|
bytes | public | Uint8Array | The byte array representation of the data to be hashed | cashconnect-js/packages/core/src/primitives/hasher.ts:22 |