Jump to content
Sign in to follow this  
Driana

(SOLVED) Developers: How can I produce the sha_pass_hash?

Recommended Posts

I've taken to your public github to create my own copy of this realm, for educational purposes. Everything works great so far. 

Except, I can't login to it, because I don't know how to store the password hashes in the database. 

The first thing I tried was sha1("password"), which did not work. The next thing I tried was working-backwards using your authentication script. But that is too complicated for me, because I am not so good at cryptography. 

It seems you do have a sophisticated password hash. Could you explain to me how to produce it?

Share this post


Link to post
Share on other sites

@Josipbroz Great thank you. That works too. 

I just solved it:

The password hash is the SHA1 hash of your uppercase username, followed by a colon, followed by the uppercase password. When setting this, you must clear the 'v' and 's' values in the database entry. That was my issue... these values must be blanked upon updating the password. 

In short, the structure of the password hash is: 

SHA1(CONCAT(UPPER(`username`),':',UPPER('your new password')))

And an example MySQL query to change your password is:

UPDATE `account` SET `sha_pass_hash`=SHA1(CONCAT(UPPER(`username`),':',UPPER('your new password'))), `v`=0, `s`=0 WHERE `id` = 'your account id';

In the above query, only replace the words "your new password" and "your account id" ... because the username will be retrieved automatically via the user id. 

I hope this helps somebody in the future. 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×