Sinisterly
[AutoIt]String to Chr converter - Printable Version

+- Sinisterly (https://sinister.ly)
+-- Forum: Coding (https://sinister.ly/Forum-Coding)
+--- Forum: Coding (https://sinister.ly/Forum-Coding--71)
+--- Thread: [AutoIt]String to Chr converter (/Thread-AutoIt-String-to-Chr-converter)

Pages: 1 2


[AutoIt]String to Chr converter - 1234hotmaster - 10-10-2011

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.


RE: [AutoIt]String to Chr converter - 1234hotmaster - 11-01-2011

Bump - Added replacement of blank strings like "" or '' with Chr(0) and made it show a msgbox after file encryption was done.


RE: [AutoIt]String to Chr converter - Kilo - 11-01-2011

works great very cool thanks Smile


RE: [AutoIt]String to Chr converter - ReaperX - 11-25-2011

Love this "encrypter". Its awesome but What Specifically did you Use to Get it To Read Each Line and Convert Each Line to Chr?


RE: [AutoIt]String to Chr converter - 1234hotmaster - 11-26-2011

oh i just used _StringBetwen() to detect stuff between " and ' Smile


RE: [AutoIt]String to Chr converter - M3 ™ - 09-16-2012

Nice Code , Congratulations


RE: [AutoIt]String to Chr converter - 3r3bus - 09-16-2012

Deleted #2 for you,

Nice share...


RE: [AutoIt]String to Chr converter - 1234hotmaster - 09-17-2012

Thanks guys, i might work on making it better once i get more free time Biggrin


RE: [AutoIt]String to Chr converter - spymare - 09-23-2012

I will follow this thread, the greatest autoit tool I have seen for along time


RE: [AutoIt]String to Chr converter - armoros - 10-23-2012

Very Very nice.

Can i encrypt different code sources with this tool ie. python scripts etc. or .txt.

And can i use your code to an AutoIt project that i am after. credits to you of course .

thank you