Meine eingeschickte Version war nicht wirklcih 100% Fertig.
Ich habe noch eine kleine Verbesserung vorgenommen. Ich weiß, dass das nicht mehr Zählen wird, aber so ists wenigstens fertig.
(Die Verbesserung ist, dass der Hinzugefügte String zufällig generiert wird, und deshalb der Key, sowie die Verschlüsselung jedes Mal anderst ist. Dadurch wird es absolut unmöglich selbst durch ausprobieren hinter die Verschlüsselung zu kommen.)
Ein Feature ist auch die Kompression. (wenn man einen Text eingibt der sich oft wiederholt z.B. 50Mal hintereinander den String 'Hallo, wie geht es dir ?')
Spoiler anzeigen
; von Marsi
[/autoit] [autoit][/autoit] [autoit]Opt('GUICloseOnESC', 0)
Opt('GUIOnEventMode', 1)
#Region GUI
[/autoit] [autoit][/autoit] [autoit]Global $hProgress[2]
[/autoit] [autoit][/autoit] [autoit]$hGUI = GUICreate('Crypter - Decrypter', 400, 400, _CenterX(400), _CenterY(400), -1, 0x00000080)
GUISetOnEvent(-3, '_Exit')
GUICtrlCreateLabel('Text:', 5, 10, 300, 17, 1)
$hEdit_Text = GUICtrlCreateEdit('Text', 5, 30, 300, 300, 64, 0)
GUICtrlCreateLabel('Key:', 5, 345, 300, 17, 1)
$hEdit_Key = GUICtrlCreateEdit('Key', 5, 365, 300, 30, 64, 0)
$hProgress[0] = GUICtrlCreateLabel('', 310, 65, 85, 17, 1)
$hProgress[1] = GUICtrlCreateLabel('', 310, 85, 85, 17, 1)
GUICtrlCreateButton('Crypt', 310, 5, 85, 25)
GUICtrlSetOnEvent(-1, '__Crypt')
GUICtrlCreateButton('Decrypt', 310, 35, 85, 25)
GUICtrlSetOnEvent(-1, '__Decrypt')
GUISetState(@SW_SHOW, $hGUI)
#EndRegion GUI
[/autoit] [autoit][/autoit] [autoit]While Sleep(25)
WEnd
Func __Crypt()
GUICtrlSetData($hProgress[0], 'Crypt...')
Local $a = _Crypt(GUICtrlRead($hEdit_Text), $hEdit_Key)
GUICtrlSetData($hEdit_Text, $a[0])
GUICtrlSetData($hEdit_Key, $a[1])
GUICtrlSetData($hProgress[0], '')
GUICtrlSetData($hProgress[1], '')
EndFunc ;==>__Crypt
Func __Decrypt()
GUICtrlSetData($hProgress[0], 'Decrypt...')
GUICtrlSetData($hProgress[1], 'Bitte Warten')
Local $a = _Decrypt(GUICtrlRead($hEdit_Text), GUICtrlRead($hEdit_Key))
GUICtrlSetData($hEdit_Text, $a)
GUICtrlSetData($hProgress[0], '')
GUICtrlSetData($hProgress[1], '')
EndFunc ;==>__Decrypt
#Region Crypt
[/autoit] [autoit][/autoit] [autoit]Func _Crypt($sText, $hLabel_PW)
;~ $sText = StringTrimLeft(StringToBinary($sText & 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'), 2)
$sText = StringTrimLeft(StringToBinary($sText & _RandomString(62)), 2)
$sText = _Bin($sText)
Local $ZeichenVorrat[120] = ['À','Á','Â','Ã','Ä','Å','Ç','È','É','Ê','Ë','Ì','Í','Î','Ï','Ð','Ñ','Ò','Ó','Ô','Õ','Ö','Ø','Ù','Ú','Û','Ü','Ý','Þ','ß','à','á','â','ã','ä','å','ç','è','é','ê','ë','ì','í','î','ï','ð','ñ','ò','ó','ô','õ','ö','ø','ù','ú','û','ü','ý','þ','ÿ','2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
Local $ErsatzString = ''
Local $Schluessel = ''
For $i = 0 To UBound($ZeichenVorrat) - 1 Step 1
GUICtrlSetData($hProgress[1], $i & ' / ' & 120)
$ErsatzString = _Analyse($sText)
$sText = StringReplace($sText, $ErsatzString, $ZeichenVorrat[$i], 0, 1)
$Schluessel &= $ErsatzString
Next
$sPW = _Bin(StringTrimLeft(StringToBinary($Schluessel), 2))
Local $Temp_PW = _PW_gen($sPW)
$sPW = $Temp_PW[0]
$Schluessel = $Temp_PW[1]
Local $x[2] = [$sText & $Schluessel, $sPW]
Return $x
EndFunc ;==>_Crypt
Func _PW_gen($sPW)
Local $PW = ''
Local $Key = ''
For $i = 0 To StringLen($sPW) / 8 - 1 Step 1
$Key &= StringLeft($sPW, 7)
$sPW = StringTrimLeft($sPW, 7)
$PW &= StringLeft($sPW, 1)
$sPW = StringTrimLeft($sPW, 1)
Next
$PW = _AntiZero($PW)
$Key = _AntiZero($Key)
Local $x[2] = [BinaryToString('0x' & _Hex($PW)), BinaryToString('0x' & _Hex($Key))]
Return $x
EndFunc ;==>_PW_gen
Func _AntiZero($sPW) ;Nur für _Bin wenn /6 aufgeht.
Local $Temp_PW = ''
For $i = 0 To StringLen($sPW) / 6 - 1 Step 1
$Temp_PW &= '11' & StringLeft($sPW, 6)
$sPW = StringTrimLeft($sPW, 6)
Next
Return $Temp_PW
EndFunc ;==>_AntiZero
Func _RandomString($Laenge)
If $Laenge > 62 Then $Laenge = 62
Local $Temp_String = '', $Temp_Char = ''
Local $ZeichenVorrat_RndStr[62] = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','0','1','2','3','4','5','6','7','8','9']
For $i = 0 To $Laenge-1
$Temp_Char = $ZeichenVorrat_RndStr[Random(0,61,1)]
If Not StringInStr($Temp_String, $Temp_Char, 1) Then
$Temp_String &= $Temp_Char
Else
$i -= 1
EndIf
Next
Return $Temp_String
EndFunc
#EndRegion Crypt
[/autoit] [autoit][/autoit] [autoit]#Region Decrypt
[/autoit] [autoit][/autoit] [autoit]Func _Decrypt($sText, $sPW)
Local $ZeichenVorrat[120] = ['À','Á','Â','Ã','Ä','Å','Ç','È','É','Ê','Ë','Ì','Í','Î','Ï','Ð','Ñ','Ò','Ó','Ô','Õ','Ö','Ø','Ù','Ú','Û','Ü','Ý','Þ','ß','à','á','â','ã','ä','å','ç','è','é','ê','ë','ì','í','î','ï','ð','ñ','ò','ó','ô','õ','ö','ø','ù','ú','û','ü','ý','þ','ÿ','2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
_ArrayReverse($ZeichenVorrat)
$sKey = StringRight($sText, 280)
$sText = StringTrimRight($sText, 280)
$sKey = _PW_antiGen($sKey, $sPW)
Local $Laenge = StringLen($sKey) / 2
For $i = 0 To $Laenge - 1
$sText = StringReplace($sText, $ZeichenVorrat[$i], StringRight($sKey, 2), 0, 1)
$sKey = StringTrimRight($sKey, 2)
Next
$sText = _Hex($sText)
$sText = StringTrimRight(BinaryToString('0x' & $sText), 62)
If StringLeft($sText, 2) = '0x' Then Return
Return $sText
EndFunc ;==>_Decrypt
Func _PW_antiGen($sKey, $sPW)
Local $Temp_Key = _Bin(StringTrimLeft(StringToBinary($sKey), 2))
Local $Temp_PW = _Bin(StringTrimLeft(StringToBinary($sPW), 2))
Local $Key = ''
$Temp_PW = _AntiAntiZero($Temp_PW)
$Temp_Key = _AntiAntiZero($Temp_Key)
For $i = 0 To StringLen($Temp_PW) - 1 Step 1
$Key &= StringLeft($Temp_Key, 7)
$Temp_Key = StringTrimLeft($Temp_Key, 7)
$Key &= StringLeft($Temp_PW, 1)
$Temp_PW = StringTrimLeft($Temp_PW, 1)
Next
Return BinaryToString('0x' & _Hex($Key))
EndFunc ;==>_PW_antiGen
Func _AntiAntiZero($sPW) ;Nur für _Bin wenn /6 aufgeht.
Local $Temp_PW = ''
For $i = 0 To StringLen($sPW) Step 1
$sPW = StringTrimLeft($sPW, 2)
$Temp_PW &= StringLeft($sPW, 6)
$sPW = StringTrimLeft($sPW, 6)
Next
Return $Temp_PW
EndFunc ;==>_AntiAntiZero
#EndRegion Decrypt
[/autoit] [autoit][/autoit] [autoit]#Region Crypt/Decrypt - NebenFunktionen
[/autoit] [autoit][/autoit] [autoit]Func _Bin($sText)
$sText = StringReplace($sText, '0', '0000', 0, 1)
$sText = StringReplace($sText, '1', '0001', 0, 1)
$sText = StringReplace($sText, '2', '0010', 0, 1)
$sText = StringReplace($sText, '3', '0011', 0, 1)
$sText = StringReplace($sText, '4', '0100', 0, 1)
$sText = StringReplace($sText, '5', '0101', 0, 1)
$sText = StringReplace($sText, '6', '0110', 0, 1)
$sText = StringReplace($sText, '7', '0111', 0, 1)
$sText = StringReplace($sText, '8', '1000', 0, 1)
$sText = StringReplace($sText, '9', '1001', 0, 1)
$sText = StringReplace($sText, 'A', '1010', 0, 1)
$sText = StringReplace($sText, 'B', '1011', 0, 1)
$sText = StringReplace($sText, 'C', '1100', 0, 1)
$sText = StringReplace($sText, 'D', '1101', 0, 1)
$sText = StringReplace($sText, 'E', '1110', 0, 1)
$sText = StringReplace($sText, 'F', '1111', 0, 1)
Return $sText
EndFunc ;==>_Bin
Func _Hex($sText) ; Bin Rein, Hex raus
Local $a = StringLen($sText) / 4
Local $ErsatzString = ''
For $i = 0 To $a - 1 Step 1
$ErsatzString &= _StringReplaceBinHex(StringLeft($sText, 4))
$sText = StringTrimLeft($sText, 4)
Next
Return $ErsatzString
EndFunc ;==>_Hex
Func _StringReplaceBinHex($a)
Switch $a
Case '1111'
Return 'F'
Case '1110'
Return 'E'
Case '1101'
Return 'D'
Case '1100'
Return 'C'
Case '1011'
Return 'B'
Case '1010'
Return 'A'
Case '1001'
Return '9'
Case '1000'
Return '8'
Case '0111'
Return '7'
Case '0110'
Return '6'
Case '0101'
Return '5'
Case '0100'
Return '4'
Case '0011'
Return '3'
Case '0010'
Return '2'
Case '0001'
Return '1'
Case '0000'
Return '0'
Case Else
Return 'X'
EndSwitch
EndFunc ;==>_StringReplace
Func _Analyse($sData)
Local $StringLaenge = StringLen($sData)
Local $Top[2]
Local $StringPart, $Replacements
Local $Anzeige[2]
Local $Genauigkeit = -1
For $i = 0 To $StringLaenge - 1 Step 1
Switch $StringLaenge
Case 0 To 4000
$Genauigkeit = -1
Case 4001 To 8000
$Genauigkeit = 1
Case Else
$Genauigkeit = 2
EndSwitch
$StringPart = StringMid($sData, $i, 2)
StringReplace($sData, $StringPart, $StringPart, 0, 1)
$Replacements = @extended
If $Replacements >= $Top[0] Then
$Top[0] = $Replacements
$Top[1] = $StringPart
EndIf
If $Genauigkeit <> -1 Then
$Anzeige[1] = Round($i / $StringLaenge, $Genauigkeit)
If $Anzeige[0] <> $Anzeige[1] Then
GUICtrlSetData($hProgress[0], $Anzeige[1] * 100 & ' %')
$Anzeige[0] = $Anzeige[1]
EndIf
EndIf
Next
Return $Top[1]
EndFunc ;==>_Analyse
#EndRegion Crypt/Decrypt - NebenFunktionen
[/autoit] [autoit][/autoit] [autoit]#Region Sonstige Funktionen
[/autoit] [autoit][/autoit] [autoit]Func _Exit()
Exit
EndFunc ;==>_Exit
Func _CenterX($a)
Return @DesktopWidth / 2 - $a / 2
EndFunc ;==>_CenterX
Func _CenterY($a)
Return @DesktopHeight / 2 - $a / 2
EndFunc ;==>_CenterY
Func _ArrayReverse(ByRef $avArray, $iStart = 0, $iEnd = 0) ; Aus den Array-Funktionen geklaut ![]()
If Not IsArray($avArray) Then Return SetError(1, 0, 0)
If UBound($avArray, 0) <> 1 Then Return SetError(3, 0, 0)
Local $vTmp, $iUBound = UBound($avArray) - 1
[/autoit] [autoit][/autoit] [autoit]; Bounds checking
If $iEnd < 1 Or $iEnd > $iUBound Then $iEnd = $iUBound
If $iStart < 0 Then $iStart = 0
If $iStart > $iEnd Then Return SetError(2, 0, 0)
; Reverse
For $i = $iStart To Int(($iStart + $iEnd - 1) / 2)
$vTmp = $avArray[$i]
$avArray[$i] = $avArray[$iEnd]
$avArray[$iEnd] = $vTmp
$iEnd -= 1
Next
Return 1
EndFunc ;==>_ArrayReverse
#EndRegion Sonstige Funktionen
[/autoit]/Edit: es gibt immernoch sachen zum verbessern fällt mir grade auf^^ aber da hab ich jetzt keine Lust dazu. es ist so gut, wie es ist. //