Generate random readable strings for various purposes.
Project description
philiprehberger-randstr
Generate random readable strings for various purposes.
Installation
pip install philiprehberger-randstr
Usage
Random Strings
from philiprehberger_randstr import randstr
randstr(16) # "aBx4kLm9pQrS2tUv"
randstr(8, charset="lowercase") # "abcdefgh"
Tokens and Passwords
from philiprehberger_randstr import token, password
token(32) # URL-safe base64 token
password(16) # "aB3$kLm!9pQr#2tU"
Hex and Short IDs
from philiprehberger_randstr import hex_str, uuid_short
hex_str(16) # "a1b2c3d4e5f6a7b8"
uuid_short() # "7f3a8b2c"
Readable IDs
readable_id excludes visually-confusable characters (0, 1, O, o, I, l) — useful for vouchers, short references, and any human-typed code.
from philiprehberger_randstr import readable_id
readable_id(8) # e.g. "K7P4MNXR" — never contains 0/1/O/o/I/l
All generators use the secrets module for cryptographic security.
API
| Function / Class | Description |
|---|---|
randstr(length=16, charset="alphanumeric") |
Random string from a built-in or custom charset |
token(length=32) |
URL-safe base64-encoded token |
password(length=16, symbols, min_symbols, min_digits, min_upper) |
Strong password with guaranteed character-class diversity |
hex_str(length=16) |
Random lowercase hex string |
uuid_short(length=8) |
Short UUID-like hex ID |
readable_id(length=8) |
Random ID drawn from a visually-unambiguous alphabet |
Development
pip install -e .
python -m pytest tests/ -v
Support
If you find this project useful:
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file philiprehberger_randstr-0.2.0.tar.gz.
File metadata
- Download URL: philiprehberger_randstr-0.2.0.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d54bfbafe4112a4ccfd2f84b32b37ca6897af4659dbb8acb0ee22d28e443d998
|
|
| MD5 |
abcc19bfd1d3a378a69034fca3c12926
|
|
| BLAKE2b-256 |
b9e7abdd8d7e749f6b9f73ccd7112883960366961f23422688f1b071ab2be0c4
|
File details
Details for the file philiprehberger_randstr-0.2.0-py3-none-any.whl.
File metadata
- Download URL: philiprehberger_randstr-0.2.0-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d443ebf2b3700430903cef2730c0435799daf9f70b97ffd92081ccef7f349b9
|
|
| MD5 |
1efe6a81fc07aad09775411541b2cd4d
|
|
| BLAKE2b-256 |
2f0b969d6fe0e52a638602ced32a7f389bea7e5ba9b0593ba2ba49b420a97282
|