SHARE
TWEET

Untitled

a guest Sep 13th, 2017 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. /**************************************
  3.     Usage:
  4.      function CryptAlg($dString,$dKey,$dType,$dIntense,$dCalcNum)
  5.      * Where:
  6.      $dString is the string you wish to encrypt
  7.      $dKey is your encryption key
  8.      $dType is to encrypt or decrypt the string ($dType values are 0 or 1,
  9.         0 is encrypt and 1 is decrypt)
  10.      $dIntense is how many times you wish to encrypt the
  11.         string (makes for a more secure and harder to break string)
  12.         Since the highest ascii value for a text character is 255, if
  13.         you set the $dIntense value to 255, it will just loop back to
  14.         where it was, and intern decrypt what you encrypted.
  15.      $dCalcNum is the number that will be added or subtracted with when
  16.         ever encryption begins. The math will take place and will affect
  17.         the first ascii number in the two statements.
  18.     Notes:
  19.      When crypting a string, remember that you MUST have the exact
  20.      same $dKey, $dIntense, and $dCalcNum variables as the encrypted
  21.      or decrypted string for it to accurately do it's job.
  22.      
  23. */
  24.     function CryptAlg($dString,$dKey,$dType,$dIntense,$dCalcNum)
  25.     {
  26.         $dString = str_replace(" ","",str_replace("-","",$dString));
  27.         if ($dIntense > 254)
  28.             $dIntense = 254;
  29.         $dNewString = $dString;
  30.         for ($y = 0; $y <= $dIntense; $y++)
  31.         {
  32.             $strOutput = "";
  33.             $x = 0;
  34.             for ($i = 0; $i < strlen($dNewString); $i++)
  35.             {
  36.                 if ($x >= strlen($dKey))
  37.                     $x = 0;
  38.                 if ($dType == 0)
  39.                     $strOutput .= Chr((Ord($dNewString[$i]) + $dCalcNum) - Ord($dKey[$x]));
  40.                 if ($dType == 1)
  41.                     $strOutput .= Chr((Ord($dNewString[$i]) - $dCalcNum) + Ord($dKey[$x]));
  42.                 $x++;
  43.             }
  44.             $dNewString = $strOutput;
  45.         }
  46.         return $dNewString;
  47.     }
  48.    
  49.     # GLOBAL CREDITCARD ENCRYPTION KEY/CALCNUM
  50.     $dKey = "SkeletonKey";
  51.     $dIntense = 1;
  52.     $dCalcNum = 1234567890;
  53.    
  54.     /*$test = CryptAlg("Crypt Algorithm", "testkey1234567890", 0, 110, 1234567890);
  55.     echo "Encrypted text: $test<br>";
  56.     $test = CryptAlg($test, "testkey1234567890", 1, 110, 1234567890);
  57.     echo "Decrypted text: $test<br>";*/
  58. ?>
RAW Paste Data
Top