encription and decription code

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    encription and decription code

    PHP Code:
      function xoft_encode($plain_data$config_keypass)
      {
          
    $key_length 0;
          
    $all_bin_chars "";
          
    $cipher_data "";
          for (
    $i 0$i strlen($plain_data); $i++) {
              
    $p substr($plain_data$i1);
              
    $k substr($config_keypass$key_length1);
              
    $key_length++;
              if (
    $key_length >= strlen($config_keypass)) {
                  
    $key_length 0;
              }
              
    $dec_chars ord($p) ^ ord($k);
              
    $dec_chars $dec_chars strlen($config_keypass);
              
    $bin_chars decbin($dec_chars);
              while (
    strlen($bin_chars) < 8) {
                  
    $bin_chars "0" $bin_chars;
              }
              
    $all_bin_chars $all_bin_chars $bin_chars;
          }
          
    $m 0;
          for (
    $j 0$j strlen($all_bin_chars); $j $j 4) {
              
    $four_bit substr($all_bin_chars$j4);
              
    $four_bit_dec bindec($four_bit);
              
    $decimal_value $four_bit_dec $m;
              
    $base64_value dec_to_base64($decimal_value);
              
    $cipher_data $cipher_data $base64_value;
              
    $m++;
              if (
    $m 3) {
                  
    $m 0;
              }
          }
          return 
    $cipher_data;
      }
      
    ///////////////////////////////////////////////
      
    function xoft_decode($cipher_data$config_keypass)
      {
          
    $m 0;
          
    $all_bin_chars "";
          for (
    $i 0$i strlen($cipher_data); $i++) {
              
    $c substr($cipher_data$i1);
              
    $decimal_value base64_to_dec($c);
              
    $decimal_value = ($decimal_value $m) / 4;
              
    $four_bit decbin($decimal_value);
              while (
    strlen($four_bit) < 4) {
                  
    $four_bit "0" $four_bit;
              }
              
    $all_bin_chars $all_bin_chars $four_bit;
              
    $m++;
              if (
    $m 3) {
                  
    $m 0;
              }
          }
          
    $key_length 0;
          
    $plain_data "";
          for (
    $j 0$j strlen($all_bin_chars); $j $j 8) {
              
    $c substr($all_bin_chars$j8);
              
    $k substr($config_keypass$key_length1);
              
    $dec_chars bindec($c);
              
    $dec_chars $dec_chars strlen($config_keypass);
              
    $c chr($dec_chars);
              
    $key_length++;
              if (
    $key_length >= strlen($config_keypass)) {
                  
    $key_length 0;
              }
              
    $dec_chars ord($c) ^ ord($k);
              
    $p chr($dec_chars);
              
    $plain_data $plain_data $p;
          }
          return 
    $plain_data;
      }
      
    /////////////////////////////////////
      
    function base64_to_dec($str)
      {
          
    $str strtr($str, array("=" => "64""/" => "63""+" => "62""9" => "61""8" => "60""7" => "59""6" => "58""5" => "57""4" => "56""3" => "55""2" => "54""1" => "53""0" => "52""z" => "51""y" => "50""x" => "49""w" => "48""v" => "47""u" => "46""t" => "45""s" => "44""r" => "43""q" => "42""p" => "41""o" => "40""n" => "39""m" => "38""l" => "37""k" => "36""j" => "35""i" => "34""h" => "33""g" => "32""f" => "31""e" => "30""d" => "29""c" => "28""b" => "27""a" => "26""Z" => "25""Y" => "24""X" => "23""W" => "22""V" => "21""U" => "20""T" => "19""S" => "18""R" => "17""Q" => "16""P" => "15""O" => "14""N" => "13""M" => "12""L" => "11""K" => "10""J" => "9""I" => "8""H" => "7""G" => "6""F" => "5""E" => "4""D" => "3""C" => "2""B" => "1""A" => "0"));
          return 
    $str;
      }
      
    /////////////////////////////////////
      
    function dec_to_base64($str)
      {
          
    $str strtr($str, array("64" => "=""63" => "/""62" => "+""61" => "9""60" => "8""59" => "7""58" => "6""57" => "5""56" => "4""55" => "3""54" => "2""53" => "1""52" => "0""51" => "z""50" => "y""49" => "x""48" => "w""47" => "v""46" => "u""45" => "t""44" => "s""43" => "r""42" => "q""41" => "p""40" => "o""39" => "n""38" => "m""37" => "l""36" => "k""35" => "j""34" => "i""33" => "h""32" => "g""31" => "f""30" => "e""29" => "d""28" => "c""27" => "b""26" => "a""25" => "Z""24" => "Y""23" => "X""22" => "W""21" => "V""20" => "U""19" => "T""18" => "S""17" => "R""16" => "Q""15" => "P""14" => "O""13" => "N""12" => "M""11" => "L""10" => "K""9" => "J""8" => "I""7" => "H""6" => "G""5" => "F""4" => "E""3" => "D""2" => "C""1" => "B""0" => "A"));
          return 
    $str;
      } 
    usage:

    PHP Code:
    $key 'abcdefg'// define here your key
    $text 'the text to be encrypted';
    $encrypted_text =xoft_encode($text,$key);
    $decrypted_text =xoft_decode($encrypted_text,$key); // makes the encrypted string back to normal 
    Advertise your mobile site for FREE with AdTwirl


    #2
    thanks is this 64bit?
    Did I help you?
    You can help me too
    Your donations will help me finance my studies.

    Comment


      #3
      Check out this converter
      TRANSLATOR, BINARY
      Visit my site

      Comment

      Working...
      X