Skip to content

Instantly share code, notes, and snippets.

@ckruse
Created June 21, 2018 08:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ckruse/3a658d0270b01b89288d731ca9a6f3c5 to your computer and use it in GitHub Desktop.
Save ckruse/3a658d0270b01b89288d731ca9a6f3c5 to your computer and use it in GitHub Desktop.
import hashlib
import random
class FilterModule(object):
def salt(self):
ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
chars=[]
for i in range(16):
chars.append(random.choice(ALPHABET))
return "".join(chars)
def setup_password(self, password):
md5 = hashlib.md5()
sha1 = hashlib.sha1()
md5.update(self.salt())
salt = md5.hexdigest()
sha1.update(salt + ":" + password)
return salt + ":" + sha1.hexdigest()
def filters(self):
return {
'setup_password': self.setup_password
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment