Pseudo-random number generator

## Functions

xmpp_rand_t * | xmpp_rand_new (xmpp_ctx_t *ctx)
| Create new xmpp_rand_t object.
void | xmpp_rand_free (xmpp_ctx_t *ctx, xmpp_rand_t *rand)
| Destroy an xmpp_rand_t object.
int | xmpp_rand (xmpp_rand_t *rand)
| Generate random integer.
void | xmpp_rand_bytes (xmpp_rand_t *rand, unsigned char *output, size_t len)
| Generate random bytes.
void | xmpp_rand_nonce (xmpp_rand_t *rand, char *output, size_t len)
| Generate a nonce that is printable randomized string.

## Detailed Description

## Function Documentation

## xmpp_rand_new()

xmpp_rand_t * xmpp_rand_new | ( | xmpp_ctx_t * | ctx | ) |

Create new xmpp_rand_t object.

Parameters

  ctx | A Strophe context object

## xmpp_rand_free()

void xmpp_rand_free | ( | xmpp_ctx_t * | ctx,
|  | xmpp_rand_t * | rand
| ) |  |

Destroy an xmpp_rand_t object.

Parameters

  ctx | A Strophe context object
  rand | A xmpp_rand_t object

## xmpp_rand()

int xmpp_rand | ( | xmpp_rand_t * | rand | ) |

Generate random integer.

Analogue of rand(3).

## xmpp_rand_bytes()

void xmpp_rand_bytes | ( | xmpp_rand_t * | rand,
|  | unsigned char * | output,
|  | size_t | len
| ) |  |

Generate random bytes.

Generates len bytes and stores them to the output buffer.

Parameters

  rand | A xmpp_rand_t object
  output | A buffer where a len random bytes will be placed.
  len | Number of bytes reserved for the output..

## xmpp_rand_nonce()

void xmpp_rand_nonce | ( | xmpp_rand_t * | rand,
|  | char * | output,
|  | size_t | len
| ) |  |

Generate a nonce that is printable randomized string.

This function doesn't allocate memory and doesn't fail.

Parameters

  rand | A xmpp_rand_t object
  output | A buffer where a NULL-terminated string will be placed. The string will contain len-1 printable symbols.
  len | Number of bytes reserved for the output string, including end of line '\0'.