hash_1_3.py 605 B

12345678910111213141516171819
  1. def postgres_passwd(password, username, uppercase=False):
  2. """
  3. Reference(s):
  4. http://pentestmonkey.net/blog/cracking-postgres-hashes/
  5. >>> postgres_passwd(password='testpass', username='testuser', uppercase=False)
  6. 'md599e5ea7a6f7c3269995cba3927fd0093'
  7. """
  8. if isinstance(username, unicode):
  9. username = unicode.encode(username, UNICODE_ENCODING)
  10. if isinstance(password, unicode):
  11. password = unicode.encode(password, UNICODE_ENCODING)
  12. retVal = "md5%s" % md5(password + username).hexdigest()
  13. return retVal.upper() if uppercase else retVal.lower()