dnsx3

Encrypted and Decrypted { Caesar }

Jun 30th, 2016
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.98 KB | None | 0 0
  1. <?php
  2. /*
  3.  Author   : Lov3rDns
  4.  Title    : Encrypted and Decrypted { Caesar }
  5.  tw/video : https://twitter.com/NetDevr/status/748706162405552129
  6.  thanks @r00t3rz for the effort : http://www.exploit4arab.org/exploits/1382
  7. */
  8. set_time_limit(0);
  9. error_reporting(0);
  10.  
  11. echo "\n| Words  # ";
  12. $words=trim(fgets(STDIN));
  13. echo "\n| For Encrypted Enter 1 for Decrypted Enter 2  # ";
  14. $type=trim(fgets(STDIN));
  15. if($type == 1) // Encrypted
  16. {
  17. echo "\n| What is the key number .. Example : 10  # ";
  18. $key=trim(fgets(STDIN));
  19.  
  20. function check($first){
  21.    $first = strtoupper($first);
  22.    $second = ord($first);
  23.    return ($second > 64 && $second < 91) ? ($second - 64) : false;
  24. }
  25. function en0f($str, $add){
  26.     $ar = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'); // u can add the letters big
  27.     $strs = '';
  28.     foreach(str_split($str) as $i => $wor)
  29.     {
  30.         $ifn = (check($wor) - 1);
  31.         if( ( $ifn + $add ) > 26 )
  32.             $strs .= $ar[( $ifn + $add ) - 26];
  33.         else
  34.             $strs .= $ar[$ifn+$add];
  35.     }
  36.     return $strs;
  37. }
  38.  
  39. echo "\r\n Encrypted : [ ".en0f($words, +$key)." ]\r\n";
  40. }elseif($type == 2) // Decrypted
  41. {
  42. echo "\n| What is the key number .. Example : 10  # ";
  43. $key=trim(fgets(STDIN));
  44.  
  45. function check($first){
  46.    $first = strtoupper($first);
  47.    $second = ord($first);
  48.    return ($second > 64 && $second < 91) ? ($second - 64) : false;
  49. }
  50. function en0f($str, $add){
  51.     $ar = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'); // u can add the letters big
  52.     $strs = '';
  53.     foreach( str_split($str) as $i => $wor ) {
  54.         $ifn = (check($wor) - 1);
  55.         if( ( $ifn + $add ) > 26 )
  56.             $strs .= $ar[( $ifn + $add ) - 26];
  57.         else
  58.             $strs .= $ar[$ifn+$add];
  59.     }
  60.     return $strs;
  61. }
  62.  
  63. echo "\r\n Decrypted : [ ".en0f($words, -$key)." ]\r\n";
  64. }
  65. ?>
Advertisement
Add Comment
Please, Sign In to add comment