Categories

LinkedIn

Jonathan Anders

Share

Recent Comments

dEncrypt

An encryption algorithm with a few twists that I’ve added.

function CryptAlg($dString,$dKey,$dType,$dIntense,$dCalcNum)
{
  if ($dIntense > 254)
    $dIntense = 254;
  $dNewString = $dString;
  for ($y = 0; $y = strlen($dKey))
        $x = 0;
      if ($dType == 0)
        $strOutput .= Chr((Ord($dNewString[$i]) + $dCalcNum) - Ord($dKey[$x]));
      if ($dType == 1)
        $strOutput .= Chr((Ord($dNewString[$i]) - $dCalcNum) + Ord($dKey[$x]));
      $x++;
    }
    $dNewString = $strOutput;
  }
  return $dNewString;
}

Usage:

  • $dString is the string you wish to encrypt
  • $dKey is your encryption key
  • $dType is to encrypt or decrypt the string ($dType values are 0 or 1, 0 is encrypt and 1 is decrypt)
  • $dIntense is how many times you wish to encrypt the string (makes for a more secure and harder to break string)
    Since the highest ascii value for a text character is 255, if you set the $dIntense value to 255, it will just loop back to
    where it was, and intern decrypt what you encrypted.
  • $dCalcNum is the number that will be added or subtracted with when ever encryption begins. The math will take place and will affect
    the first ascii number in the two statements.

Notes:

When crypting a string, remember that you MUST have the exact same $dKey, $dIntense, and $dCalcNum variables as the encrypted or decrypted string for it to accurately do it’s job.

Example:

$test = CryptAlg("Crypt Algorithm", "testkey1234567890", 0, 110, 1234567890);
echo "Encrypted text: $test";
$test = CryptAlg($test, "testkey1234567890", 1, 110, 1234567890);
echo "Decrypted text: $test";

Will yield:

Notice:

This code was created on 4/1/2003 and has not been updated since. I am posting this information here for easier access for users. Use at your own risk.

Popularity: 3% [?]

Leave a Reply

Your email address will not be published. Required fields are marked *

*


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">

Spam protection by WP Captcha-Free