• Home
  • About
  • Downloadables
  • Weightloss for Recessive Times

Kibo …

… keeping meat fresh since 1970

Feed on
Posts
Comments

RC4 Encryption

May 18th, 2005 by Intermanaut

To use this code, simply call the EnDeCrypt function with two parameters: the string you want to encrypt/decrypt; the encryption password.

<?

function EnDeCrypt($plaintext,$strPwd)

{

$intLength=strlen($strPwd);

$sbox=Array();

$key=Array();

$cipher=”;

$i=0;

$j=0;

for ($a=0; $a<256; $a++)

{

$key[$a]=ord(substr($strPwd,($a % $intLength),1));

$sbox[$a]=$a;

}

$b=0;

for ($a=0; $a<256; $a++)

{

$b=($b + $sbox[$a] + $key[$a]) % 256;

$tempSwap = $sbox[$a];

$sbox[$a] = $sbox[$b];

$sbox[$b] = $tempSwap;

}

for ($a=0; $a<strlen($plaintext); $a++)

{

$i=($i+1) % 256;

$j=($j + $sbox[$i]) % 256;

$temp=$sbox[$i];

$sbox[$i]=$sbox[$j];

$sbox[$j]=$temp;

$k=$sbox[($sbox[$i] + $sbox[$j]) % 256 ];

$cipherby=ord(substr($plaintext,$a,1)) ^ $k;

$cipher=$cipher . chr($cipherby);

}

return $cipher;

}

$strTemp=EnDeCrypt(“String to encrypt”, “Cipher password”);

?>

Posted in PHP | No Comments

Comments are closed.

  • Recent Posts

    • Motorola MotoActv Review
    • Exceptionally Poor Grammar
    • The Adjustment Bureau
    • Unkown
    • Paul
  • Things

    • About
    • Addresses worth banning from your forum
    • Downloadables
    • Foamcore Macro Studio
    • Multiplicity: Pouring yourself a beer
    • Multiplicity: The five of me
    • Ross on Wye: What a Mess
    • Weightloss for Recessive Times
  • Stuff

    • Conversations (22)
    • Movies (21)
    • Programming (12)
      • ASP (3)
      • JavaScript (6)
      • PHP (2)
      • VBA (1)
    • Rambles (265)
      • Angry (48)
      • Happy (21)
    • Blogroll

      • 1 city, 2 people, 24 hours
      • del.icio.us
      • EmmieJay – guilt-free style
      • flickr

Kibo … © 2012 All Rights Reserved.

MistyLook made free by Web Hosting Bluebook