Hi,
Ich habe im Internet einen kleine PHP Verschlüsslungs Algorythmus gefunden. Diesen habe ich halbwegs übersetzt bekommen nur bekomme ich etwas völlig anderes raus als bei der PHP Datei.
Ich hoffe ihr könnt mir helfen.
Hier ist der PHP Algorythmus
Spoiler anzeigen
<?php
// String EnCrypt + DeCrypt function
// Author: halojoy, July 2006
// Modified and commented by: laserlight, August 2006
function convert($text, $key = '') {
// return text unaltered if the key is blank
if ($key == '') {
return $text;
}
// remove the spaces in the key
$key = str_replace(' ', '', $key);
if (strlen($key) < 8) {
exit('key error');
}
// set key length to be no more than 32 characters
$key_len = strlen($key);
if ($key_len > 32) {
$key_len = 32;
}
$k = array(); // key array
// fill key array with the bitwise AND of the ith key character and 0x1F
for ($i = 0; $i < $key_len; ++$i) {
$k[$i] = ord($key{$i}) & 0x1F;
}
// perform encryption/decryption
for ($i = 0, $j = 0; $i < strlen($text); ++$i) {
$e = ord($text{$i});
// if the bitwise AND of this character and 0xE0 is non-zero
// set this character to the bitwise XOR of itself and the jth key element
// else leave this character alone
if ($e & 0xE0) {
$text{$i} = chr($e ^ $k[$j]);
}
// increment j, but ensure that it does not exceed key_len-1
$j = ($j + 1) % $key_len;
}
return $text;
}
echo convert('To be or not to be, that is the question', 'mysecretkey');
?>
Alles anzeigen
und hier mein Versuch
Spoiler anzeigen
#include <String.au3>
#include <Array.au3>
; -1 Key Error
MsgBox(0, "", Convert("12rtt3", "1234567hhhhh89zz"))
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]Func Convert($str, $ky)
If $ky = "" Then Return $str
$ky = StringReplace($ky, Chr(32), '')
If StringLen($ky) < 8 Then Return -1
If StringLen($ky) < 32 Then
$kl = StringLen($ky)
Else
$kl = 32
EndIf
Local $TmpArr[$kl]
For $i = 0 To $kl - 1
$TmpArr[$i] = BitXOR(Ord(StringMid($ky, $i, 1)), 0x1F)
Next
;~ _ArrayDisplay($TmpArr)
$j = 0
For $i = 0 To StringLen($str) - 1
$e = Ord(StringMid($str, $i, 1))
If BitXOR($e, 0xE0) Then $str = StringReplaceCount($str, Chr($e ^ $TmpArr[$j]), $i)
[/autoit] [autoit][/autoit] [autoit]$j = Mod(($j + 1), $kl)
Next
Return $str
EndFunc ;==>Convert
Func Ord($sStr)
Return Asc(StringLeft($sStr, 1))
EndFunc ;==>Ord
Func StringReplaceCount($sStr, $subString, $Index)
$sStr = StringSplit($sStr, "")
$sStr[$Index] = $subString
Return _ArrayToString($sStr, "")
EndFunc ;==>StringReplaceCount
Schon mal danke für die Antworten !
//Edit: Zum schluss müsste die Ausgabe beim Autoit Script so
aussehen