Whirlpool hashing in pawn compared to PHP
#1

I have an user control panel where you register your character. However, there's a small difference between the two hashing methods in the two languages, or well it seems like there is. Because when I use PAWN to hash with Whirlpool, everything is capitalized. But in PHP, it is not. So when I try to compare them two in order for the user to login, it's not "the right password" because one of the hashed password is capatilized, and the other one is not.

PAWN: THISISANEXAMPLE
PHP: thisisanexample

So how am I supposed to confirm that the password is right.. when they're hashed in a different way? Right now I am using strcmp to compare the two passwords.. not working so I have to manually capitalize the hashed password in order for it to work.
Reply
#2

A hashing algorithm is universal. Its output is always a predetermined number of bits, which is often represented in hexadecimal notation. In hexadecimal f is the same as F and both mean 15 in decimal. Use strtoupper() or strtolower().
Reply
#3

Quote:
Originally Posted by Vince
Посмотреть сообщение
A hashing algorithm is universal. Its output is always a predetermined number of bits, which is often represented in hexadecimal notation. In hexadecimal f is the same as F and both mean 15 in decimal. Use strtoupper() or strtolower().
So is this going to work?

Код:
$password = hash('whirlpool', (strtoupper($_POST['password']));
Hope that doesn't make any conflict with PDO?
Reply
#4

No. Make the output of the hash uppercase, not the password itself.
Reply
#5

Quote:
Originally Posted by Vince
Посмотреть сообщение
No. Make the output of the hash uppercase, not the password itself.
Uh alright? But does strtoupper work with pawn though?

As this did not work out well:
if(!strcmp(strtoupper(hashpass), charData[playerid][characterpass]))

Do I need to make a stock function or something?
Reply
#6

The implementation of Whirlpool in the plugin outputs the result in uppercase and as such it is probably already stored in uppercase in the database. The PHP implementation of Whirlpool outputs the result in lowercase so that result needs to be made uppercase to be matched against what is already stored.

tl;dr: only the PHP output needs to be made uppercase.
Reply
#7

Quote:
Originally Posted by Vince
Посмотреть сообщение
The implementation of Whirlpool in the plugin outputs the result in uppercase and as such it is probably already stored in uppercase in the database. The PHP implementation of Whirlpool outputs the result in lowercase so that result needs to be made uppercase to be matched against what is already stored.

tl;dr: only the PHP output needs to be made uppercase.
Alright.
To join the server you have to make an account on an UCP. That uses PHP and stores the password in lowercase, and it has to be in uppercase for them to join the server.

So this should do the job then?
Код:
$password = strtoupper(hash('whirlpool', $_POST['password']));
That code is being stored into the database.
Reply
#8

http://forum.sa-mp.com/showpost.php?...65&postcount=9
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)