Strings and bytes
ixia.passphrase
def passphrase(
n: int,
*,
sep: str = "-",
words_path: PathLike[str] | str = "/usr/share/dict/words",
) -> str
Generates an XKCD-style passphrase made up of n
words
(based on the file specified by words_path
), separated by sep
(-
by
default).
⚠️ The default word list is not available on Windows.
ixia.rand_alnum
Returns a random alphanumeric (A–Z, a–z, 0–9) string of length n
.
ixia.rand_bytes
Generates n
random bytes. Defaults to 32.
ixia.rand_hex
Returns a hex string composed of n
random bytes.
ixia.rand_line
def rand_line(file: TextIOBase | PathLike[str] | str) -> str
def rand_line(file: BufferedIOBase) -> bytes
Returns a random line from a file. Given a string or a path-like object, assumes
it is a path, reads it, and returns a random line from the read content. Given a
readable IO object, reads it, and returns a random line from the read content.
Returns a bytes
object if provided an IO object in binary mode.
ixia.rand_printable
Returns a random printable ASCII (range 32–126) string of length n
.
ixia.rand_urlsafe
Returns a random URL-safe text string, composed of n
bytes, in Base64
encoding. Defaults to 32.