# RNG Non-cryptographic

# RNG Non-cryptographic

This module includes functions that generates non cryptographic random numbers.

## Summary

| ### Functions ||
|---|---|
| `https://openthread.io/reference/group/api-random-non-crypto#group__api-random-non-crypto_1ga8383bd4c0a0baac30730f3d183418afd(uint32_t aValue, uint16_t aJitter)` | `uint32_t` Adds a random jitter within a given range to a given value. |
| `https://openthread.io/reference/group/api-random-non-crypto#group__api-random-non-crypto_1ga45cea877d98e6e594c2ad862b0950c76(uint8_t *aBuffer, uint16_t aSize)` | `void` Fills a given buffer with random bytes. |
| `https://openthread.io/reference/group/api-random-non-crypto#group__api-random-non-crypto_1ga3edd301ae3db721fcdd7d9aef5635c4b(void)` | `uint16_t` Generates and returns a random `uint16_t` value. |
| `https://openthread.io/reference/group/api-random-non-crypto#group__api-random-non-crypto_1gad3cf6ec86e495fdd58ec0411c5f454c3(uint16_t aMin, uint16_t aMax)` | `uint16_t` Generates and returns a random `uint16_t` value within a given range `[aMin, aMax)`. |
| `https://openthread.io/reference/group/api-random-non-crypto#group__api-random-non-crypto_1ga43a928e160c999a3a69173f0365bc9ea(void)` | `uint32_t` Generates and returns a random `uint32_t` value. |
| `https://openthread.io/reference/group/api-random-non-crypto#group__api-random-non-crypto_1gaedb8b654829bde30f93ee04567c43403(uint32_t aMin, uint32_t aMax)` | `uint32_t` Generates and returns a random `uint32_t` value within a given range `[aMin, aMax)`. |
| `https://openthread.io/reference/group/api-random-non-crypto#group__api-random-non-crypto_1ga42fdb1430d5dd237d1aab2b1986959ce(void)` | `uint8_t` Generates and returns a random byte. |
| `https://openthread.io/reference/group/api-random-non-crypto#group__api-random-non-crypto_1ga0b0ebe9d82a1fab8fa8bb9abb513e055(uint8_t aMin, uint8_t aMax)` | `uint8_t` Generates and returns a random `uint8_t` value within a given range `[aMin, aMax)`. |

## Functions

### otRandomNonCryptoAddJitter

```
uint32_t otRandomNonCryptoAddJitter(
  uint32_t aValue,
  uint16_t aJitter
)
```
Adds a random jitter within a given range to a given value.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aValue` | A value to which the random jitter is added. | | `[in] aJitter` | Maximum jitter. Random jitter is selected from the range `[-aJitter, aJitter]`. | |
| **Returns** | The given value with an added random jitter. |

### otRandomNonCryptoFillBuffer

```
void otRandomNonCryptoFillBuffer(
  uint8_t *aBuffer,
  uint16_t aSize
)
```
Fills a given buffer with random bytes.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[out] aBuffer` | A pointer to a buffer to fill with the random bytes. | | `[in] aSize` | Size of buffer (number of bytes to fill). | |

### otRandomNonCryptoGetUint16

```
uint16_t otRandomNonCryptoGetUint16(
  void
)
```
Generates and returns a random `uint16_t` value.

<br />

| Details ||
|---|---|
| **Returns** | A random `uint16_t` value. |

### otRandomNonCryptoGetUint16InRange

```
uint16_t otRandomNonCryptoGetUint16InRange(
  uint16_t aMin,
  uint16_t aMax
)
```
Generates and returns a random `uint16_t` value within a given range `[aMin, aMax)`.


> [!NOTE]
> **Note:** The returned random value can include the `aMin` value but excludes the `aMax`.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aMin` | A minimum value (this value can be included in returned random result). | | `[in] aMax` | A maximum value (this value is excluded from returned random result). | |
| **Returns** | A random `uint16_t` value in the given range (i.e., aMin \<= random value \< aMax). |

### otRandomNonCryptoGetUint32

```
uint32_t otRandomNonCryptoGetUint32(
  void
)
```
Generates and returns a random `uint32_t` value.

<br />

| Details ||
|---|---|
| **Returns** | A random `uint32_t` value. |

### otRandomNonCryptoGetUint32InRange

```
uint32_t otRandomNonCryptoGetUint32InRange(
  uint32_t aMin,
  uint32_t aMax
)
```
Generates and returns a random `uint32_t` value within a given range `[aMin, aMax)`.


> [!NOTE]
> **Note:** The returned random value can include the `aMin` value but excludes the `aMax`.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aMin` | A minimum value (this value can be included in returned random result). | | `[in] aMax` | A maximum value (this value is excluded from returned random result). | |
| **Returns** | A random `uint32_t` value in the given range (i.e., aMin \<= random value \< aMax). |

### otRandomNonCryptoGetUint8

```
uint8_t otRandomNonCryptoGetUint8(
  void
)
```
Generates and returns a random byte.

<br />

| Details ||
|---|---|
| **Returns** | A random `uint8_t` value. |

### otRandomNonCryptoGetUint8InRange

```
uint8_t otRandomNonCryptoGetUint8InRange(
  uint8_t aMin,
  uint8_t aMax
)
```
Generates and returns a random `uint8_t` value within a given range `[aMin, aMax)`.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aMin` | A minimum value (this value can be included in returned random result). | | `[in] aMax` | A maximum value (this value is excluded from returned random result). | |
| **Returns** | A random `uint8_t` value in the given range (i.e., aMin \<= random value \< aMax). |

## Resources

OpenThread API Reference topics originate from the source code, available
on [GitHub](https://github.com/openthread/openthread/tree/main/include/openthread).
For more information, or to contribute to our documentation, refer to
[Resources](https://openthread.io/resources).