Which method would you call safe and secure? I shot these snippets from php.net. I am just curious because people posted their own, and I just could not understand why some of them are like them ... Can someone help me and tell me a little more about this? What would be the safest and why?
one.
<?php $hash = md5($salt1.$password.$salt2); ?>
2.
<?php function eliteEncrypt($string) { // Create a salt $salt = md5($string."%*4!#$;\.k~'( _@ "); // Hash the string $string = md5("$salt$string$salt"); return $string; } ?>
3.
<?php define ('SALT_ONE', 'some_random_123_collection_&$^%_of_stuff'); define ('SALT_TWO', 'another_random_%*!_collection_ANbu_of_stuff'); $password = 'dragon'; function generate_encrypted_password($str) { $new_pword = ''; if( defined('SALT_ONE') ): $new_pword .= md5(SALT_ONE); endif; $new_pword .= md5($str); if( defined('SALT_TWO') ): $new_pword .= md5(SALT_TWO); endif; return substr($new_pword, strlen($str), 40); } echo generate_encrypted_password($password); ?>
4.
<? function enchsetenev($toencode,$times) { $salt = 's+(_a*'; for($zo=0;$zo<$times;$zo=$zo+1) { $toencode = hash('sha512',salt.$toencode); $toencode = md5($toencode.$salt); } return $toencode; } ?>
5.
<?php $hash = $password . $salt; for ( $i = 0; $i < 10000; $i++ ) { $hash = md5( $hash ); } echo $hash; ?>
Kyle
source share