You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

14 lines
421 B

# -*- coding: utf-8 -*-
from random import SystemRandom
def random_token(length, byte_filter):
allowed_bytes = ''.join(c for c in map(chr, range(128)) if byte_filter(c))
random = SystemRandom()
return ''.join([random.choice(allowed_bytes) for _ in range(length)])
def alpha_numeric(length):
return random_token(length, str.isalnum)
def lower_case(length):
return random_token(length, str.islower)