ETkObject.py 880 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. """
  4. @Copyright (C) ansjer cop Video Technology Co.,Ltd.All rights reserved.
  5. @AUTHOR: ASJRD018
  6. @NAME: AnsjerFormal
  7. @software: PyCharm
  8. @DATE: 2019/6/1 17:25
  9. @Version: python3.6
  10. @MODIFY DECORD:ansjer dev
  11. @file: ETkObject.py
  12. @Contact: chanjunkai@163.com
  13. """
  14. import base64
  15. import urllib.parse
  16. class ETkObject(object):
  17. def __init__(self, etk):
  18. self.uid = ''
  19. self.parseUid(etk)
  20. def parseUid(self, etk):
  21. try:
  22. c = base64.b64decode(etk)
  23. c = c[2:-2]
  24. c = urllib.parse.unquote(c.decode('utf-8'))
  25. c = base64.b64decode(c)
  26. uid = c.decode('utf-8')
  27. if len(uid) == 20:
  28. self.uid = uid
  29. except Exception as e:
  30. print(repr(e))
  31. eto = ETkObject('R19XRFZZVGpZMU5VUkRXVE5NVUZsWE1qRXhNVUU9ViY=')
  32. print(eto.uid)