Jump to content

CodeCrypter - Encrypt your Script


RTFC
 Share

Recommended Posts

Hi @RTFC,

I used your tools to encrypt my .au3 and (almost) all was good.

My program (a GIS system) must be in 3 languages, ENG,RUS,GER

I use a loc.au3 file where I have all phrases in the 3 languages.

To use cyricllic I had to switch to File->Encoding->UTF8 BOM

When I use Codecrypter it correctly wraps and .au3 works but ONLY in english. When I switch to RUS I can see only ?????????? ?????????? ?????

How to solve this?

Thanks,

Marco

Link to comment
Share on other sites

As I stated before, if people want me to have a look at a particular (potential) issue, then please provide the smallest-possible script that reproduces the error/problem.

Link to comment
Share on other sites

hmm is there a log I can provide you? There are no errors in .au3.
This is the "trick" I use to switch language:
 

$idOptionsmenu = GUICtrlCreateMenu("&Options")
$idLocalization = GUICtrlCreateMenu("Language", $idOptionsmenu)
$idLocENG = GUICtrlCreateMenuItem("English", $idLocalization)
$idLocRUS = GUICtrlCreateMenuItem("Russian", $idLocalization)
$idLocGER = GUICtrlCreateMenuItem("German", $idLocalization)

then

Case $idLocENG
            GUICtrlSetState($idLocENG, $GUI_CHECKED)
            GUICtrlSetState($idLocRUS, $GUI_UNCHECKED)
            GUICtrlSetState($idLocGER, $GUI_UNCHECKED)
            RegWrite($RegisterKey, "Language", "REG_SZ", "ENG")
            _send($dictionary[44])
        Case $idLocRUS
            GUICtrlSetState($idLocENG, $GUI_UNCHECKED)
            GUICtrlSetState($idLocRUS, $GUI_CHECKED)
            GUICtrlSetState($idLocGER, $GUI_UNCHECKED)
            RegWrite($RegisterKey, "Language", "REG_SZ", "RUS")
            _send($dictionary[44])
        Case $idLocGER
            GUICtrlSetState($idLocENG, $GUI_UNCHECKED)
            GUICtrlSetState($idLocRUS, $GUI_UNCHECKED)
            GUICtrlSetState($idLocGER, $GUI_CHECKED)
            RegWrite($RegisterKey, "Language", "REG_SZ", "GER")
            _send($dictionary[44])

with

#include <Localization.au3>

.
.
.
Global $dictionary[120]
.
.

Local $s_language = RegRead($RegisterKey, "Language")
.
.

    For $i = 0 To UBound($dictionary) - 1
        $dictionary[$i] = Eval($s_language & $i)
    Next

and my localization.au3, just to understand,

.
.
.

$ENG115= "Info"
$ENG116= "About"
$ENG117= "Terms of Use"
$ENG118= "Help"
.
.
.

$RUS115= "Информация"
$RUS116= "О продукте"
$RUS117= "Условия использования"
$RUS118= "Справка"

 

 

Edited by marko001
Link to comment
Share on other sites

Yeah, I'm not about to spend ages trying to reverse-engineer something that might possibly produce an error that might be similar to the one you're experiencing, or not, without any way of checking.:ermm: In your case, since this seems to concern localisation-specific strings, maybe adapt the provided HelloWorld example, and avoid GUIs if you can. Please note that the smaller and simpler the reproducer, the easier it is for me to narrow down what might be going wrong, so defintely nothing over a hundred lines in total. Thanks.

Link to comment
Share on other sites

Strike 1. So which part of

17 hours ago, RTFC said:

provide the smallest-possible script

and

15 hours ago, RTFC said:

avoid GUIs if you can

did you not understand? Especially since the issue can be reproduced in one line:

MsgBox(0,"test","Русский текст")

Moreover, your GUI reproducer would mess with my registry without my consent (if I had let it), which I consider rather rude.

Strike 2. How did you figure that this is a CodeCrypter problem? Did you even read the CodeCrypter FAQ? Especially the part where it describes how to methodically identify where a problem might originate? Just inspecting the CodeScanner output (either in its GUI or the "stringsUsed.txt" files in the output subdirectory would have shown you that this has got nothing to do with encryption. You didn't even have to run a backtranslate (but I suppose you didn't try that first either).

Strike 3. How about you try clicking this link, and maybe adopt that strategy as a general first approach before you post. That would have shown you that this is a generic AutoIt limitation that dozens of users have run up against in various contexts (with various solutions as well), for example here, here, and here. So the obvious solution is to not #include your language translations in the script, but keep them in separate files that you load/process at runtime. Nothing prevents you from also encrypting/decrpyting these (at runtime) with regular crypt functions (which will be encrypted by CodeCrypter). Or else maybe store them in binary form, and convert them at runtime.

Three strikes, and you're out. I won't be helping you again. [click]

Link to comment
Share on other sites

You're making your life difficult and Eval isn't needed.

Change your localized data file to something like this:

Global Enum $LANG_EN, $LANG_RU, $LANG_DE, $LANG_FR

Global $Dictionary = [ _
    [ _                         ; EN
        "Close", _
        "Standard Checkbox", _
        "Quit", _
        "The checkbox is checked.", _
        "The checkbox is not checked." _
    ], _
    [ _                         ; RU
        "близко", _
        "Стандартный флажок", _
        "Уволиться", _
        "Флажок отмечен.", _
        "Флажок не отмечен." _
    ], _
    [ _                         ; DE
        "Schließen", _
        "Standard Checkbox", _
        "Verlassen", _
        "Das Kontrollkästchen ist aktiviert.", _
        "Das Kontrollkästchen ist nicht aktiviert." _
    ], _
    [ _                         ; FR
        "Fermer", _
        "Case à cocher standard", _
        "Quitter", _
        "La case est cochée.", _
        "La case n'est pas cochée." _
    ] _
]

