near-sdk-gr

Math.HashAlgorithm

enum HashAlgorithm {
  SHA256,
  KECCAK256,
  KECCAK512,
  RIPEMD160,
}

Math.hashBytes

hashBytes : (HashAlgorithm, Bytes) -> Bytes

Hashes the given byte sequence using the given hash algorithm. This function will overwrite the contents of register 0.

Parameters:

param type description
alg HashAlgorithm The hashing algorithm to use
value Bytes The value to hash

Returns:

type description
Bytes The hash

Examples:

Math.hashBytes(Math.SHA256, data)

Math.hashString

hashString : (HashAlgorithm, String) -> Bytes

Hashes the given string using the given hash algorithm. This function will overwrite the contents of register 0.

Parameters:

param type description
alg HashAlgorithm The hashing algorithm to use
value String The value to hash

Returns:

type description
Bytes The hash

Examples:

Math.hashString(Math.SHA256, data)