PHPBuilder - XOR Encryption Functions



RSS Twitter
Tips Application Architecture

XOR Encryption Functions

by: Dustin Schneider
|
August 6, 2000

Did you know you could write your own encryption functions? It's actually really simple, and can allow any size of keys. Here are the simple functions to do so:


function x_Encrypt($string, $key)
{
  for($i=0; $i<strlen($string); $i++)
  {
    for($j=0; $j<strlen($key); $j++)
    {
      $string[$i] = $string[$i]^$key[$j];
    }
  }

  return $string;
}

function x_Decrypt($string, $key)
{
  for($i=0; $i<strlen($string); $i++)
  {
    for($j=0; $j<strlen($key); $j++)
    {
      $string[$i] = $key[$j]^$string[$i];
    }
  }

  return $string;
}

Quite simple, eh? Try it out for yourself.
Dustin Schneider

Comment and Contribute

Your comment has been submitted and is pending approval.

Author:
Dustin Schneider

Comment:



Comment:

(Maximum characters: 1200). You have characters left.