Skip to content

Commit

Permalink
Update encrypt-decrypt.php
Browse files Browse the repository at this point in the history
  • Loading branch information
seebz committed Feb 27, 2014
1 parent adc32d9 commit cd668c6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions php/encrypt-decrypt.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ function encrypt($str, $salt=null) {
$out .= chr(ord($str{$i})+ord($kc));
}
$out = base64_encode($out);
$out = str_replace(array('=', '/'), array('', '-'), $out);
$out = str_replace(array('/', '='), array('-', ''), $out);
return $out;
}


function decrypt($str, $salt=null) {
$salt = md5($salt);
$out = '';
$str = str_replace('-', '/', $str);
$str = str_replace(array('-', ' ', '%20'), array('/', '+', '+'), $str);
$str = base64_decode($str);
for ($i = 0; $i<strlen($str); $i++) {
$kc = substr($salt, ($i%strlen($salt)) - 1, 1);
Expand All @@ -27,4 +27,4 @@ function decrypt($str, $salt=null) {
}


?>
?>

0 comments on commit cd668c6

Please sign in to comment.