Utils
getBytes
Convert string to bytes.
Parameters
string
string
Returns Array<number> The bytes from the given string.
ab2hexstring
Convert Buffer to hex string.
Parameters
arr
Buffer
Returns string The hex string from the given buffer.
sha256ripemd160
Calculate ripemd160(sha256(hex))
from the hex string
Parameters
-
hex
string The hex encoded string. - Throws
"sha256ripemd160 expects a string"
Thrown if non-string is provided. - Throws
"invalid hex string length"
Thrown if the given hex string is an invalid one.
Returns string The hex string from the given buffer.
encodeAddress
Encode address from the string or Buffer.
Parameters
value
(string | Buffer) The string or Buffer to be encoded.prefix
string The prefix of the address. (optional) (optional, default'thor'
)type
BufferEncoding The buffer encoding type. It will be used when string is provided. (optional) (optional, default'hex'
)
Returns string The address generated from the given string or buffer.
createAddress
Create address from the public key.
Parameters
publicKey
Buffer The public key in Buffer format.
Returns string The address generated from the given public key(buffer format).
pbkdf2Async
Calculate pbkdf2 (Password-Based Key Derivation Function 2).
Parameters
Returns Buffer The pbkdf2 value from the given options.