PHP:
<?php
$password = \"\";
if (isset($_POST[\"pharse\"])) {
$password = $_POST[\"pharse\"];
}
function CalculateCheckSum($text) {
$z = 1;
for ($i=0;$i<strlen($text);$i++) {
$n = (integer)(Ord(substr($text,$i,1)));
$z = ((($z<<3)|($z>>28))^$n)&(0x7FFFFFFF);//^($n);
}
return (integer)($z);
}
// echo CalculateCheckSum($password).\"<br>\n\";
if (CalculateCheckSum($password)!=301685396) {
Header(\"Location: notepad_passerr.htm\");
;
}
function MakeInteger($text) {
return (integer)
((integer)((ord(substr($text,0,1))<<24))
|(integer)((ord(substr($text,1,1))<<16))
|(integer)((ord(substr($text,2,1)))<<8)
|(integer)(ord(substr($text,3,1))));
}
function MakeString($z) {
return (string)
Chr(($z>>24)&255).Chr(($z>>16)&255).Chr(($z>>8)&255).Chr($z&255);
}
function EmptyString($len) {
$key = \"\";
for ($i=0;$i<$len;$i++) {
$key.=Chr(0);
}
return $key;
}
function CreateKey($text,$keylen) {
$key = \"\";
$textlen = strlen($text);
for ($i=0;$i<$keylen;$i++) {
$mp1 = ((integer)($i*$textlen*$textlen/$keylen)%$textlen);
$mp2 = (integer)(Ord(substr($text,$mp1,1)));
$mp3 = (integer)(($mp2*$mp2-$i)^($i));
$key.=Chr($mp3);
}
return $key;
}
function Encrypt($text,$key) {
$str=\"\";
for ($i=0;$i<strlen($text);$i++) {
$keypos = ((integer)($i*strlen($key)*strlen($key)/strlen($text))%strlen($key));
$mpa = (integer)(Ord(substr($text,$i,1)));
$mpb = (integer)(Ord(substr($key,$keypos,1)));
$str.=Chr(($mpa+$mpb)%256);
}
return $str;
}
function Decrypt($text,$key) {
$str=\"\";
for ($i=0;$i<strlen($text);$i++) {
$keypos = ((integer)($i*strlen($key)*strlen($key)/strlen($text))%strlen($key));
$mpa = (integer)(Ord(substr($text,$i,1)));
$mpb = (integer)(Ord(substr($key,$keypos,1)));
$str.=Chr(($mpa-$mpb)%256);
}
return $str;
}
if (isset($_POST[\"mytext\"])) {
$mytext = $_POST[\"mytext\"];
$key = CreateKey($mytext,128);
$enckey = Encrypt($key,$password);
$encmytext = Encrypt($mytext,$enckey);
$f = @fopen(\"notepad.bin\",\"wb\");
if ($f) {
fwrite($f,$key);
fwrite($f,MakeString(CalculateCheckSum($mytext)));
fwrite($f,EmptyString(124));
fwrite($f,$encmytext);
fclose($f);
}
}
$s = \"\";
$f = @fopen(\"notepad.bin\",\"rb\");
if ($f) {
while (!(feof($f))) {
$s = $s.fread($f,4096);
}
fclose($f);
$frame = substr($s,0,256);
$s = substr($s,256,strlen($s)-256);
$key = substr($frame,0,128);
$chksum = MakeInteger(substr($frame,128,4));
$enckey = Encrypt($key,$password);
$s = Decrypt($s,$enckey);
}
?>
<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">
<html>
<head>
<meta http-equiv=\"cache-control\" content=\"no-cache\">
<meta http-equiv=\"expires\" content=\"0\">
<title>Whistler Online-Pad v1.0</title>
<style>
body {
background-color:#AAAAAA;
color:#000000;
}
#inText {
border:1px;
border-style:solid;
border-left-color:#888888;
border-top-color:#888888;
border-right-color:#EEEEEE;
border-bottom-color:#EEEEEE;
background-color:#DDDDDD;
}
#inButton {
border:1px;
border-style:solid;
border-left-color:#EEEEEE;
border-top-color:#EEEEEE;
border-right-color:#888888;
border-bottom-color:#888888;
background-color:#DDDDDD;
}
</style>
</head>
<body>
<form name=x method=\"POST\">
<table width=\"100%\" cellspacing=0 cellpadding=0 style=\"table-layout:fixed;width:100%;height:100%;\">
<colgroup>
<col width=\"50%\">
<col width=\"50%\">
</colgroup>
<tr><td colspan=2><textarea name=mytext style=\"width:100%;height:100%;display:block;\" rows=8 id=inText><?php
$s = str_replace(\"<\",\"<\",$s);
$s = str_replace(Chr(160),\" \",$s);
echo $s;
?></textarea></td></tr>
<tr height=\"32\">
<input type=hidden name=pharse value=\"<?php echo $password; ?>\">
<td width=\"50%\" align=left><input type=submit value=\"Change\" id=inButton></td>
<td width=\"50%\" align=right><input type=reset value=\"Undo\" id=inButton></td>
</tr>
</table>
</form>
</body>
</html>
Was meint ihr ? Diese Routine habe ich selber geschrieben - Ist ein so verschlüsselter Text sicher, wenn man das Passwort (ist ein langer Satz, der aber überhaupt kein Sinn macht) nicht kennt aber an alle Dateien inklusive PHP-Quellcode drankommt ?
Wenn ja, wie sicher ist er ? Gibt es irgendeine Seite, wo jeder sein verschlüsselten Text inklusive Quellcode veröffentlichen kann und jemand versucht es zu entschlüsseln und zu sagen, um was es in dem Text handelt ?
EDIT & P.S.: Oooops, falscher Smilie beim Beitragstitel - wenn ich eingeloggt bin, steht da ganz normal ein Fragezeichen, komisch ...