Skip to main content

random-strings

Generate strings that are ✨ random ✨

how to install

$ pip install random-strings

how to use

>>> from random_strings import random_string
>>> random_string(5)
'YSuz5'

advanced usage

from random_strings import random_hex, random_string

password = random_string(16)
SECRET_KEY = random_string(64)

# hexadecimal characters
SECURE_TOKEN = random_hex(128)

# no uppercase letters
verification_code = random_string(12,upper=False)
# only uppercase letters
verification_code = random_string(12,lower=False,digit=False)

# custom characters
characters = '23456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
verification_code = random_string(12,character_string=characters)

more examples

>>> from random_strings import *

>>> random_hex(16)
'ec583ef0aaa226cba9cb07e3dc2e623c'

>>> random_uuid()
'85273146-3ad8-489f-9964-e7af16ab6a26'

>>> random_uuid(dashes=False)
'a33ee36ad08242e4a2a819147f084a51'

more details

Generated strings are suitable for cryptographically secure usecase

See os.urandom, random.SystemRandom and PEP 506 for more details on how it works.

also, this package is named random-strings. There are other packages on pypi with similar names but they don't do the same thing.

Metadata

Release files for random-strings 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for random-strings 0.2.0
File Size Uploaded
random_strings-0.2.0.tar.gz 3.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for random-strings 0.2.0
File Interpreter ABI Platform
random_strings-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 7.7 kB

Release files / random_strings-0.2.0.tar.gz

Download URL random_strings-0.2.0.tar.gz
Size 3.8 kB
Tags Source
SHA-256 checksum
How to use checksums
aadc0a002d8107e6e247e8d1adc08371bf8f2719351d5b0cb6f0f5dc6ada2ba9
BLAKE2b-256 checksum
How to use checksums
a349aabbab3370638a1545425eb53d72997b631aceae8cdcda76bdd6a105443a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / random_strings-0.2.0-py3-none-any.whl

Download URL random_strings-0.2.0-py3-none-any.whl
Size 3.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ad6810a83442a7297215272a9c8c8f083d4c7226bfdb718ea8639a3ec77e3c88
BLAKE2b-256 checksum
How to use checksums
02bc622ebad90ce9f409b1bcbbbd0cd8653f0799226a235d640829beae13e9fd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page