[AutoIt]String to Chr converter 10-10-2011, 08:02 PM
#1
Code:
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <String.au3>
#include <Array.au3>
;www.hackcommunity.com
$Main = GUICreate("AutoIt3 String Chr Encrypter by 1234hotmaster", 561, 230, -1, -1)
$Input = GUICtrlCreateInput("Hello World!", 16, 16, 353, 21)
$Conv = GUICtrlCreateButton("Convert", 160, 46, 59, 25)
GUICtrlSetCursor (-1, 0)
$Output = GUICtrlCreateInput("", 16, 80, 321, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_READONLY))
$Cpy = GUICtrlCreateButton("Copy", 336, 80, 35, 21)
GUICtrlSetFont(-1, 6, 400, 0, "MS Sans Serif")
GUICtrlSetCursor (-1, 0)
$Group1 = GUICtrlCreateGroup("String Encrypter", 8, 0, 369, 105)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("Settings", 400, 0, 153, 65)
$RevHex = GUICtrlCreateCheckbox("Reverse Hex", 432, 20, 89, 17)
$Linebreak = GUICtrlCreateInput("5", 500, 42, 25, 18, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))
GUICtrlSetFont(-1, 6, 400, 0, "Arial")
$Label1 = GUICtrlCreateLabel("Line break for every", 410, 45, 90, 16)
GUICtrlSetFont(-1, 7, 400, 0, "Arial")
$Label2 = GUICtrlCreateLabel("Chr", 530, 45, 19, 16)
GUICtrlSetFont(-1, 7, 400, 0, "Arial")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group3 = GUICtrlCreateGroup("AutoIt3 Script (*.au3) Encrypter", 8, 120, 369, 105)
$LoadNEncrypt = GUICtrlCreateButton("Encrypt", 139, 186, 99, 25)
GUICtrlSetCursor (-1, 0)
$FileEnc = GUICtrlCreateInput("", 16, 136, 321, 21,$ES_READONLY)
$seldialog = GUICtrlCreateButton("...", 336, 135, 35, 25)
GUICtrlSetCursor (-1, 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
Global $temps
Func _EncString($str,$linebrk)
Local $op,$x
For $i = 1 To StringLen($str)
If Int($linebrk) <> 0 Then $x+=1
If $x = Int($linebrk) And $linebrk <> 0 Then
$op &= " _" & @CRLF
$x=0
EndIf
$op &= "Chr(" & Asc(StringMid($str,$i,1)) & ")&"
Next
$op = StringTrimRight($op,1)
If BitAnd(GUICtrlRead($RevHex),$GUI_CHECKED) = $GUI_CHECKED Then
$op = "_HexToString(_StringReverse(" & $op
$op &= "))"
EndIf
Return $op
$op = Chr(0)
EndFunc
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Conv
If Int(GUICtrlRead($Linebreak)) <= 0 Then GUICtrlSetData($Linebreak,0)
$temps = GUICtrlRead($Input)
If GUICtrlRead($Input) <> "" Then
Local $x = 0
If BitAnd(GUICtrlRead($RevHex),$GUI_CHECKED) = $GUI_CHECKED Then
GUICtrlSetData($Input, _StringReverse(_StringToHex(GUICtrlRead($Input))))
EndIf
GUICtrlSetData($Output, _EncString(GUICtrlRead($Input),GUICtrlRead($Linebreak)))
EndIf
GUICtrlSetData($Input,$temps)
Case $Cpy
ClipPut(GUICtrlRead($Output))
WinSetTitle("","","AutoIt3 String Chr Encrypter by 1234hotmaster || Copied")
Sleep(50)
WinSetTitle("","","AutoIt3 String Chr Encrypter by 1234hotmaster // Copied")
Sleep(50)
WinSetTitle("","","AutoIt3 String Chr Encrypter by 1234hotmaster -- Copied")
Sleep(50)
WinSetTitle("","","AutoIt3 String Chr Encrypter by 1234hotmaster \\ Copied")
Sleep(50)
Case $seldialog
$fd = FileOpenDialog("Select AutoIt3 Script",@WorkingDir,"AutoIt3 Script (*.au3)",1+2)
If Not @error Then GUICtrlSetData($FileEnc, $fd)
Case $LoadNEncrypt
If FileExists(GUICtrlRead($FileEnc)) Then
$filereaded = FileRead(GUICtrlRead($FileEnc))
$arr1 = _StringBetween($filereaded,Chr(34),Chr(34),1)
$filereaded = StringReplace($filereaded, Chr(39),Chr(34),1000,1)
$filereaded = StringReplace($filereaded, Chr(34)&Chr(34),"Chr(0)",1000,1)
For $i = 0 To UBound($arr1) - 1
$filereaded = StringReplace($filereaded, Chr(34) & $arr1[$i] & Chr(34),_EncString($arr1[$i],GUICtrlRead($Linebreak)),0)
Next
If BitAnd(GUICtrlRead($RevHex),$GUI_CHECKED) = $GUI_CHECKED Then
If Not StringInStr(StringLower($filereaded),"#include <string.au3>",1,1) Then $filereaded = "#include <String.au3>" & @CRLF & $filereaded
EndIf
$fs = FileOpen(GUICtrlRead($FileEnc),2)
FileWrite($fs, $filereaded)
FileClose($fs)
$filereaded = Chr(0)
MsgBox(64,"Done","Encryption of the file is complete.",1)
EndIf
EndSwitch
WEnd
you can use this to make your code harder to read, encryption, etc since au3 can be decompiled...
Edit: Added reverse hex method which needs #include <String.au3> on the top of your code.
(This post was last modified: 11-01-2011, 03:03 AM by Skullmeat.)
Pierce the life fibers with your drill.