note 104770 modified in function.hash by danbrown

From: Date: Wed, 06 Jul 2011 14:44:41 +0000
Subject: note 104770 modified in function.hash by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-181292@lists.php.net to get a copy of this message
Another method. Not something you would want to use for utmost security, however it gets the job done. <?php function THashAndCrypt($input) { return str_rot13(base64_encode(hash('sha512', $input))); } function TdeCrypt($input) { return str_rot13(base64_decode($input)); } ?> This function takes your password, uses the rot13 method to jumble the text. Then it encodes it into a long jumbled base64 string. Finally, it is encrypted with SHA512. Not only does this use a secure SHA method, but it makes it generally more difficult to even determine which hash method was used. BY NO MEANS am i a professional PHP coder, but throughout my career i have done things like this to make things harder to decrypt in the event that they are stolen/compromised. Be aware that, simply by posting this on the net, i have made it less secure. When you want security, ALWAYS MAKE YOUR OWN FUNCTIONS. From my understanding, you should always use salt for added security. Salt can be added to these functions with little effort. Using salt in conjunction with several hundred unique hashing/encoding passes can make your passwords nearly uncrackable. Rather than taking an hour to find, the hacker is forced to either give up or wait an extra 2 years to successfully crack your encoded strings. --was-- Another method. Not something you would want to use for utmost security, however it gets the job done. function THashAndCrypt($input) { return str_rot13(base64_encode(hash('sha512', $input))); } function TdeCrypt($input) { return str_rot13(base64_decode($input)); } This function takes your password, uses the rot13 method to jumble the text. Then it encodes it into a long jumbled base64 string. Finally, it is encrypted with SHA512. Not only does this use a secure SHA method, but it makes it generally more difficult to even determine which hash method was used. BY NO MEANS am i a professional PHP coder, but throughout my career i have done things like this to make things harder to decrypt in the event that they are stolen/compromised. Be aware that, simply by posting this on the net, i have made it less secure. When you want security, ALWAYS MAKE YOUR OWN FUNCTIONS. From my understanding, you should always use salt for added security. Salt can be added to these functions with little effort. Using salt in conjunction with several hundred unique hashing/encoding passes can make your passwords nearly uncrackable. Rather than taking an hour to find, the hacker is forced to either give up or wait an extra 2 years to successfully crack your encoded strings. http://php.net/manual/en/function.hash.php

« previous php.notes (#181292) next »