note 104947 added to function.hash
| From: | yayoko at osu1 dot php dot net | Date: | Mon, 18 Jul 2011 13:32:17 +0000 |
| Subject: | note 104947 added to function.hash | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-181635@lists.php.net to get a copy of this message | ||
Hello,
the explaination of your example is in wrong order!
Your code:
<?php
function THashAndCrypt($input)
{
return str_rot13(base64_encode(hash('sha512', $input)));
}
function TdeCrypt($input)
{
return str_rot13(base64_decode($input));
}
?>
Your explaination:
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.
But PHP is working on your string in THIS order:
1. $input is encrypted with sha512.
2. Resulting Hash will be base64 encoded.
3. The base64 string will be str_rot13.
4. The secret will be returned as string.
And THAT order - like you said - will (hopefully) make it difficult for an attacker to determinate
how the heck you did the encryption. ;)
----
Server IP: 217.160.235.204
Probable Submitter: 217.232.0.68
----
Manual Page -- http://www.php.net/manual/en/function.hash.php
Edit -- https://master.php.net/note/edit/104947
Del: integrated -- https://master.php.net/note/delete/104947/integrated
Del: useless -- https://master.php.net/note/delete/104947/useless
Del: bad code -- https://master.php.net/note/delete/104947/bad+code
Del: spam -- https://master.php.net/note/delete/104947/spam
Del: non-english -- https://master.php.net/note/delete/104947/non-english
Del: in docs -- https://master.php.net/note/delete/104947/in+docs
Del: other reasons-- https://master.php.net/note/delete/104947
Reject -- https://master.php.net/note/reject/104947
Search -- https://master.php.net/manage/user-notes.php