0

can anybody share, the best encryption and decryption technique in PHP.
here i just found 3 ways. are that any better technique?

<?php
//1
$password = 'mothafucka';
$sSalt = '8*S&AsEc4qUs';
$sHash = hash( 'whirlpool', $password . $sSalt );
echo $sHash."<br><br>";

//2
$password = "palancau87";
$password = sha1($password);
$password = md5($password);
echo $password."<br><br>";

//3
function getSalt( $iLength = 10 )
{
	$sPossible = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()-+=[]{}|';
	$iPossibleCount = strlen( $sPossible );
 
	$sSalt = '';
	for( $i=0; $i<$iLength; $i++ )
	{
		$sSalt .= $sPossible[mt_rand(0, $iPossibleCount)];
	}
 
	return $sSalt;
}
 
$sSalt = getSalt();
$sHash = hash('whirlpool', $password . $sSalt );
echo $sHash."<br><br>";
?>

Output:
52fc3756a4248bd5c059174d6d43f3579796ffb7f260451413bdc7ba821e7260f33306aa0973c6c5371632ca097deb93a6e8e54f3eb2e43035f037e74a423bad

20ccad752a137fe77724688ff82a5fd9

418b652b4a858e740202d88483636cdd181e74dc4bc25bab3b887a566e43bf9d542c0c21304b738ddb41a1735d8bdbfbe75156826bfdaa18083047a58e06103f

3
Contributors
5
Replies
6
Views
5 Years
Discussion Span
Last Post by dean8710
0

Do you want a hash (as shown), or do you want to be able to decrypt it? Also have a look at this thread.

3 above examples are from that link actually.
I just want to know the technique to decrypt it, so we as an admin, can echo it to view the encrypted word.

or, this encrypt technique cannot be decrypt?

Edited by dean8710: n/a

0

See mschroeder's link, if you want en-/decryption, instead of hashes. A hash is not meant to be decrypted.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.