SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 14/09/2017, 02:58 PM   #1
warningCode
Little Clucker
 
warningCode's Avatar
 
Join Date: Feb 2016
Posts: 6
Reputation: 0
Default hash password with md5

I want to hash password with md5
how can i do?
warningCode is offline   Reply With Quote
Old 14/09/2017, 03:05 PM   #2
Zeth
Huge Clucker
 
Zeth's Avatar
 
Join Date: Feb 2017
Location: Titan
Posts: 428
Reputation: 114
Default Re: hash password with md5

If you are using MySQL, there is no need of any plugin, you just need to put md5 along with the the password like md5('%s') and you can also use salt with md5 to improve the security.
Zeth is offline   Reply With Quote
Old 14/09/2017, 03:08 PM   #3
Vince
Spam Machine
 
Vince's Avatar
 
Join Date: Sep 2007
Location: Belgium
Posts: 10,083
Reputation: 2655
Default Re: hash password with md5

MD5 has been proven insecure. Use the inbuilt SHA256_PassHash() function instead.
__________________
Vince is offline   Reply With Quote
Old 14/09/2017, 03:30 PM   #4
warningCode
Little Clucker
 
warningCode's Avatar
 
Join Date: Feb 2016
Posts: 6
Reputation: 0
Default Re: hash password with md5

http://forum.sa-mp.com/showthread.php?t=273088
instead of udb.
how can i do on it? md5 or sha256
warningCode is offline   Reply With Quote
Old 15/09/2017, 08:31 PM   #5
warningCode
Little Clucker
 
warningCode's Avatar
 
Join Date: Feb 2016
Posts: 6
Reputation: 0
Default Re: hash password with md5

Quote:
Originally Posted by warningCode View Post
http://forum.sa-mp.com/showthread.php?t=273088
instead of udb.
how can i do on it? md5 or sha256
again.
warningCode is offline   Reply With Quote
Old 15/09/2017, 08:37 PM   #6
Meller
Banned
 
Join Date: Dec 2016
Posts: 579
Reputation: 132
Default Re: hash password with md5

I'd suggest you to use SHA256 with a secret HASH, example:

PHP Code:
SHA256_PassHash(password[], salt[], ret_hash[], ret_hash_len)

SHA256_PassHash("the input"""ur secret hash/salt", password, sizeof password); 
Meller is offline   Reply With Quote
Old 15/09/2017, 08:51 PM   #7
Whatname
Big Clucker
 
Join Date: Aug 2016
Posts: 177
Reputation: 12
Default Re: hash password with md5

md5 is not that good

use whirlpool or sha256
Whatname is offline   Reply With Quote
Old 15/09/2017, 08:52 PM   #8
warningCode
Little Clucker
 
warningCode's Avatar
 
Join Date: Feb 2016
Posts: 6
Reputation: 0
Default Re: hash password with md5

Quote:
Originally Posted by Meller View Post
I'd suggest you to use SHA256 with a secret HASH, example:

PHP Code:
SHA256_PassHash(password[], salt[], ret_hash[], ret_hash_len)

SHA256_PassHash("the input"""ur secret hash/salt", password, sizeof password); 
how i can edit according to this?
Code:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch( dialogid )
    {
        case DIALOG_REGISTER:
        {
            if (!response) return Kick(playerid);
            if(response)
            {
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_WHITE"Registering...",""COL_RED"You have entered an invalid password.\n"COL_WHITE"Type your password below to register a new account.","Register","Quit");
                new INI:File = INI_Open(UserPath(playerid));
                INI_SetTag(File,"data");
                INI_WriteInt(File,"Password",udb_hash(inputtext));
                INI_WriteInt(File,"Cash",0);
                INI_WriteInt(File,"Admin",0);
                INI_WriteInt(File,"Kills",0);
                INI_WriteInt(File,"Deaths",0);
                INI_Close(File);

                SetSpawnInfo(playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);
                SpawnPlayer(playerid);
                ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"Great! Your Y_INI system works perfectly. Relog to save your stats!","Ok","");
			}
        }

        case DIALOG_LOGIN:
        {
            if ( !response ) return Kick ( playerid );
            if( response )
            {
                if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
                {
                    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                    GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
					ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"You have successfully logged in!","Ok","");
                }
                else
                {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
                }
                return 1;
            }
        }
    }
    return 1;
}
warningCode is offline   Reply With Quote
Old 15/09/2017, 08:55 PM   #9
Meller
Banned
 
Join Date: Dec 2016
Posts: 579
Reputation: 132
Default Re: hash password with md5

Your encryption should be enough, you're using local files, being restricted to your server only, there's no way they're getting leaked unless you're stupid. But, if you'd be stupid, you still have udb_hash(). So it should be enough. I only encrypt my passwords if they're remote, of course I've started encrypting them all the time, but what you got is enough.
Meller is offline   Reply With Quote
Old 15/09/2017, 09:02 PM   #10
warningCode
Little Clucker
 
warningCode's Avatar
 
Join Date: Feb 2016
Posts: 6
Reputation: 0
Default Re: hash password with md5

Quote:
Originally Posted by Meller View Post
Your encryption should be enough, you're using local files, being restricted to your server only, there's no way they're getting leaked unless you're stupid. But, if you'd be stupid, you still have udb_hash(). So it should be enough. I only encrypt my passwords if they're remote, of course I've started encrypting them all the time, but what you got is enough.
I understand but the registers will be closed from in the game, to be done through .ini.
This is not possible with udb.
warningCode is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hash password on PHP Sensation Scripting Help 2 31/05/2015 06:29 PM
Password Hash CrazyChoco Scripting Help 3 18/10/2012 01:22 PM
Password Hash BleverCastard Scripting Help 2 01/04/2012 08:12 PM
Hash Password mitosking Scripting Help 2 23/10/2011 09:54 PM


All times are GMT. The time now is 09:47 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.