Collection of functions to randomly and securely generate commonly used IDs.
Project description
User-friendly ID
Collection of functions to randomly and securely generate commonly-used types of IDs.
Installation
Install from PyPI:
pip install user-friendly-id
Features
- Generate any length of random string, either cryptographically secure (slower) or not (faster)
- Generate IDs without without common confusables / homoglyphs (e.g lowercase "l" vs uppercase "i")
- Lowers chances of a curse word randomly appearing in IDs using same logic as Hashids library.
How to use?
from ufid import (
generate_random_string,
generate_random_lowercase_string,
generate_random_digit_string,
generate_base64_random_string,
generate_base47_random_string,
generate_user_friendly_id,
)
# Generate securely a random string of 10 characters of
# any lowercase/uppercase alphabet + digits
generate_random_string(length=10, secure=True)
# Generate a random string of 10 characters within a set of predefined chars
generate_random_string(length=10, allowed_chars='01')
# Shortcut of the above to only allow lowercase alphabet
generate_random_lowercase_string(length=10)
# Again, shortcut to get only digits
generate_random_digit_string(length=10)
# Generate youtube-like base64 random string
generate_base64_random_string(length=10)
# Generate a random string without common confusables / homoglyphs.
# To maximize number of combination allowed_chars is not settable.
# This gives a base47 string hence the name of the function
generate_base47_random_string(length=10)
# Generate a 'true' user-friendly ID. Opiniated to a secure settings, and default of
# 6 chars for about 10 billion combinations. Also excludes without confusables / homoglyphs
# but also adds an algorithm inspired by the popular Hashids library to lower chances of
# generating curse words
generate_user_friendly_id()
generate_user_friendly_id(length=10)
Tests
TODO
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
File details
Details for the file user-friendly-id-1.0.0.tar.gz.
File metadata
- Download URL: user-friendly-id-1.0.0.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.7.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d9c5dd79dffebc6dfbb6eb2178e37617d048e86128ceb952365ffe19f03e75a7
|
|
| MD5 |
5986e0b82bd3c11cd461e009678c372e
|
|
| BLAKE2b-256 |
eb04898afc7b5819ba490b7af0ca10d7676b7e66318f0851f7630c3f7239118f
|