Jump to content
RTFC

CodeCrypter - Encrypt your Script

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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites
Posted (edited)

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

Share this post


Link to post
Share on other sites

Well if you want I can create a small program as example, multilanguage, and see how it goes?

Share this post


Link to post
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.

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites

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

LOL no problem i don't need any more your help [click][click]

(don't loose your precious time in replying, I don't have time to read it)

 

 

Share this post


Link to post
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)

Share this post


Link to post
Share on other sites
Posted (edited)

@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

Share this post


Link to post
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)

Share this post


Link to post
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

Share this post


Link to post
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)

Share this post


Link to post
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

 

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By RTFC
      The CodeScannerCrypterBundle (ca. 2.5 MB unzipped) contains the following UDFs and utilities:
      CodeScanner: analyse AutoIt script structure and content, identify potential issues, generate MCF data files CodeCrypter: front-end GUI for the MCF library, for script encryption (without storing the decryption key(s) in the script!) MetaCodeFile UDF (MCF library): for analysis and user-defined alterations of AutoIt script structure and content MCFinclude.au3: #include this UDF in any AutoIt script that you wish CodeCrypter to process AES.au3, by Ward; machine code UDF for AES encryption (32-bit, patched version) CryptoNG, by TheXman; encryption UDF using Bcrypt dll calls (32/64-bit; various algorithms) StoreCCprofile.au3/readCSdatadump.au3/helloworld.au3: auxiliary utilities and example script HowToCodeCrypt.pdf: a simple guide in five steps CodeCrypterFAQ.pdf: questions and answers, partly based upon exchanges in the CodeCrypter thread. Please follow the links for additional information.
    • By TheXman
      Encryption / Decryption / Hashing
      Purpose
      Cryptography API: Next Generation (CNG) is Microsoft's long-term replacement for their CryptoAPI.  CNG is designed to be extensible at many levels and cryptography agnostic in behavior.  Although the Crypt.au3 UDF that is installed with AutoIt3 still works perfectly, the advapi32.dll functions that it uses have been deprecated.  This UDF was created to offer a replacement for the deprecated functions.  According to Microsoft, deprecated functions may be removed in future release.  Therefore, this UDF will be available when/if that happens.
      Description
      This UDF implements some of Microsoft's Cryptography API: Next Generation (CNG) Win32 API functions.  In its initial release, it implements functions to encrypt text & files, decrypt text and files, generate hashes, and the Password-Based Key Derivation Function 2 (PBKDF2) function.  The UDF can implement any of the encryption/decryption algorithms or hashing algorithms that are installed on the PC in which it is running.  Most, if not all, of the values that you would commonly use to specify that desired algorithms, key bit lengths, and other magic number type values, are already defined as constants or enums in the UDF file.
      To flatten the learning curve, there is an example file that shows examples of all of the major functionality.  This example file is not created to be an exhaustive set of how to implement each feature and parameter.  It is designed to give you a template or guide to help you hit the ground running in terms of using the functions.  I have tried to fully document the headers of all of the functions as well as the code within the functions themselves.    As of v1.4.0, there is also a Help file that includes all of the functions, with examples.
      Current UDF Functions
      _CryptoNG_3DES_CBC_DecryptData _CryptoNG_3DES_CBC_DecryptFile _CryptoNG_3DES_CBC_EncryptData _CryptoNG_3DES_CBC_EncryptFile _CryptoNG_AES_CBC_DecryptData _CryptoNG_AES_CBC_DecryptFile _CryptoNG_AES_CBC_EncryptData _CryptoNG_AES_CBC_EncryptFile _CryptoNG_CreateRSAKeyPair _CryptoNG_DecryptData _CryptoNG_DecryptFile _CryptoNG_EncryptData _CryptoNG_EncryptFile _CryptoNG_EnumAlgorithms _CryptoNG_EnumRegisteredProviders _CryptoNG_GenerateRandom _CryptoNG_HashData _CryptoNG_HashFile _CryptoNG_LastErrorMessage _CryptoNG_PBKDF2 _CryptoNG_Version  
      Related Links
      Cryptography API: Next Generation - Main Page
      Cryptography API: Next Generation - Reference
      Cryptography API: Next Generation - Primitives
      Cryptography API: Next Generation - Cryptographic Algorithm Providers
    • By RTFC
      MetaCode offers a way to:
      separate a script's structure from its content remove all redundant definitions (globals and UDFs) change any content (and some structure) combine (new) structure and (new) content into a new script The most useful applications implemented so far are:
      Fast language translation (not just text strings, also variable names and UDF names) Obfuscation (vars and/or UDFs) Script Encryption (conditionals, calls, and macros) Encryption is powerful because the key is not stored anywhere; you can define it to be a user password, macro, environment spec/variable, server response, something you define yourself, or a combination thereof; anything goes, as long as it's not a fixed string or fixed value. More info in the CodeCrypter thread: ?do=embed' frameborder='0' data-embedContent>'?do=embed' frameborder='0' data-embedContent>>
      ?do=embed' frameborder='0' data-embedContent>
      But MetaCode has more potential than that; it allows you to tinker with any type of content separately, then rebuild a new version. So for example, you can have a single script structure and numerous different language modules you just plug in to create a new version in a different language.
      A brief Tutorial is here: MetaCode Tutorial.pdf
      The MCF library itself can be found in the CodeScannerCrypter bundle.
      And a little example how to use it for translating your GUI into a different language:
       UI_Translator.7z (new version that should work with the new version of Google Translate, see post #13 below)
       
       
      MCF.au3 is just the library plus the MCFinclude.au3 file you need to include in any script you wish to encrypt.
      There is no GUI here. However, I did write a separate front-end for it called CodeCrypter, which you can find here:
      ?do=embed' frameborder='0' data-embedContent>'?do=embed' frameborder='0' data-embedContent>>
      ?do=embed' frameborder='0' data-embedContent>
      MCF uses output generated by my CodeScanner version 2.8+, which you can find here:
      '?do=embed' frameborder='0' data-embedContent>>
      CodeScanner also depends on MCF.au3 now, as it can now call a few of its functions.
      I should also mention Ward's excellent AES.au3 UDFs used for the encryption and decryption calls,  which is now included in the CodeScannerCrypter bundle (thanks to Ward for allowing to include it). You can find the original (unpatched) version here:
      '?do=embed' frameborder='0' data-embedContent>>
      Note: you can replace the encryption/decryption calls with whatever algorithm you like (hint: the native <Crypt.au3> library is too slow for most purposes, better stick to machine code routines)
      So just to be clear:
      CodeScanner (v2.8+) needs MCF (earlier versions won't work!) CodeCrypter needs MCF (plus anything that MCF needs) MCF itself needs MCFinclude (part of MCF zip) MCF also needs readCSdatadump (part of the CodeScanner package, you need the latest version packaged with CodeScanner v2.8; earlier versions won't work!) both MCF and MCFinclude currently rely on AES.au3 by Ward So you basically need to download the whole bundle for any of it to work.
       
      If you have any questions, please start by reading the MCF Tutorial and the CodeCrypter FAQ (you can download the latter separately from the CodeCrypter thread).
      Next, read the extensive Remarks sections in MCF.au3, MCFinclude.au3, and CodeCrypter.au3
      If still no joy, then please post. However, I'm not online that often, and logged in to the forum even less, so response may take a while).
      RT
×
×
  • Create New...