apikey.py 519 B

1234567891011121314151617181920212223242526272829
  1. import os
  2. class apikey_generator:
  3. """
  4. This is ApiKey generator.
  5. """
  6. def __new__(cls) -> str:
  7. """
  8. It create new ApiKey, and return it as string.
  9. Returns:
  10. (str): New random ApiKey
  11. """
  12. random = os.urandom(cls.size())
  13. string = random.hex()
  14. return string
  15. def size() -> int:
  16. """
  17. It return size of ApiKey in bytes.
  18. Returns:
  19. (int): Size of ApiKey in bytes
  20. """
  21. return 128