<?php
function encrypt($plain, $cipher, $text) {
$newText = '';
for($i=0; $i<strlen($text); $i++) { $c = $text[$i];
if($index && $index < strlen($cipher)) { $newText = $newText . $cipher[$index];
} else {
$newText = $newText . $c;
}
}
return $newText;
}
$plainAlphabet = "abcdefghijklmnopqrstuvwxyz";
$cipherAlphabet = "zyxwvutsrqponmlkjihgfedcba";
$text = "Some sensitive text that only humans must be able to read";
$encodedText = encrypt($plainAlphabet, $cipherAlphabet, $text);
echo $encodedText;
PD9waHAKZnVuY3Rpb24gZW5jcnlwdCgkcGxhaW4sICRjaXBoZXIsICR0ZXh0KSB7CgkkcGxhaW4gPSAkcGxhaW4gLiBzdHJ0b3VwcGVyKCRwbGFpbik7CgkkY2lwaGVyID0gJGNpcGhlciAuIHN0cnRvdXBwZXIoJGNpcGhlcik7CiAKCSRuZXdUZXh0ID0gJyc7Cglmb3IoJGk9MDsgJGk8c3RybGVuKCR0ZXh0KTsgJGkrKykgIHsKCQkkYyA9ICR0ZXh0WyRpXTsKCQkkaW5kZXggPSBzdHJycG9zKCRwbGFpbiwgJGMpOwoJCWlmKCRpbmRleCAmJiAkaW5kZXggPCBzdHJsZW4oJGNpcGhlcikpIHsKCQkJJG5ld1RleHQgPSAkbmV3VGV4dCAuICRjaXBoZXJbJGluZGV4XTsKCQl9IGVsc2UgewoJCQkkbmV3VGV4dCA9ICRuZXdUZXh0IC4gJGM7CgkJfQoJfQoJcmV0dXJuICRuZXdUZXh0Owp9CiAKJHBsYWluQWxwaGFiZXQgPSAiYWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXoiOwokY2lwaGVyQWxwaGFiZXQgPSAienl4d3Z1dHNycXBvbm1sa2ppaGdmZWRjYmEiOwokdGV4dCA9ICJTb21lIHNlbnNpdGl2ZSB0ZXh0IHRoYXQgb25seSBodW1hbnMgbXVzdCBiZSBhYmxlIHRvIHJlYWQiOwogCiRlbmNvZGVkVGV4dCA9IGVuY3J5cHQoJHBsYWluQWxwaGFiZXQsICRjaXBoZXJBbHBoYWJldCwgJHRleHQpOwplY2hvICRlbmNvZGVkVGV4dDsK