Advertisement
ShadowEmbrace

Deciphering

Dec 10th, 2018
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.52 KB | None | 0 0
  1. <?php
  2.  
  3. $cipher = readline();
  4. $substring = explode(' ', readline());
  5.  
  6. for ($i = 0; $i < strlen($cipher); $i++) {
  7.     $letter = $cipher[$i];
  8.     if (ord($letter) >= ord('d') && ord($letter) <= ord('z') ||
  9.         $letter === '{' || $letter === '}' || $letter === '|' || $letter === '#') {
  10.         $cipher[$i] = chr(ord($letter) - 3);
  11.  
  12.     } else {
  13.         echo 'This is not the book you are looking for.';
  14.         return;
  15.     }
  16. }
  17.  
  18. $decipher = str_replace($substring[0], $substring[1], $cipher);
  19.  
  20. echo $decipher;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement