Voici mon nouvel UDF : _Crypt_Space.au3
Il sert à crypter une chaine de caractères et les transformes en espaces.
Par exemple, si je crypte "Bonjour, je suis TT22 !" avec le code 22, ça donne ça :
Bonjour, je suis TT22 !.txt
- (2.36 Kio) Téléchargé 422 fois
Code : Tout sélectionner
_Crypt_Space($Crypt,$Code,$Flag)
$Crypt = Chaine de caractères à crypter/décrypter.
$Code = Code de cryptage (défaut est 1), ATTENTION : Le code de cryptage doit être le même que celui de décryptage sinon, vos résultats seronts incorrectes.
$Flag = 0 pour crypter, 1 pour décrypter.
Renvoie la chaine de carractère cryptée/décryptée.
Donc, l'UDF :
► Afficher le texte
Code : Tout sélectionner
#cs ----------------------------------------------------------------------------
AutoIt Version: 3.3.6.1
Author: TT22
Script Function:_Crypt_Space (UDF)
Template AutoIt script.
#ce ----------------------------------------------------------------------------
; Script Start - Add your code below here
; $Crypt = Chaine de caractères à crypter/décrypter.
; $Code = Code de cryptage (défaut est 1), ATTENTION : Le code de cryptage doit être le même que celui de décryptage sinon, vos résultats seronts incorrectes.
; $Flag = 0 pour crypter, 1 pour décrypter.
; Renvoie la chaine de carractère cryptée/décryptée.
#include <Array.au3>
#include <File.au3>
Func _Crypt_Space($Crypt,$Code,$Flag)
; ENCRYPT :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
If $Flag = 0 Then
If $Code < 0 Then $Code = 0
If $Code = "" Then $Code = 1
$toure = 0
$Plus_Code = ""
While 1
$toure = $toure + 1
$Plus_Code = $Plus_Code &" "
If $toure = $Code Then ExitLoop
WEnd
FileDelete(@ScriptDir&"\Crypt.art")
FileDelete(@ScriptDir&"\Tmp.art")
FileWrite(@ScriptDir&"\Tmp.art",$Crypt)
$Chars = StringSplit($Crypt, "")
If _FileCountLines(@ScriptDir&"\Tmp.art") > 1 Then
$UBound = 0
$Ub = UBound($Chars)
EndIf
If _FileCountLines(@ScriptDir&"\Tmp.art") = 1 Then
$UBound = 1
$Ub = UBound($Chars)
EndIf
FileDelete(@ScriptDir&"\Tmp.art")
While 1
$Ub = $Ub - 1
FileWriteLine(@ScriptDir&"\Crypt.art",$Chars[$Ub])
If $Ub = $UBound then ExitLoop
WEnd
$tour = _FileCountLines(@ScriptDir&"\Crypt.art")
$tour = $tour + 1
FileDelete(@ScriptDir&"\Encrypt.art")
While 1
$tour = $tour - 1
If $tour = 0 Then ExitLoop
$lettre = FileReadLine(@ScriptDir&"\Crypt.art",$tour)
$Encrypt = AscW($lettre)
$ttour = 0
$Finish = ""
While 1
If $Encrypt = 0 Then ExitLoop
$ttour = $ttour + 1
$Finish = $Finish&" "
If $ttour = $Encrypt Then ExitLoop
WEnd
FileWriteLine(@ScriptDir&"\Encrypt.art",$Finish&$Plus_Code)
WEnd
$Crypted = FileRead(@ScriptDir&"\Encrypt.art")
FileDelete(@ScriptDir&"\Encrypt.art")
FileDelete(@ScriptDir&"\Crypt.art")
Return $Crypted
EndIf
; ENCRYPT :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
; DECRYPT :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
If $Flag = 1 Then
$CRLF = 0
If $Code < 0 Then $Code = 0
If $Code = "" Then $Code = 1
FileDelete(@ScriptDir&"\Crypt.art")
FileWrite(@ScriptDir&"\Crypt.art",$Crypt&@CRLF&"a")
$numline = _FileCountLines(@ScriptDir&"\Crypt.art")
$tour = 0
While 1
$tour = $tour + 1
$Chars = StringSplit(FileReadLine(@ScriptDir&"\Crypt.art",$tour), "")
FileDelete(@ScriptDir&"\Tmp.art")
While UBound($Chars)
FileWriteLine(@ScriptDir&"\Tmp.art",_ArrayPop($Chars))
WEnd
$Number = _FileCountLines(@ScriptDir&"\Tmp.art")
FileDelete(@ScriptDir&"\Tmp.art")
If $Number = $Code+1 Then
$Car = "#@CRLF#"
$CRLF = 1
Else
$Car = Chr($Number-($Code+1))
EndIf
FileWrite(@ScriptDir&"\Decrypt.art",$Car)
If $tour = $numline - 2 Then ExitLoop
WEnd
_ReplaceStringInFile(@ScriptDir&"\Decrypt.art","#@CRLF##@CRLF#",@CRLF)
$Decrypted = FileRead(@ScriptDir&"\Decrypt.art")
FileDelete(@ScriptDir&"\Decrypt.art")
FileDelete(@ScriptDir&"\Crypt.art")
Return $Decrypted
EndIf
; DECRYPT :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
EndFunc
► Afficher le texte
Code : Tout sélectionner
#include <GuiConstantsEx.au3>
#include "_Crypt_Space.au3"
_Main()
Func _Main()
; GUI and String stuff
$WinMain = GUICreate('_Crypt_Space', 400, 400)
; Creates window
$EditText = GUICtrlCreateEdit('', 5, 5, 380, 350)
; Creates main edit
$InputLevel = GUICtrlCreateInput(1, 110, 360, 50, 20, 0x2001)
$EncryptButton = GUICtrlCreateButton('Encrypt', 170, 360, 105, 35)
; Encryption button
$DecryptButton = GUICtrlCreateButton('Decrypt', 285, 360, 105, 35)
; Decryption button
GUICtrlCreateLabel('Level', 110, 385)
; Simple text labels so you know what is what
GUISetState()
; Shows window
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
Case $EncryptButton
GUISetState(@SW_DISABLE, $WinMain) ; Stops you from changing anything
$string = GUICtrlRead($EditText) ; Saves the editbox for later
GUICtrlSetData($EditText, 'Please wait while the text is Encrypted/Decrypted.') ; Friendly message
GUICtrlSetData($EditText, _Crypt_Space($string,GUICtrlRead($InputLevel),0))
; Calls the encryption. Sets the data of editbox with the encrypted string
; The encryption starts with 1/0 to tell it to encrypt/decrypt
; The encryption then has the string that we saved for later from edit box
; It then reads the password box & Reads the level box
GUISetState(@SW_ENABLE, $WinMain) ; This turns the window back on
Case $DecryptButton
GUISetState(@SW_DISABLE, $WinMain) ; Stops you from changing anything
$string = GUICtrlRead($EditText) ; Saves the editbox for later
GUICtrlSetData($EditText, 'Please wait while the text is Encrypted/Decrypted.') ; Friendly message
GUICtrlSetData($EditText, _Crypt_Space($string,GUICtrlRead($InputLevel),1))
; Calls the encryption. Sets the data of editbox with the encrypted string
; The encryption starts with 1/0 to tell it to encrypt/decrypt
; The encryption then has the string that we saved for later from edit box
; It then reads the password box & Reads the level box
GUISetState(@SW_ENABLE, $WinMain) ; This turns the window back on
EndSwitch
WEnd ; Continue loop untill window is closed
Exit
EndFunc ;==>_Main

PS : Le décryptage est un peut plus long que le cryptage.