API Reference

chbshash.random(n_words: int = 4, sep: str = ' ', *, rng: Random | None = None) str

Generate a random passphrase.

Parameters:
  • n_words – The number of words in the passphrase. Default is 4.

  • sep – The separator between words in the passphrase. Default is whitespace.

  • rng – External random number generator. Default is to generate non-deterministic passphrases.

chbshash.hash(x: Buffer | IO[bytes] | IO[str], /, n_words: int = 4, sep: str = ' ') str

Non-cryptographic hash of any bytes-like or file-like object.

Parameters:
  • x – The input data to hash. Can be any bytes-like object or file-like object.

  • n_words – The number of words in the passphrase. Default is 4.

  • sep – The separator between words in the passphrase. Default is whitespace.

chbshash.words() list[str]

Return the domain of used words.

chbshash.clear_cache() None

Clear the internal words cache (~30 MiB RAM).

The cache is loaded automatically on the first call to words(), random(), or hash().