Created
November 9, 2012 06:16
-
-
Save eurica/4044024 to your computer and use it in GitHub Desktop.
One time pad server code sample
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
<? | |
// One Time Pad from string demo. | |
// http://euri.ca/2012/11/encryption-that-calls-home-skyfall-movie-magic/ | |
// Don't use this in production, obviously since you can brute force the seed. | |
// (Actually coming up with a server that generates OTPs in response to a seed is a decent problem) | |
$seed = "LOCALSECRET" + $_SERVER["QUERY_STRING"]; | |
$hash = hash('sha256', $seed); | |
$dec = hexdec($hash); | |
mt_srand($dec); | |
for($i=0; $i<1000; $i++) { | |
echo dechex(mt_rand()); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment