Skip to content

Instantly share code, notes, and snippets.

@carlohamalainen
Created May 6, 2013 03:40
Show Gist options
  • Save carlohamalainen/5523233 to your computer and use it in GitHub Desktop.
Save carlohamalainen/5523233 to your computer and use it in GitHub Desktop.
Create a Joomla password hash/salt entry using Python
import getpass
import hashlib
import random
import string
password = getpass.getpass('password (not echoed): ')
salt = ''.join(random.choice(string.ascii_lowercase + string.ascii_uppercase + string.digits) for x in range(32))
password_hash = hashlib.md5(password + salt).hexdigest()
print "update CHANGEME_users set password='" + password_hash + ':' + salt + "' where id = ...;"
@progressify
Copy link

It's still working in 2021 with python 3.8.8
This is the only edit that I have made:

password_hash = hashlib.md5(f'{password}{salt}'.encode('utf-8')).hexdigest()

Thank you :)

@carlohamalainen
Copy link
Author

Happy to help 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment