Skip to content

Instantly share code, notes, and snippets.

@Opus1no2
Created April 16, 2013 21:58
Show Gist options
  • Save Opus1no2/5399998 to your computer and use it in GitHub Desktop.
Save Opus1no2/5399998 to your computer and use it in GitHub Desktop.
Caesar Hack
<?php
/**
* Caesar Hack
*/
$message = 'GUVFVFZLFRPERGZRFFNTR';
$letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
for ($j = 0; $j < strlen($letters); $j++) {
$trans = '';
for ($i = 0; $i < strlen($message); $i++) {
$num = strpos($letters, $message[$i]);
$num -= $j;
if ($num < 0) {
$num += strlen($letters);
}
$trans .= $letters[$num];
}
echo "{$j} {$trans}" . PHP_EOL;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment