Soooo... Dachte ich poste das auch noch hier, kann ja vielleicht wer brauchen ;D
Irgendwelche Superrätsel oder so... ^^
Ist eine Cäserchiffre. Verschiebt eigentlich die Zeichen um soviel, wie der Module von 256 aus der Prüfsumme von crc32 gibt.
Funktioniert soweit. Stellt damit an, was ihr wollt... Denkt aber an die Lizenz...
[php]<?php
/*
Cäserchiffre.
Chiffriert einen String mit einem Passwort, mit selbigen (Naja, nicht ganz...) lässt sich wieder entschlüsseln.
Funktioniert nur mit ASCII!
Copyright (C) 2006 Basilius Sauter
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
function chiffre_encode($sEncode, $sPass) {
$iPass = (crc32($sPass)%256);
$iEncodeLenght = StrLen($sEncode);
$sCrypt = '';
for($i = 0; $i < $iEncodeLenght; $i++) {
$iAsciiVal = ord($sEncode{$i});
$iAsciiVal += $iPass;
while($iAsciiVal > 255) {
$iAsciiVal -= 256;
}
$sCript .= chr($iAsciiVal);
}
return $sCript;
}
function chiffre_decode($sDecode, $sPass) {
$iPass = (crc32($sPass)%256);
$iDecodeLenght = StrLen($sDecode);
$sDecript = '';
for($i = 0; $i < $iDecodeLenght; $i++) {
$iAsciiVal = ord($sDecode{$i});
$iAsciiVal -= $iPass;
while($iAsciiVal > 255) {
$iAsciiVal -= 256;
}
$sDecript .= chr($iAsciiVal);
}
return $sDecript;
}
$var = chiffre_encode('Hello World', 'bla');
$var2 = chiffre_decode($var, 'bla');
var_dump($var, $var2);
?>[/php]