index file & processor
<?php header ("Content-Type: text/html; charset=windows-1251");
$text = (string)$_POST['text'];
$offset = (int)$_POST['offset'];
?>
<html>
<head>
<title>Шифратор-дешифратор крипта</title>
</head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />
<body>
<h1>Шифратор-дешифратор для крипты v.2, а <a href="http://www.chto.su">также мой
уютненький бложег</a></h1>
<pre>
Changelog:
v.2 Корректная поддержка русского языка
v.1 Стартовая версия
---
<a href="source.php">Source code</a>
---
Вставьте текст в поле text, смещение в поле offset. (обычно от -10 до 10)
Алгоритм кодирования: chr(ord(символ)+offset)
<form method="post">
Text: <textarea name="text"><?php print ($text); ?></textarea>
Offset: <input type="text" name="offset" value="<?php print ($offset?$offset:2); ?>">
<input type="submit">
</form>
<?php
if ($text) {
$array = preg_split('//', $text, -1, PREG_SPLIT_NO_EMPTY);
print 'Codepage:<hr/>';
$cplisted = array();
foreach ($array as $l) {
$lc = chr(ord($l)+$offset);
if (!in_array($l,$cplisted))
print "$l = $lc; ";
$result[] = $lc;
$cplisted[] = $l;
}
print '<hr/>Encoded text:<hr/>';
print implode('',$result);
print '<hr/>Decoded text:<hr/>';
foreach ($result as $l) {
$lc = chr(ord($l)-$offset);
$result2[] = $lc;
}
print implode('',$result2);
}
?>
</pre>
</body>
</html>