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
Numeric PINs
from philiprehberger_randstr import pin
pin() # e.g. "478392" — 6-digit default
pin(4) # e.g. "2057"
URL-safe slugs
slug draws from the lowercase visually-unambiguous alphanumeric charset (excludes 0, 1, l, o) — ideal for short shareable URLs.
from philiprehberger_randstr import slug
slug() # e.g. "k7p4mnxr"
slug(12) # e.g. "h3jq8mt2nrpw"
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 |
pin(length=6) |
Cryptographically-strong numeric PIN of digits |
slug(length=8) |
Short URL-safe slug from the lowercase visually-unambiguous charset |
Development
pip install -e .
python -m pytest tests/ -v
Support
If you find this project useful:
License
Release files for philiprehberger-randstr 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| philiprehberger_randstr-0.3.0.tar.gz | 182.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| philiprehberger_randstr-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 187.9 kB
Release files / philiprehberger_randstr-0.3.0.tar.gz
| Download URL | philiprehberger_randstr-0.3.0.tar.gz |
|---|---|
| Size | 182.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
086e20aac03cef4b3a165b547050f067ef74204530cf6017b4e3d897e2c09f6a
|
|
BLAKE2b-256 checksum How to use checksums |
c7a3ab243cd11c66d9f25ee5b5950430c0a0dec67d27498220bf44611f2b7d84
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|
Release files / philiprehberger_randstr-0.3.0-py3-none-any.whl
| Download URL | philiprehberger_randstr-0.3.0-py3-none-any.whl |
|---|---|
| Size | 5.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
236fb21ef2b704d60c82c9c5bceda5a5aa548740037b9c6a81c90bb0904fd4c4
|
|
BLAKE2b-256 checksum How to use checksums |
5add3655d66e158f71fbaeef2d08e5d530b9c5a85b66210fb76a85b3b0067712
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|