{% else-1 %}

                        
<?php
function encrypt($string, $key) {
$strlen = strlen($string);
$result = "";
$flag = 0;
for ($i = 1; $i <= $strlen; $i++) {
$char = substr($string, $i - 1, 1);
$keychar = substr($key, ($i % strlen($key)) - 1, 1);
if ($flag == 0) {
$char = chr(ord($char) + ord($keychar));
$char = chr(ord($char) + ord($keychar));
$flag = 1;
} else {
$char = chr(ord($char) + ord($keychar));
$flag = 0;
}
$result .= $char;
}
return $result;
}

function decrypt($string, $key) {
$strlen = strlen($string);
$result = "";
$flag = 0;
for ($i = 1; $i <= $strlen; $i++) {
$char = substr($string, $i - 1, 1);
$keychar = substr($key, ($i % strlen($key)) - 1, 1);
if ($flag == 0) {
$char = chr(ord($char) - ord($keychar));
$char = chr(ord($char) - ord($keychar));
$flag = 1;
} else {
$char = chr(ord($char) - ord($keychar));
$flag = 0;
}
$result .= $char;
}
return $result;
}
?>
0 51 0
Без комментариев...