hash_1_1.py 366 B

123456789101112
  1. def mysql_passwd(password, uppercase=True):
  2. """
  3. Reference(s):
  4. http://csl.sublevel3.org/mysql-password-function/
  5. >>> mysql_passwd(password='testpass', uppercase=True)
  6. '*00E247AC5F9AF26AE0194B41E1E769DEE1429A29'
  7. """
  8. retVal = "*%s" % sha1(sha1(password).digest()).hexdigest()
  9. return retVal.upper() if uppercase else retVal.lower()