Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import hashlib
- import pickle
- import urllib
- import zlib
- _my_secret = "myawesomekey"
- def _encode_data(data):
- """
- Codify a Dictionary data into base64 string
- :param data: python dict
- :return: encoding hash, encoded data
- Usage
- hash, data = _encode_data({'email': 'myplain@email.com'})
- """
- text = zlib.compress(pickle.dumps(data, 0)).encode(
- 'base64').replace('\n', '')
- m = hashlib.md5(_my_secret + text).hexdigest()[:12]
- return m, text
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement