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.

15 lines
336 B

6 years ago
  1. import string
  2. import random
  3. import hashlib
  4. def md5(s):
  5. return hashlib.md5(s.encode()).hexdigest()
  6. def find_by_id(iterable, _id):
  7. for i in iterable:
  8. if i['id'] == _id:
  9. return i
  10. return None
  11. def generate_id(length=32):
  12. return ''.join(random.choices(string.ascii_lowercase + string.digits, k=length))