# `./fio-stl/002 random.h`

15 public symbols.

### Macros

#### `FIO_USE_STABLE_HASH_WHEN_CALLING_RISKY_HASH`

```c
#define FIO_USE_STABLE_HASH_WHEN_CALLING_RISKY_HASH 0
```



_Symbol type:_ `macro`

### Functions

#### `fio_rand64`

```c
uint64_t fio_rand64(void)
```

Returns 64 psedo-random bits. Probably not cryptographically safe.

_Symbol type:_ `function`

#### `fio_rand128`

```c
fio_u128 fio_rand128(void)
```

Returns 64 psedo-random bits. Probably not cryptographically safe.

_Symbol type:_ `function`

#### `fio_rand_bytes`

```c
void fio_rand_bytes(void *target, size_t len)
```

Writes `len` bytes of psedo-random bits to the target buffer.

_Symbol type:_ `function`

#### `fio_rand_bytes_secure`

```c
int fio_rand_bytes_secure(void *target, size_t len)
```

Writes `len` bytes of cryptographically secure random data to `target`.

Uses system CSPRNG: getrandom() on Linux, arc4random_buf() on BSD/macOS,
or /dev/urandom as fallback. Returns 0 on success, -1 on failure.

IMPORTANT: Use this for security-sensitive operations like key generation.

_Symbol type:_ `function`

#### `fio_rand_reseed`

```c
void fio_rand_reseed(void)
```

Reseeds the random engine using system state (rusage / jitter).

_Symbol type:_ `function`

#### `fio_risky_hash`

```c
uint64_t fio_risky_hash(const void *buf, size_t len, uint64_t seed)
```

Computes a facil.io Risky Hash (Risky v.3).

_Symbol type:_ `function`

#### `fio_risky_ptr`

```c
inline uint64_t fio_risky_ptr(void *ptr)
```

Adds a bit of entropy to pointer values. Designed to be unsafe.

_Symbol type:_ `function`

#### `fio_risky_num`

```c
inline uint64_t fio_risky_num(uint64_t number, uint64_t seed)
```

Adds a bit of entropy to numeral values. Designed to be unsafe.

_Symbol type:_ `function`

#### `fio_stable_hash`

```c
uint64_t fio_stable_hash(const void *data, size_t len, uint64_t seed)
```

Computes a facil.io Stable Hash (will not be updated, even if broken).

_Symbol type:_ `function`

#### `fio_stable_hash128`

```c
void fio_stable_hash128(void *restrict dest, const void *restrict data, size_t len, uint64_t seed)
```

Computes a facil.io Stable Hash (will not be updated, even if broken).

_Symbol type:_ `function`

#### `fio_risky256`

```c
fio_u256 fio_risky256(const void *data, uint64_t len)
```

Computes a 256-bit non-cryptographic hash (RiskyHash 256).

Based on the A3 (Zero-Copy ILP) design: 2-state multiply-fold with
cross-lane mixing, 128 bytes/iteration, zero-copy XOR from input.

Returns a `fio_u256` (32 bytes). Passes strict avalanche (50.0%),
collision, differential, and length independence tests.

_Symbol type:_ `function`

#### `fio_risky512`

```c
fio_u512 fio_risky512(const void *data, uint64_t len)
```

Computes a 512-bit non-cryptographic hash (RiskyHash 512).

SHAKE-style extension of fio_risky256: the first 256 bits of the 512-bit
output are identical to fio_risky256 (truncation-safe). The second 256 bits
come from an additional squeeze round.

Returns a `fio_u512` (64 bytes).

_Symbol type:_ `function`

#### `fio_risky256_hmac`

```c
fio_u256 fio_risky256_hmac(const void *key, uint64_t key_len, const void *msg, uint64_t msg_len)
```

Computes HMAC-RiskyHash-256 (RFC 2104 construction, 32-byte digest).

Uses fio_risky256 as the underlying hash with a 64-byte block size.
If `key_len > 64`, the key is hashed first with fio_risky256.

NOTE: The underlying hash is non-cryptographic, so standard HMAC
security proofs do not apply. For cryptographic HMAC, use blake2.

_Symbol type:_ `function`

#### `fio_risky512_hmac`

```c
fio_u512 fio_risky512_hmac(const void *key, uint64_t key_len, const void *msg, uint64_t msg_len)
```

Computes HMAC-RiskyHash-512 (RFC 2104 construction, 64-byte digest).

Uses fio_risky512 as the underlying hash with a 64-byte block size.
If `key_len > 64`, the key is hashed first with fio_risky512.

NOTE: The underlying hash is non-cryptographic, so standard HMAC
security proofs do not apply. For cryptographic HMAC, use blake2.

_Symbol type:_ `function`

-----------------------------------------------------
