HashCode

Methods
8
Fields
None

Getting one

HashCode.fromString(…)
HashCode.fromInt(…)
HashCode.fromBytes(…)

Methods

MethodReturnsDescription
toString()stringThe bytes in lower-case hex, two digits each, in order.
bits()numberHow many bits the hash has (8 per byte).
asInt()numberThe first four bytes as an int, little-endian; fewer than four is IllegalStateException.
equals(any)booleanWhether other equals this HashCode, as == answers it (false for a value of another class).
asBytes()stringThe hash's bytes, as a Luau string (any bytes).
fromString(string)HashCodeThe hash string spells in lower-case hex (Guava refuses upper case): fewer than two characters, an odd count or another character is `Ill…
fromInt(number)HashCodeA 32-bit hash: hash's four bytes, little-endian.
fromBytes(string | {number})HashCodeA hash of bytes (a Luau string, or an array of byte numbers), copied; none at all is IllegalArgumentException.

Returned by

MethodReturnsDescription
HashCodeClass.fromBytesHashCodeA hash of bytes (a Luau string, or an array of byte numbers), copied; none at all is IllegalArgumentException.
HashCodeClass.fromIntHashCodeA 32-bit hash: hash's four bytes, little-endian.
HashCodeClass.fromStringHashCodeThe hash string spells in lower-case hex (Guava refuses upper case): fewer than two characters, an odd count or another character is `Ill…
Hasher.hashHashCodeThe hash of everything fed. Once: a second hash(), or a put after it, is IllegalStateException.
HashFunction.hashBytesHashCode(HashFunction, string | {number}) -> HashCode: The hash of input's bytes (a Luau string of them, or an array of byte numbers): `Hashing…
HashFunction.hashIntHashCodeThe hash of input's four bytes, little-endian.
HashFunction.hashLongHashCodeThe hash of input's eight bytes, little-endian (exact below 2^53, as every Luau number is).
HashFunction.hashStringHashCodeThe hash of input's bytes in charset (input.getBytes(charset)).
HashFunction.hashUnencodedCharsHashCodeThe hash of input's UTF-16 code units, each little-endian (no charset).

Method details

toString

toString: (HashCode) -> string

The bytes in lower-case hex, two digits each, in order.

bits

bits: (HashCode) -> number

How many bits the hash has (8 per byte).

asInt

asInt: (HashCode) -> number

The first four bytes as an int, little-endian; fewer than four is IllegalStateException.

equals

equals: (HashCode, any) -> boolean

Whether other equals this HashCode, as == answers it (false for a value of another class).

asBytes

asBytes: (HashCode) -> string

The hash's bytes, as a Luau string (any bytes).

fromString

fromString: (string) -> HashCode

The hash string spells in lower-case hex (Guava refuses upper case): fewer than two characters, an odd count or another character is IllegalArgumentException.

fromInt

fromInt: (number) -> HashCode

A 32-bit hash: hash's four bytes, little-endian.

fromBytes

fromBytes: (string | {number}) -> HashCode

A hash of bytes (a Luau string, or an array of byte numbers), copied; none at all is IllegalArgumentException.