<?php
class Encrypt {
function xcrypt($encrypt, $source) {
// encrypt or decrypt a string $source
// If $encrypt is 1, then we're encrypting; otherwise we're decrypting
$universe = "tudLEBxcn1ehi2Ny8Q0sJKpHz7aAjvCfkb5P4I36oFG- 9qDgVwlmrT_RSMUO";
$cryptkey = "23 21 04 07 49 22 48 30 60";
// double universe length so that when encrypting from the left half or decrypting from the
// right, we never have to wrap around
$universe .= $universe;
$result = "";
$foundloc = 0;
// encrypt goes to the right, decrypt goes to the left
// encrypt
if ($encrypt == 1) {
for ($i = 0; $i < strlen($source); $i++) {
$foundloc = strpos ( $universe, substr ( $source, $i , 1)) + intval(substr($cryptkey, ($i % 9) * 3, 2));
if ($foundloc == FALSE) {
echo "Error: your user name or password contains characters other than letters, numbers, spaces, dashes, and underscores. Please use the Back button on your browser to back up and enter different values.";
return(FALSE);
}
$result .= substr($universe, $foundloc, 1) ;
}
// decrypt
} else {
for ($i = 0; $i < strlen($source); $i++) {
$foundloc = strpos ( $universe, substr ( $source, $i , 1), 61) - intval(substr($cryptkey, ($i % 9) * 3, 2));
if ($foundloc == FALSE) {
echo "Error: your user name or password contains characters other than letters, numbers, spaces, dashes, and underscores. Please use the Back button on your browser to back up and enter different values.";
return(FALSE);
}
$result .= substr($universe, $foundloc, 1);
}
}
return ($result);
}
}
?>