Created
May 2, 2011 18:02
-
-
Save radiosilence/952042 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $msg = "Lorem"; | |
| // Key that user inputs | |
| $okey = "potato"; | |
| // A slow hash is made from this key - 2^14 iterations of whirlpool. Salt is generated automatically and is about 100 characters long. | |
| $hash = $hasher->hash($okey); | |
| // Salt of this hash is taken and stored, so that hash can be re-created with correct original key. | |
| $salt = $hasher->pull_salt($hash); | |
| // Last 32 characters of hash are taken for use as actual key | |
| $key = substr($hash, -32); | |
| // Encrypted with RIJNDAEL-256 | |
| $enc = $c->encrypt($msg, $key, True); | |
| // DECRYPTION | |
| $attempt = "potato" | |
| var_dump("DERIVED HASH", $hash, "STORED DATA:", $enc, $salt, "REQUIRED DATA:", $okey, "ACTUAL KEY", $key2, "MESSAGE:", | |
| $c->decrypt($enc, substr($hasher->hash($attempt, $salt), -32), True) | |
| ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment