note 104947 deleted from function.hash by danbrown
| From: | danbrown@php.net | Date: | Mon, 18 Jul 2011 14:25:17 +0000 |
| Subject: | note 104947 deleted from function.hash by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-181650@lists.php.net to get a copy of this message | ||
Note Submitter: yayoko
----
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. ;)