Skip to content

Instantly share code, notes, and snippets.

@faelp22
Created March 31, 2018 20:56
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 faelp22/105a4083166e8365b1a9f21058d90b97 to your computer and use it in GitHub Desktop.
Save faelp22/105a4083166e8365b1a9f21058d90b97 to your computer and use it in GitHub Desktop.
OpenCart 2.0+ password algorithm
import random
import string
import hashlib
"""
This is a simple script to generate passwords for Ecommerce OpenCart version 2+
tested up to version 3.0.2.0.
Use: Python 3
Author: Isael Sousa <faelp22@gmail.com>
Date: 31/03/2018
"""
def token(size=32):
"""
Returns a string of random digits
"""
pool = string.ascii_letters + string.digits
return ''.join(random.choice(pool) for i in range(size))
def sha1(value):
"""
Returns a string sha1 algorithm
"""
return hashlib.sha1(str(value).encode('utf-8')).hexdigest()
def opencart_passwd(salt, value):
"""
Returns an Opencart 2+ password
"""
return sha1(salt + sha1(salt + sha1(value)))
if __name__ == '__main__':
salt = token(9)
passwd = 'asdasd'
print(opencart_passwd(salt, passwd))
print(opencart_passwd('le3h5zZ2B', 'asdasd'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment