Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<? php function encode caesar cipher ($plaintext, $shift) { $cipher_text = ""; for ($i ..
Decoded Output download
<? php
function encode caesar cipher ($plaintext, $shift) {
$cipher_text = "";
for ($i = 0; $i < strlen($plaintext); $i++) {
$char = $plaintext [$i];
if (ctype_ alpha($char)) { // char == letter
$shift_value = ctype upper($char) ? 65 : 97;
$cipher_text .= chr( (ord($char) + $shift_value + $shift) % 26 + $shift_value);
} else {
$cipher_text .= $char;
return $cipher_text;
function decode caesar cipher($cipher_text, $shift) {
return encode caesar cipher($cipher_text, - $shift);
function main() {
$flag =
$shift = 5; // Shift
$encoded_flag = encode caesar.cipher($flag, $shift);
echo "CTF Challenge: Decode the following encrypted flag:
";
echo $encoded_flag . "
";
//Shift of 5
$user_input = readline("
Enter the decoded flag: ");
if ($user_input === $flag) {
echo "Nays Wan! Here's your flag P
";
} else {
echo "Ngek!
";
}
main();
?>
Did this file decode correctly?
Original Code
<? php
function encode caesar cipher ($plaintext, $shift) {
$cipher_text = "";
for ($i = 0; $i < strlen($plaintext); $i++) {
$char = $plaintext [$i];
if (ctype_ alpha($char)) { // char == letter
$shift_value = ctype upper($char) ? 65 : 97;
$cipher_text .= chr( (ord($char) + $shift_value + $shift) % 26 + $shift_value);
} else {
$cipher_text .= $char;
return $cipher_text;
function decode caesar cipher($cipher_text, $shift) {
return encode caesar cipher($cipher_text, - $shift);
function main() {
$flag =
$shift = 5; // Shift
$encoded_flag = encode caesar.cipher($flag, $shift);
echo "CTF Challenge: Decode the following encrypted flag: \n";
echo $encoded_flag . "\n\n";
//Shift of 5
$user_input = readline("\nEnter the decoded flag: ");
if ($user_input === $flag) {
echo "Nays Wan! Here's your flag P\n";
} else {
echo "Ngek! \n";
}
main();
Function Calls
None |
Stats
MD5 | 1ee8956f003af5978e7c6c57fc718411 |
Eval Count | 0 |
Decode Time | 39 ms |