Skip to content

Digest

Spice
import "std/crypto/digest";

Functions

rotateLeft32

Spice
public inline f<unsigned int> rotateLeft32(unsigned int value, int count)

Rotate a 32 bit word to the left.

The rotation count has to be in the range 1..31. Rotating by 0 or 32 would shift a word by its full width, which is undefined behavior.

Parameters

Name Type Description
value unsigned int Word to rotate
count int Number of bits to rotate by (1..31)

Returns: unsigned int — Rotated word

rotateRight32

Spice
public inline f<unsigned int> rotateRight32(unsigned int value, int count)

Rotate a 32 bit word to the right.

The rotation count has to be in the range 1..31. Rotating by 0 or 32 would shift a word by its full width, which is undefined behavior.

Parameters

Name Type Description
value unsigned int Word to rotate
count int Number of bits to rotate by (1..31)

Returns: unsigned int — Rotated word

rotateLeft64

Spice
public inline f<unsigned long> rotateLeft64(unsigned long value, int count)

Rotate a 64 bit word to the left.

The rotation count has to be in the range 1..63. Rotating by 0 or 64 would shift a word by its full width, which is undefined behavior.

Parameters

Name Type Description
value unsigned long Word to rotate
count int Number of bits to rotate by (1..63)

Returns: unsigned long — Rotated word

rotateRight64

Spice
public inline f<unsigned long> rotateRight64(unsigned long value, int count)

Rotate a 64 bit word to the right.

The rotation count has to be in the range 1..63. Rotating by 0 or 64 would shift a word by its full width, which is undefined behavior.

Parameters

Name Type Description
value unsigned long Word to rotate
count int Number of bits to rotate by (1..63)

Returns: unsigned long — Rotated word

toHexString

Spice
public f<String> toHexString(const byte[] digest, unsigned long length)

Render a raw digest as its lowercase hexadecimal representation, two chars per byte.

Parameters

Name Type Description
digest const byte[] Digest bytes to render
length unsigned long Number of digest bytes

Returns: String — Hex representation of the digest