; language in force
Global $Lang

;===========================================================================
; example use
;---------------------------------------------------------------------------
; randomly select a language and display some strings
For $i = 1 To 3
    $Lang = Random($LANG_EN, $LANG_FR, 1)
    Use_Example()
Next

Func Use_Example()
    For $i = 1 To 3
        MsgBox(0, "", $Dictionary[$Lang][Random(0, UBound($Dictionary, 2) - 1, 1)])
    Next
EndFunc

 

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

@jchd thanks for your great support, dude, I appreciated.

Do you think, due the fact dictionary is over 200 phrases, it's better to keep it in  a separate au3 or keep it in the main script?

Thanks again,

Marco

[Edit]: Obviously I had to change to UTF-8 to show correctly cyrillic.
Could this led to troubles when encoding?

SS_2174.jpg

Edited by marko001
Link to comment
Share on other sites

Having 600+ lines of string data on top of the main source is uneasy to deal with.  Keep the data in it's own file and #include it just as you currently do.

When modifying the main code you don't have to page down at hell to find code, and if you need to change/add localized strings, it's easy enough to open the separate file.

You may also want to give strings a verbose ID instead of just a numeric index.  It would make your code easier to read and less error-prone:

Global Enum $LANG_EN, $LANG_RU, $LANG_DE, $LANG_FR

Global Enum $MSG_Close, $MSG_StdChkBox, $MSG_Quit, $MSG_ChkedBox, MSG_UnChkedBox

Global $Dictionary = [ _
    [ _                         ; EN
        "Close", _
        "Standard Checkbox", _
        "Quit", _
        "The checkbox is checked.", _
        "The checkbox is not checked." _
    ], _
...

Of course, giving a short yet meaningful name (enum) matching the actual string index is up to you, but I find MsgBox(0, "", $Dict[$Lang][$MSG_FileReadErr]) more readable than MsgBox(0, "", $Dict[$Lang][98]).

Obviously you still have to take care that the number and order of strings are the same for every language.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

But the problem still remains.

After encoding with Codecrypter I get this.

With your hint my code is surely better now but I still can't figure out how to get rid of these ????? on a crypted .au3 when on the contrary cyrillic is correctly shown on unencoded au3s

SS_2179.jpg

Link to comment
Share on other sites

I don't know how the things work in CodeCrypter, but I suspect some part isn't handling UTF8 correctly.  That sould be relatively easy to fix.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

1 minute ago, jchd said:

I don't know how the things work in CodeCrypter, but I suspect some part isn't handling UTF8 correctly.  That sould be relatively easy to fix.

"relatively easy" :D

You are the man: 8.820 posts and 1.416++ 

:D

 

Link to comment
Share on other sites

  • 1 month later...

This was an oversight in my patching of the CryptoNG lib; fixed in v3.3c, available for download now.

Link to comment
Share on other sites

  • 3 months later...

@RTFC

I see a few differences between your modified version of CryptoNG and the original version that could be problematic.  When comparing the version of CryptotNG.au3 that you distribute, which appears to be my v1.6.1, I think the following differences may need to be corrected.  The last correction listed below, is definitely the reason why the hashing result is not being returned in the post above. 
 

In __CryptoNG_BCryptCreateHash, the following line should be changed from

DllStructSetData($tHMACSecretBuffer,"data",$vHMACSecret)

to

DllStructSetData($tHMACSecretBuffer,"data",$xHMACSecret)

 

In __CryptoNG_BCryptEncrypt_CBC, the following line should be changed from

DllStructSetData($tIVBuffer,"data",$vIV)

to

DllStructSetData($tIVBuffer,"data",Binary($vIV))

 

In __CryptoNG_BCryptFinishHash, the following line should be changed from

;All is good
DllStructGetData($tDataBuffer,"data")

to

$xHash = DllStructGetData($tDataBuffer,"data")

 

For the record, as of this evening, CryptoNG is up to v1.7.0.  There's not a major difference in functionality between v1.6.1 and v1.7.0.  However, it does have several function header corrections and the getting/setting of structure fields was changed back to the object-based way of doing it.  There are a few more small additions, modifications, and optimizations, but not really enough to warrant switching to the newest version, unless you wanted to of course.   ;)

Edited by TheXman
Link to comment
Share on other sites

@TheXman:Thanks a bunch for scrutinising my patched version!:) I will implement the fixes soon.:> I did have a look at your CNG version 1.7, but as you already noted, the improvements you made were not going to impact CodeCrypter performance to any great extent, and I'm still not a fan of object-based notation, but I do appreciate your continuing efforts to make CNG the best it can possibly be. Sorry for the oversights on my part in adapting your work (bit distracted at the moment).

@quimao: fix uploaded. Thanks for notifying me.

Edited by RTFC
Link to comment
Share on other sites

I have a problem with CodeScannerCrypter. When I run Codescanner it usually opens directly in the current folder. That way I know its working. With the latest Windows updates it opens in This PC and when i navigate and find my file it doesnt work properly. It still do some calsulations but its way faster and it incomplete and it doesnt work. Now It doesnt even show the files in the folder. I downloaded v3.3.d from here (although it says its submitted 27 of February, this is the official link. Old versions doesnt work as well.



 I believe that have something to do with Windows Permissions. They started to make things difficult to run scripts since v1709 and up. And when new version comes out they implement it in lower versions Windows Updates. I have a tweaked WIndows but I try to remove the restrictions so I dont think its from that since on default Windows its the same.

Anyone else with similar problem?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...