SA-MP Forums Archive
Password encryption help - 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: Password encryption help (/showthread.php?tid=647102)



Password encryption help - JessThompson - 29.12.2017

How would I make my script work with this php encryption

Код:
		public function encrypt( $string, $encryption_key )
		{

			$password = hash( 'sha256', $string );
			$length   = strlen( $password ) / 2;

			if ( strlen( $password ) % 2 ) {
				$length++;
			}

			$passSplit = str_split( $password, $length );
			$saltSplit = str_split( $encryption_key, 3 );

			$string  = $saltSplit[0] . $passSplit[0] . $saltSplit[1] . $passSplit[1] . $saltSplit[2];
			$encrypt = hash( 'whirlpool', $string );

			return $encrypt;
		}

		public function encryption_key()
		{

			$numbers = array( 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60 );

			return substr( sha1( rand( $numbers[0], $numbers[count( $numbers ) - 1] ) ), 0, $numbers[rand( 0, count( $numbers ) - 1 )] );
		}



Re: Password encryption help - RogueDrifter - 29.12.2017

Encrypt the password the moment it's registered, save it in the user's file, the moment they login Encrypt the inputtext or the string that has the password, compare it to the saved encryption on register, if they match = true else return false login attempt, i'm gonna assume that the string in that encrypt function is the pw so that's where u implement it in both cases, tho im not sure about that encryption key part.
EDIT: and imo, if you're just trying to secure the player's database read this: Salting Tutorial
EDIT 2: I'm not sure what that public function does but hashes will return the same hash for passwords if the function u posted provides random strings for each password then hashes it (salt-hash) then it's fine.