Skip to content

Instantly share code, notes, and snippets.

@eurica
Created November 9, 2012 06:16
Show Gist options
  • Save eurica/4044024 to your computer and use it in GitHub Desktop.
Save eurica/4044024 to your computer and use it in GitHub Desktop.
One time pad server code sample
<?
// 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