SA-MP Forums Archive
SHA1 Password - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: SHA1 Password (/showthread.php?tid=613235)



SHA1 Password - Zeus666 - 25.07.2016

Hi. On my UCP, when you want to log in, you need to type your password, but on my database your password is encrypted on SHA1.

How can I make a converter so they just type their password and the converter will convert it to SHA1 and login can be successful?

PHP код:
$query mysql_query("SELECT username, password FROM users WHERE username = '$username'"); 



Re: SHA1 Password - yvoms - 25.07.2016

Lets get things right,
You are encrypting passwords to your database, you wouldn't want to have raw passwords laying around.
But then you make a UCP that Decrypts your passwords and shows the raw?
Why not make them type the password > Hash it > Check the hashes if they match, and then continue?


Re: SHA1 Password - Zeus666 - 25.07.2016

No.

http://vestigedayz.com/ucp/testplm.php


You need to log in with your hashed password, otherwise it will not recognize.

I want to log in with my unhashed password.


I register In agme with password test, on database appears 04141b4babwaevcwav4aw4va4a



On UCP i need to log in with 04141b..... and if I log in with test it's says wrong password


Re: SHA1 Password - yvoms - 25.07.2016

Thats because you are not hashing the input in the php file afaik


Re: SHA1 Password - Zeus666 - 25.07.2016

And how can I do it?


Re: SHA1 Password - itsCody - 25.07.2016

http://php.net/manual/en/function.hash.php
^ Regarding the UCP hashing issue.


Re: SHA1 Password - Zeus666 - 25.07.2016

I must change

PHP код:
$query mysql_query("SELECT username, password FROM users WHERE username = '$username'");   to 

PHP код:
$query mysql_query("SELECT username, password FROM users WHERE username = '$username'"  AND password where password $password(md5decripted
something like that but i dont know how


Re: SHA1 Password - itsCody - 25.07.2016

Or, you can post some snippets of the log in script..

Like fetching of the password, inputs, login buttons.. Maybe a little more.
You aren't even hashing it properly with the function I linked above


Re: SHA1 Password - Zeus666 - 25.07.2016

Quote:
Originally Posted by itsCody
Посмотреть сообщение
Or, you can post some snippets of the log in script..

Like fetching of the password, inputs, login buttons.. Maybe a little more.
You aren't even hashing it properly with the function I linked above
Код HTML:
public OnPlayerRegister(playerid, password[])
{
    if(IsPlayerConnected(playerid))
	{
	    new Query[450],IP[16];
	    GetPlayerIp(playerid, IP, sizeof(IP));
		strcat(Query,"INSERT INTO `users` (Username,Password,IP) VALUES ('%s', sha1('%s'),'%s')");
		format(Query,sizeof(Query),Query,PlayerName(playerid),password,IP);
PHP код:
ublic OnPlayerAccountLogin(playeridenteredPassword[])
{
    if(
IsPlayerNPC(playerid)) return 1;
    {
        if(
IsPlayerConnected(playerid))
        {
            new 
query[350];
            
format(querysizeof(query), "SELECT * FROM `users` WHERE `Username`= '%s' AND `Password` = SHA1('%s')"PlayerName(playerid), enteredPassword); 



Re: SHA1 Password - itsCody - 25.07.2016

I'm confused
SA:MP has SHA256. What's with SHA1??

https://sampwiki.blast.hk/wiki/SHA256_PassHash

And I thought you were talking about your user control panel regarding the login + hashing.