| xdmisterx |
| | CITAZIONE [...]L'XXTEA, tecnicamente parlando, è un cifrario a blocchi basato su una rete di Feistel non bilanciata, dove le due metà in cui è diviso il blocco di dati su cui opera la funzione non sono delle stesse dimensioni. L'XXTEA lavora, infatti, su blocchi di dimensione variabile la cui lunghezza è minimo 64 bit e multipla di 32 bit. Il numero dei cicli completi dipende dalla dimensione del blocco, ma devono comunque essere compresi fra un minimo di 6 ed un massimo di 32 (quando si utilizzano blocchi di piccole dimensioni).[...] WikiAvendo trovato l'udf nel forum ufficiale, ho fatto questa semplice interfaccia per il suo utilizzo: CODICE #include <GuiConstants.au3> #include <WindowsConstants.au3>
Global $title = "File crypter XXTEA"
$gui = GUICreate($title,320,120,-1,-1,-1,0x00000010)
GUICtrlCreateGroup("Encrypt\decrypt file",10,10,300,100) $file_path = GUICtrlCreateInput("",20,30,200,20) GUICtrlSetTip($file_path,"The path of the file to encrypt or decrypt") GUICtrlSetState($file_path,$GUI_DROPACCEPTED) $open_dialog = GUICtrlCreateButton("Path...",225,30,80,20) $del_file = GUICtrlCreateCheckbox("Delete the input file...",20,55) $pwd = GUICtrlCreateInput("",20,80,200,20,0x0020) GUICtrlSetTip($pwd,"The password") $encdec = GUICtrlCreateButton("Enc\Dec",225,80,80,20)
GUISetState()
While 1 Switch GUIGetMsg() Case $gui_event_close Exit Case $open_dialog $path = FileOpenDialog($title,@ScriptDir,"All(*.*)") If $path <> "" Then GUICtrlSetData($file_path,$path) EndIf Case $encdec $read_path = GUICtrlRead($file_path) $pwd_r = GUICtrlRead($pwd) If $read_path <> "" And $pwd_r <> "" Then $open = FileOpen($read_path,0) $read = FileRead($open) FileClose($open) $sp = StringSplit($read_path,".",2) If $sp[UBound($sp)-1] = "fcx" Then $data = _XXTEA_Decrypt($read,$pwd_r) $sp_name = StringSplit($read_path,"\",2) $file_decrypted = StringReplace($sp_name[UBound($sp_name)-1],".fcx","") $file_decrypted_path = StringReplace($read_path,$sp_name[UBound($sp_name)-1],"") $write = FileOpen($file_decrypted_path & $file_decrypted,2) FileWrite($write,$data) FileClose($write) Else $data = _XXTEA_Encrypt($read,$pwd_r) $sp_name = StringSplit($read_path,"\",2) $file_crypted = $sp_name[UBound($sp_name)-1] &".fcx" $file_crypted_path = StringReplace($read_path,$sp_name[UBound($sp_name)-1],"") $write = FileOpen($file_crypted_path & $file_crypted,2) FileWrite($write,$data) FileClose($write) EndIf If GUICtrlRead($del_file) = $gui_checked Then FileDelete($read_path) EndIf EndIf GUICtrlSetData($pwd,"") EndSwitch WEnd
Func _XXTEA_Encrypt($Data, $Key) $Data = Binary($Data) Local $DataLen = BinaryLen($Data) If $DataLen = 0 Then Return "" ElseIf $DataLen < 8 Then $DataLen = 8 EndIf Local $Opcode = '0x83EC14B83400000099538B5C2420558B6C242056578B7C9DFCF7FB89C683C606C74424180000000085F68D76FF0F8EEA000000896C24288D4BFF8D549D00894C2410895424148974242081442418B979379E8B4C2418C1E90281E103000000894C241C31F6397424107E568B5424288BCF8B6CB204C1E9058D14AD0000000033CA8BD58BC7C1EA03C1E00433D003CA8B5424188BDE81E303000000335C241C8B4424308B1C9833D533DF03D333CA8B542428010CB28B0CB2463974241089CF7FAA8B5424288BCF8B2AC1E9058D14AD0000000033CA8BD58BC7C1EA03C1E00433D003CA8B5424188BDE81E303000000335C241C8B4424308B1C9833D533DF03D3FF4C242033CA8B542414014AFC8B4AFC8B54242089CF420F8F2DFFFFFF5F31C05E5D5B83C414C21000' Local $CodeBuffer = DllStructCreate("byte[" & BinaryLen($Opcode) & "]") DllStructSetData($CodeBuffer, 1, $Opcode)
Local $V = DllStructCreate("byte[" & Ceiling($DataLen / 4) * 4 & "]") DllStructSetData($V, 1, $Data)
Local $K = DllStructCreate("byte[16]") DllStructSetData($K, 1, $Key)
DllCall("user32.dll", "none", "CallWindowProc", "ptr", DllStructGetPtr($CodeBuffer), _ "ptr", DllStructGetPtr($V), _ "int", Ceiling($DataLen / 4), _ "ptr", DllStructGetPtr($K), _ "int", 0)
Local $Ret = DllStructGetData($V, 1) $CodeBuffer = 0 $V = 0 $K = 0 Return $Ret EndFunc
Func _XXTEA_Decrypt($Data, $Key) $Data = Binary($Data) Local $DataLen = BinaryLen($Data) If $DataLen = 0 Then Return ""
Local $Opcode = '0x83EC10B83400000099538B5C241C55568B742420578B3EF7FB69D0B979379E81C256DA4CB5895424180F84DD000000897424248D4BFF8D149E894C2410895424148B4C2418C1E90281E103000000894C241C8B742410837C2410007E528B5424248B6CB2FC8BCD8BD7C1E905C1E20233CA8BD78BC5C1EA03C1E00433D003CA8B5424188BDE81E3030000008B44242C33D7335C241C8B1C9833DD03D333CA8B542424290CB28B0CB24E89CF85F67FAE8B5424148B6AFC8BCD8BD7C1E905C1E20233CA8BD78BC5C1EA03C1E00433D003CA8B5424188BDE81E3030000008B44242C33D7335C241C8B1C9833DD03D333CA8B542424290A8B0A89CF814424184786C861837C2418000F8535FFFFFF5F31C05E5D5B83C410C21000' Local $CodeBuffer = DllStructCreate("byte[" & BinaryLen($Opcode) & "]") DllStructSetData($CodeBuffer, 1, $Opcode)
Local $V = DllStructCreate("byte[" & Ceiling($DataLen / 4) * 4 & "]") DllStructSetData($V, 1, $Data)
Local $K = DllStructCreate("byte[16]") DllStructSetData($K, 1, $Key)
DllCall("user32.dll", "none", "CallWindowProc", "ptr", DllStructGetPtr($CodeBuffer), _ "ptr", DllStructGetPtr($V), _ "int", Ceiling($DataLen / 4), _ "ptr", DllStructGetPtr($K), _ "int", 0)
Local $Ret = DllStructGetData($V, 1) $CodeBuffer = 0 $V = 0 $K = 0 Return $Ret EndFunc Cripta e decripta file. Ho inserito l'opzione drag & drop per la scelta del file ciao
| | |
| |
|