object

# `hash_common_32`

Auxiliary predicates for the hashes library 32-bit algorithms.

Availability:
`logtalk_load(hashes(loader))`
Author: Paulo Moura
Version: 1:3:0
Date: 2026-07-22
Compilation flags:
`static, context_switching_calls`
Uses:
list
Remarks:
(none)
Inherited public predicates:
(none)

## Public predicates

### `word32_hex/2`

Converts a 32-bit word into an 8-digit lowercase hexadecimal atom.

Compilation flags:
`static`
Template:
`word32_hex(Word,Hex)`
Mode and number of proofs:
`word32_hex(+integer,-atom)` - `one`

### `bytes_hex/2`

Converts a list of bytes into a lowercase hexadecimal atom.

Compilation flags:
`static`
Template:
`bytes_hex(Bytes,Hex)`
Mode and number of proofs:
`bytes_hex(+list(integer),-atom)` - `one`

### `mask32/1`

Returns the 32-bit mask value.

Compilation flags:
`static`
Template:
`mask32(Mask)`
Mode and number of proofs:
`mask32(-integer)` - `one`

### `add32/3`

Adds two integers modulo 2^32.

Compilation flags:
`static`
Template:
`add32(A,B,Sum)`
Mode and number of proofs:
`add32(+integer,+integer,-integer)` - `one`

### `add32/4`

Adds three integers modulo 2^32.

Compilation flags:
`static`
Template:
`add32(A,B,C,Sum)`
Mode and number of proofs:
`add32(+integer,+integer,+integer,-integer)` - `one`

### `add32/5`

Adds four integers modulo 2^32.

Compilation flags:
`static`
Template:
`add32(A,B,C,D,Sum)`
Mode and number of proofs:
`add32(+integer,+integer,+integer,+integer,-integer)` - `one`

### `mul32/3`

Multiplies two integers modulo 2^32. Computed via 16-bit limb decomposition so that no intermediate result exceeds about 2**49, avoiding integer overflow errors on backends with bounded integer arithmetic.

Compilation flags:
`static`
Template:
`mul32(A,B,Product)`
Mode and number of proofs:
`mul32(+integer,+integer,-integer)` - `one`

### `rol32/3`

Rotates a 32-bit word left by the given number of bits.

Compilation flags:
`static`
Template:
`rol32(Value,Shift,Rotated)`
Mode and number of proofs:
`rol32(+integer,+integer,-integer)` - `one`

### `ror32/3`

Rotates a 32-bit word right by the given number of bits.

Compilation flags:
`static`
Template:
`ror32(Value,Shift,Rotated)`
Mode and number of proofs:
`ror32(+integer,+integer,-integer)` - `one`

### `little_endian_word32/2`

Decodes four bytes in little-endian order into a 32-bit word.

Compilation flags:
`static`
Template:
`little_endian_word32(Bytes,Word)`
Mode and number of proofs:
`little_endian_word32(+list(integer),-integer)` - `one`

### `big_endian_word32/2`

Decodes four bytes in big-endian order into a 32-bit word.

Compilation flags:
`static`
Template:
`big_endian_word32(Bytes,Word)`
Mode and number of proofs:
`big_endian_word32(+list(integer),-integer)` - `one`

### `integer_to_little_endian_bytes32/3`

Encodes a 32-bit word into four bytes in little-endian order.

Compilation flags:
`static`
Template:
`integer_to_little_endian_bytes32(Integer,Bytes,Tail)`
Mode and number of proofs:
`integer_to_little_endian_bytes32(+integer,-list(integer),-variable)` - `one`

### `integer_to_little_endian_bytes32/2`

Encodes a 32-bit word into four bytes in little-endian order.

Compilation flags:
`static`
Template:
`integer_to_little_endian_bytes32(Integer,Bytes)`
Mode and number of proofs:
`integer_to_little_endian_bytes32(+integer,-list(integer))` - `one`

### `integer_to_big_endian_bytes32/3`

Encodes a 32-bit word into four bytes in big-endian order.

Compilation flags:
`static`
Template:
`integer_to_big_endian_bytes32(Integer,Bytes,Tail)`
Mode and number of proofs:
`integer_to_big_endian_bytes32(+integer,-list(integer),-variable)` - `one`

### `integer_to_big_endian_bytes32/2`

Encodes a 32-bit word into four bytes in big-endian order.

Compilation flags:
`static`
Template:
`integer_to_big_endian_bytes32(Integer,Bytes)`
Mode and number of proofs:
`integer_to_big_endian_bytes32(+integer,-list(integer))` - `one`

### `pad_md/4`

Pads a message using MD-style padding with a little-endian or big-endian length field.

Compilation flags:
`static`
Template:
`pad_md(Endian,Bytes,LengthFieldBytes,PaddedBytes)`
Mode and number of proofs:
`pad_md(+little_big,+list(integer),+integer,-list(integer))` - `one`

### `pad_md_tail/5`

Pads the final, less-than-one-block tail of a message using MD-style padding given the total message length in bytes. For use when the message has already been consumed block by block during segmented/incremental hashing, so that only the unconsumed tail, and not the whole message, needs to be available.

Compilation flags:
`static`
Template:
`pad_md_tail(Endian,TailBytes,TotalLength,LengthFieldBytes,PaddedBytes)`
Mode and number of proofs:
`pad_md_tail(+little_big,+list(integer),+integer,+integer,-list(integer))` - `one`

## Protected predicates

(no local declarations; see entity ancestors if any)

## Private predicates

(no local declarations; see entity ancestors if any)

## Operators

(none)