giangnguyen

Public Private Key encryption?

18 posts in this topic

Anybody knows how I can apply Public-Private Key encryption? I found several threads but they are all outdated 

Any ideas? I don't think it is included in advapi32 either, which is used by AutoIt atm

Share this post


Link to post
Share on other sites



Bump, still needing this. 

Share this post


Link to post
Share on other sites

_Crypt_EncryptFile() and _Crypt_DecryptFile()  not working ?

or you mean is create Public Key and Private Keys (.cer, .pvk, .pfx) from MakeCert.exe, pvk2pfx.exe and SignTool.exe ?


“The world won’t care about your self-esteem. The world will expect you to accomplish something Before you feel good about yourself.”

Share this post


Link to post
Share on other sites

Maybe you mean PGP / GPG ?


ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button:

Spoiler

Last update: 2016-12-23
Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft Components * TeamViewer API -UDF * JavaManagement UDF * VIES over SOAPPOP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF * WinSCP UDF *

My contribution to others projects: * _sql.au3 UDF  *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities *

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, The Art of Computer Programming
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

 

Share this post


Link to post
Share on other sites
On 2.6.2016 at 5:52 AM, giangnguyen said:

I found several threads but they are all outdated 

Are  there any changes in logic. I think no, so you have to read the changelog and update the found source to actual stable or to wait until some one else needs it and is so kind to share.

Share this post


Link to post
Share on other sites

ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button:

Spoiler

Last update: 2016-12-23
Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft Components * TeamViewer API -UDF * JavaManagement UDF * VIES over SOAPPOP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF * WinSCP UDF *

My contribution to others projects: * _sql.au3 UDF  *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities *

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, The Art of Computer Programming
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

 

Share this post


Link to post
Share on other sites

Generate keys.  Keep Private key. Distribute public key. Compare keys on demand.

Perhaps your question is not clearly defined?


Skysnake

Why is the snake in the sky?

Share this post


Link to post
Share on other sites

Like _Crypt_DecryptData but with RSA encryption and decryption. That is my goal here.

Share this post


Link to post
Share on other sites

 

 

 

o_0

 

 


“The world won’t care about your self-esteem. The world will expect you to accomplish something Before you feel good about yourself.”

Share this post


Link to post
Share on other sites

I'm pretty much interested in RSA Functionality in AutoIt, however, these old links provided from @Trong are either outdated, unreadable or there's simply no correct help.

When I use

https://www.autoitscript.com/forum/topic/104025-rsa-publicprivate-encryption/

$CALG_RSA_KEYX = 0x0000a400 ; RSA public key exchange algorithm.
$CALG_RSA_SIGN = 0x00002400 ; RSA public key signature algorithm.

with the provided encryption tool from AutoIt install itself and encrypt any string, I get "-1" as output and when decrypting I get "ÿÿÿÿ" (0xFFFFFFFF).

I'm probably doing something wrong there, but can't get my finger on what...

Which led me to the same problem this user had:

Problem
https://www.autoitscript.com/forum/topic/151577-rsa-algorithm/#comment-1085259

User who linked the site below
https://www.autoitscript.com/forum/topic/151577-rsa-algorithm/?page=2#comment-1085384

Russian _RSA_crypt
http://autoit-script.ru/index.php/topic,8343.msg56412.html#msg56412

And when I continued reading, the last post of that thread leads me to an _RSA_Crypt function, which is completely on russian and so totally unreadable...

Best of it, the file is locked in Dropbox because of traffic...

 

The last one is the tool from peethebee, which sadly used a removed function in AutoIt. It's "PluginOpen" and "PluginClose".

https://www.autoitscript.com/forum/topic/40776-rsa-encryption-plugin/

That site is broken with his RSA.dll, which isn't downloadable anymore from autoit.de, but I could extract the broken text.


#include
#include "bigint.h"

#include

#include

#include

#include "au3plugin.h"

using namespace std;

#define RBI RossiBigInt

/*

*

* AutoIt v3 Plugin RSA

*

* Copyright © 1999-2006 Jonathan Bennett

* Copyright © 2006-2007 peethebee

* The rules of GPL apply to this work!

*

* RSA.c

*

*/

/****************************************************************************

* Function List

*

* This is where you define the functions available to AutoIt. Including

* the function name (Must be the same case as your exported DLL name), the

* minimum and maximum number of parameters that the function takes.

*

****************************************************************************/

/* "FunctionName", min_params, max_params */

AU3_PLUGIN_FUNC g_AU3_Funcs[] =

{

{"RSA_GenerateKeys", 3, 3},

{"RSA_Encrypt", 2, 2},

{"RSA_Decrypt", 2, 2}

};

/****************************************************************************

* AU3_GetPluginDetails()

*

* This function is called by AutoIt when the plugin dll is first loaded to

* query the plugin about what functions it supports. DO NOT MODIFY.

*

****************************************************************************/

AU3_PLUGINAPI int AU3_GetPluginDetails(int *n_AU3_NumFuncs, AU3_PLUGIN_FUNC **p_AU3_Func)

{

/* Pass back the number of functions that this DLL supports */

*n_AU3_NumFuncs	= sizeof(g_AU3_Funcs)/sizeof(AU3_PLUGIN_FUNC);

/* Pack back the address of the global function table */

*p_AU3_Func = g_AU3_Funcs;

return AU3_PLUGIN_OK;

}

/****************************************************************************

* DllMain()

*

* This function is called when the DLL is loaded and unloaded. Do not

* modify it unless you understand what it does...

*

****************************************************************************/

BOOL WINAPI DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)

{

switch (ul_reason_for_call)

{

case DLL_PROCESS_ATTACH:

case DLL_THREAD_ATTACH:

case DLL_THREAD_DETACH:

case DLL_PROCESS_DETACH:

break;

}

return TRUE;

}

RBI euklid(RBI a, RBI :whistle: {

RBI h;

while (b != RBI(0)) {

h = a % b;

a = b;

b = h;

}

return a;

}

RBI _minus_mod(RBI a, RBI b, RBI m) {

if (a > :) {

return (a- :lol: % m;

} else {

return m - (b-a) % m;

}

}

RBI extended_euclid(RBI a, RBI n) {

RBI v3(n);

RBI g(a);

RBI v1(0);

RBI t1(1);

RBI t3;

RBI temp;

RBI q;

do {

q = g / v3;

t3 = g % v3;

if (t3 > RBI(0)) {

q = (v1*q) % n;

q = _minus_mod(t1, q, n);

t1=v1;

v1=q;

g=v3;

v3=t3;

}

} while (t3 != RBI(0));

return v1;

}

RBI fast_exp(RBI b, RBI e) {

RBI result(1);

// Ist die aktuelle Bitstelle von e gesetzt (1),

// das Ergebnis mit b multiplizieren.

while (e > RBI(0)) {

if ((e & RBI(1)) == RBI(1)){

result = (result * :) ;

}

// den Exponenten in der Binärdarstellung um

// 1 nach rechts verschieben, sodass der nächste

// Durchlauf die nächste Bitstelle bearbeitet.

e >>= 1;

// b quadrieren, da es an der nächsten Bitstelle

// eine entsprechend höhere Wertigkeit hat.

b = b * b;

}

return result;

}

RBI fast_exp_mod(RBI b, RBI e, RBI m) {

RBI result(1);

while (e > RBI(0)) {

// Ist die aktuelle Bitstelle von e gesetzt (1),

// dann das Quadrat der Basis zum Ergebnis addieren.

// Dabei gleich den Modulus einbeziehen, damit das

// Ergebnis nicht unnötig groß wird.

if ((e & RBI(1)) == RBI(1)){

result = (result * :( ;

result = (result % m);

}

// den Exponenten in der Binärdarstellung um

// 1 nach rechts verschieben, sodass der nächste

// Durchlauf die nächste Bitstelle bearbeitet.

e >>= 1;

// b quadrieren, da es an der nächsten Bitstelle

// eine entsprechend höhere Weritgkeit hat.

b = (b * B) % m;

}

return result;

}

/*

int miller_rabin_is_prime(RBI n, int steps) {

long small_primes[10] = {2,3,5,7,11,13,17,19,23,29};

RBI d, a, t, y;

d = n-RBI(1);

while (RBI(d & RBI(1)) == RBI(0)) {

d >>= 1;

}

for (int b=0;b

a = RBI(small_primes);

t = d;

y = fast_exp_mod(a,t,n);

while (t != n-RBI(1) && y != RBI(1) && y != n-RBI(1)) {

y = (y * y) % n;

t <<= 1;

}

//if (y != n-RBI(1) && RBI(t & RBI(1)) == RBI(0)) return 1;

if ((y != n-RBI(1)) && (RBI(t & RBI(1)) == RBI(0))) {

MessageBox(NULL, "nicht prim", "MR", MB_OK);

return 1;

}

}

MessageBox(NULL, "prim", "MR", MB_OK);

return 0;

}*/

int witness(RBI n, RBI a) {

MessageBox(NULL, "witness", "anfang", MB_OK);

RBI t, u, x, y, i;

for(t = RBI(0); ((n - RBI(1)) & (fast_exp(RBI(2),(t+RBI(1))))) == RBI(0); t++); //My hack way of finding t and u

u = (n - RBI(1)) / (fast_exp(RBI(2), t)); //such that 2^t * u = n - 1 where u is odd

y = fast_exp_mod(a, u, n); //This is described in the next section

for(i = RBI(1); i <= t; i++) {

x = (y * y) % n;

if((x == RBI(1)) && (y != RBI(1)) && (y != (n - RBI(1)))) {

MessageBox(NULL, "oben", "return 1", MB_OK);

return 1;

}

}

if(x != RBI(1)) {

MessageBox(NULL, "unten", "return 1", MB_OK);

return 1;

}

return 0;

}

int miller_rabin_is_prime(RBI n, int s) {

long small_primes[10] = {2,3,5,7,11,13,17,19,23,29};

if(n == RBI(3))

return 1;

RBI a;

int j;

for(j = 0; j < s; j++) {

a = RBI(small_primes[j]);

if(witness(n, a)) {

MessageBox(NULL, "nicht prim", "MR", MB_OK);

return 0;

}

}

MessageBox(NULL, "prim", "MR", MB_OK);

return 1;

}

int fermat_is_prime(RBI n) {

RBI result2(0);

RBI result3(0);

RBI result5(0);

// Fermattest mit Basis 2

result2 = fast_exp_mod(RBI(2), n - RBI(1), n);

// Fermattest mit Basis 3

result3 = fast_exp_mod(RBI(3), n - RBI(1), n);

// Fermattest mit Basis 5

result5 = fast_exp_mod(RBI(5), n - RBI(1), n);

// Das probabilistische Ergebnis zurückgeben.

// Rückgabewert 1 steht für wahrscheinlich prim,

// Rückgabewert 0 steht für sicher nicht prim.

return (result2 == RBI(1) && result3 == RBI(1) &&

result5 == RBI(1)) ? 1:0;

}

RBI find_prime_number(double bitlength){

int fermat_res = 0;

RBI rand_nr;

// Zufallszahl berechnen

srand(time(NULL));

//gewünschte Bitlänge herstellen

RBI minimum_value(fast_exp(RBI(2), RBI(bitlength)));

do {

// Zufallszahl generieren

rand_nr = RBI(rand());

rand_nr = (fast_exp(rand_nr, RBI(4))+RBI(1)) % (fast_exp(RBI(2),

RBI(bitlength-1)) + 1);

// Summe aus 2 hoch Bitlänge und Zufallszahl bilden und

// Ergebnis auf Primalität testen

fermat_res = fermat_is_prime(minimum_value + RBI(rand_nr));

} while (fermat_res == 0);

// wenn Fermat keine zusammengesetzte Zahl erkannt hat,

// dann Zahl als Primzahl zurückliefern

return minimum_value + RBI(rand_nr);

}

AU3_PLUGIN_DEFINE(RSA_GenerateKeys)

{

AU3_PLUGIN_VAR	*pMyResult;

double key_bitlength;

key_bitlength = AU3_GetDouble(&p_AU3_Params[0]);

//miller_rabin_is_prime(RBI(key_bitlength), 2);

string keypath;

keypath = AU3_GetString(&p_AU3_Params[1]);

//keypath = keypath::replace("\\", "\\\\" );

string keyname;

keyname = AU3_GetString(&p_AU3_Params[2]);

// Zwei Primzahlen p und q suchen

RBI p(find_prime_number(key_bitlength / 2));

RBI q;

// Sicherstellen, dass p ungleich q

do {

q = find_prime_number(key_bitlength / 2);

}

while (q == p);

// n berechnen

RBI n(p * q);

// phi(n) berechnen:

RBI phi((p - RBI(1)) * (q - RBI(1)));

// e setzen

RBI e;

e = RBI(65537); //RBI(fast_exp(RBI(2), RBI(16))+1);

// d berechnen

srand(time(NULL));

RBI d = extended_euclid(e, phi);

// öffentlichen Schlüssel in eine Datei schreiben

string pubpath=keypath + keyname + ".pubkey";

ofstream pubkeyfile;

pubkeyfile.open(pubpath.c_str());

pubkeyfile << n;

pubkeyfile << "\n";

pubkeyfile << e;

pubkeyfile << "\n";

pubkeyfile << key_bitlength << " bit";

pubkeyfile << "\n";

pubkeyfile << "";

pubkeyfile.close();

// privaten Schlüssel in eine Datei schreiben

string privpath=keypath + keyname + ".privkey";

ofstream privkeyfile;

privkeyfile.open(privpath.c_str());

privkeyfile << n;

privkeyfile << "\n";

privkeyfile << d;

privkeyfile << "\n";

privkeyfile << key_bitlength << " bit";

privkeyfile << "\n";

privkeyfile << "";

privkeyfile.close();

/* Ergebnisse in Datei ausgeben

string logpath="C:\\rsa.log";

ofstream logfile;

logfile.open(logpath.c_str());

logfile << "RSA-Schluesselgenerierung" << endl << endl;

logfile << "p: " << p << endl;

logfile << "q: " << q << endl;

logfile << "n: " << n << endl;

logfile << "phi(n): " << phi << endl;

logfile << "e: " << e << endl;

logfile << "d: " << d << endl;

logfile << "de mod phi: " << (RBI(d)*e) % phi << endl << endl;

logfile << "Schluessel gespeichert als " << keyname <<

".privkey und " << keyname << ".pubkey im Ordner " <<

keypath << endl;

logfile.close();*/

pMyResult = AU3_AllocVar();

AU3_SetInt32(pMyResult, 1);

*p_AU3_Result	= pMyResult;

*n_AU3_ErrorCode	= 0;

*n_AU3_ExtCode	= 0;

return AU3_PLUGIN_OK;

}

AU3_PLUGIN_DEFINE(RSA_Encrypt)

{

AU3_PLUGIN_VAR *pMyResult;

pMyResult = AU3_AllocVar();

string text;

text = AU3_GetString(&p_AU3_Params[0]);

string keyfilename;

keyfilename = AU3_GetString(&p_AU3_Params[1]);

//keyfilename = string_replace(keyfilename, "\\", "\\\\");

//MessageBox(NULL, text.c_str(), keyfilename.c_str(), MB_OK);

// öffentlichen Schlüssel auslesen

ifstream pubkeyfile;

string line;

pubkeyfile.open(keyfilename.c_str());

// erste Zeile auslesen und gleich n setzen

getline(pubkeyfile, line);

RBI n(line, 10);

// zweite Zeile auslesen und gleich e setzen

getline(pubkeyfile, line);

RBI e(line, 10);

// Plaintext zeichenweise durchgehen

// immer 2 Zeichen sammeln um eine einfache

// Blockchiffre umzusetzen

//MessageBox(NULL, text.c_str(), keyfilename.c_str(), MB_OK);

string res_str;

// Stringlänge auf geraden Wert bringen

if (text.length() % 2 == 1) {text = text + " ";}

for (int i=0;i

// ASCII-Code der Zeichens berechnen

int mi1 = int(text);

int mi2 = int(text[i+1]);

// Verkettung

RBI mi;

mi = RBI(mi2) * fast_exp(RBI(2), RBI(7)) + RBI(mi1);

// Eigentliche Verschlüsselung

RBI ci(fast_exp_mod(mi, e, n));

// Ergebnis anhängen (als Hex-Wert, mit Trennzeichen #)

res_str = res_str + ci.getstr_pure_hex_value() + "#";

}


/* Ergebnis in eine temporäre Datei schreiben

MessageBox(NULL, "test", "test", MB_OK);

string tempfile="C:\\rsa.enc";

ofstream encfile;

encfile.open(tempfile.c_str());

encfile << res_str;

encfile.close(); */


//AU3_SetString(pMyResult, res_str.c_str());

//MessageBox(NULL, res_str.c_str(), "test", MB_OK);

AU3_SetString(pMyResult, res_str.c_str());

//MessageBox(NULL, "test", "test", MB_OK);


*p_AU3_Result	= pMyResult;

*n_AU3_ErrorCode	= 0;

*n_AU3_ExtCode	= 0;

//MessageBox(NULL, "test", "test", MB_OK);


return AU3_PLUGIN_OK;

}



AU3_PLUGIN_DEFINE(RSA_Decrypt)

{

AU3_PLUGIN_VAR	*pMyResult;

pMyResult = AU3_AllocVar();

string text;

text = AU3_GetString(&p_AU3_Params[0]);

string keyfilename;

keyfilename = AU3_GetString(&p_AU3_Params[1]);

//keyfilename = string_replace(keyfilename, "\\", "\\\\");


//MessageBox(NULL, text.c_str(), "test", MB_OK);

//MessageBox(NULL, keyfilename.c_str(), "test", MB_OK);


// privaten Schlüssel auslesen

ifstream privkeyfile;

string line;

privkeyfile.open(keyfilename.c_str());

// erste Zeile auslesen und gleich n setzen

getline(privkeyfile, line);

RBI n(line, 10);

// zweite Zeile auslesen und gleich d setzen

getline(privkeyfile, line);

RBI d(line, 10);


// Ciphertext an Trennzeichen spalten

string res_str;

string collect_string;

for (int i=0;i

if (text == '#') {

// Entschlüsselung

RBI mi(fast_exp_mod(RBI(collect_string, 16), d, n));

// beide Zeichen aus mi extrahiere

RBI mi1;

RBI mi2;

mi1 = mi % fast_exp(RBI(2), RBI(7));

mi2 = mi / fast_exp(RBI(2), RBI(7));

// mi1 und mi2 an Ergebnis-String anhängen

res_str = res_str + (char)mi1.get_pure_ulong();

res_str = res_str + (char)mi2.get_pure_ulong();

// Sammel-String wieder leeren

collect_string = "";

} else {

// Zeichen ist noch Teil des Blockes

collect_string = collect_string + text;

}

}


/* Ergebnis in eine temporäre Datei schreiben

string tempfile="C:\\rsa.dec";

ofstream decfile;

decfile.open(tempfile.c_str());

decfile << res_str;

decfile.close();*/


AU3_SetString(pMyResult, res_str.c_str());

*p_AU3_Result	= pMyResult;

*n_AU3_ErrorCode	= 0;

*n_AU3_ExtCode	= 0;


return AU3_PLUGIN_OK;

Since I don't know how to build DLL's, I'd like to ask some of you people to do this and provide a help, how to do DllCalls for this C++ code.

 

Share this post


Link to post
Share on other sites

AutoIt plugin support has been abandonned long ago.

 


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

Need to convert the plugins things

; author Neonium - DLL by peethebee
#include <GUIConstants.au3>

PluginOpen("rsa.dll")
#AutoIt3Wrapper_plugin_funcs = RSA_GenerateKeys, RSA_Decrypt, RSA_Encrypt

Opt("GUIOnEventMode", 1)

$Form1_1 = GUICreate("RSA Encryption", 347, 275, 193, 115)
GUISetOnEvent($GUI_EVENT_CLOSE, "AForm1_1Close")
$tab = GUICtrlCreateTab(10, 10, 325, 260)
$tab0 = GUICtrlCreateTabItem("File")
$vschluessel = GUICtrlCreateButton("Crypt", 40, 230, 115, 25, 0)
GUICtrlSetOnEvent(-1, "vschluesselClick")
$nschluessel = GUICtrlCreateButton("Decrypt", 180, 230, 115, 25, 0)
GUICtrlSetOnEvent(-1, "nschluesselClick")
$Public = GUICtrlCreateLabel("PublicKey File", 20, 124, 70, 17)
$Priv = GUICtrlCreateLabel("PrivateKey File", 20, 152, 74, 17)
$PrivFile = GUICtrlCreateInput("", 104, 152, 117, 21)
$Pubfile = GUICtrlCreateInput("", 104, 120, 117, 21)
$BrowsePub = GUICtrlCreateButton("Browse", 236, 120, 89, 25, 0)
GUICtrlSetOnEvent(-1, "BrowsePubClick")
$BrowsePrv = GUICtrlCreateButton("Browse", 236, 152, 89, 25, 0)
GUICtrlSetOnEvent(-1, "BrowsePrvClick")
$BrowseDat = GUICtrlCreateButton("Browse", 236, 52, 89, 25, 0)
GUICtrlSetOnEvent(-1, "BrowseDatClick")
$Label1 = GUICtrlCreateLabel("File to crypt", 28, 37, 168, 17)
$Datei = GUICtrlCreateInput("", 28, 56, 197, 21)
$privfilegen = GUICtrlCreateButton("Key Files Generator", 100, 190, 125, 25, 0)
GUICtrlSetOnEvent(-1, "privfilegenClick")

$tab1 = GUICtrlCreateTabItem("Password")

$vschluesselp = GUICtrlCreateButton("Crypt", 40, 230, 115, 25, 0)
GUICtrlSetOnEvent(-1, "vschluesselpClick")
$nschluesselp = GUICtrlCreateButton("Decrypt", 180, 230, 115, 25, 0)
GUICtrlSetOnEvent(-1, "nschluesselpClick")
$Publicp = GUICtrlCreateLabel("PublicKey File", 20, 124, 70, 17)
$Privp = GUICtrlCreateLabel("PrivateKey File", 20, 152, 74, 17)
$PrivFilep = GUICtrlCreateInput("", 104, 152, 117, 21)
$Pubfilep = GUICtrlCreateInput("", 104, 120, 117, 21)
$BrowsePubp = GUICtrlCreateButton("Browse", 236, 120, 89, 25, 0)
GUICtrlSetOnEvent(-1, "BrowsePubpClick")
$BrowsePrvp = GUICtrlCreateButton("Browse", 236, 152, 89, 25, 0)
GUICtrlSetOnEvent(-1, "BrowsePrvpClick")
$privfilegenp = GUICtrlCreateButton("Key Files Generator", 100, 190, 125, 25, 0)
GUICtrlSetOnEvent(-1, "privfilegenClick")
$Label1p = GUICtrlCreateLabel("Password clear", 60, 37, 200, 17)
$Dateip = GUICtrlCreateInput("", 60, 56, 197, 21)
$Label2p = GUICtrlCreateLabel("Password crypted:", 60, 78, 200, 17)
$pwp = GUICtrlCreateInput("", 60, 93, 197, 21)
$clipputp = GUICtrlCreateButton("Copy", 265, 93, 60, 21)
GUICtrlSetOnEvent(-1, "clipputpClick")

GUISetState(@SW_SHOW)

$var = IniRead(@WorkingDir & "\file.ini", "privkey", "key", "")
GUICtrlSetData($PrivFile, $var)
$var = IniRead(@WorkingDir & "\file.ini", "pubkey", "key", "")
GUICtrlSetData($Pubfile, $var)
$var = IniRead(@WorkingDir & "\file.ini", "privkeyp", "key", "")
GUICtrlSetData($PrivFilep, $var)
$var = IniRead(@WorkingDir & "\file.ini", "pubkeyp", "key", "")
GUICtrlSetData($Pubfilep, $var)

While 1
    $msg = GUIGetMsg()

    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    If $msg = $tab Then
        ; display the clicked tab
        If GUICtrlRead($tab) = 0 Then WinSetTitle("My GUI Tab", "", "My GUI Tab0")
        If GUICtrlRead($tab) = 1 Then WinSetTitle("My GUI Tab", "", "My GUI Tab1")
    EndIf
WEnd

Func AForm1_1Close()
    $readpriv = GUICtrlRead($PrivFile)
    $readpub = GUICtrlRead($Pubfile)
    $readprivp = GUICtrlRead($PrivFilep)
    $readpubp = GUICtrlRead($Pubfilep)

    IniDelete(@ScriptDir & "\file.ini", "privkeyp")
    IniDelete(@ScriptDir & "\file.ini", "pubkeyp")
    IniDelete(@ScriptDir & "\file.ini", "privkey")
    IniDelete(@ScriptDir & "\file.ini", "pubkey")

    If $readpriv <> "" Then
        IniWrite(@ScriptDir & "\file.ini", "privkey", "key", $readpriv)
    EndIf
    If $readpub <> "" Then
        IniWrite(@ScriptDir & "\file.ini", "pubkey", "key", $readpub)
    EndIf

    If $readprivp <> "" Then
        IniWrite(@ScriptDir & "\file.ini", "privkeyp", "key", $readprivp)
    EndIf
    If $readpubp <> "" Then
        IniWrite(@ScriptDir & "\file.ini", "pubkeyp", "key", $readpubp)
    EndIf
    Exit
EndFunc   ;==>AForm1_1Close

Func BrowseDatClick()
    $readdatei = GUICtrlRead($Datei)
    $var = FileOpenDialog("Datei", $readdatei, "Text (*.txt)", 1)
    GUICtrlSetData($Datei, $var)
EndFunc   ;==>BrowseDatClick

Func BrowsePrvClick()
    $readpriv = GUICtrlRead($PrivFile)
    $var = FileOpenDialog("Datei", $readpriv, "Private (*.privkey)", 1)
    GUICtrlSetData($PrivFile, $var)
EndFunc   ;==>BrowsePrvClick

Func BrowsePubClick()
    $readpub = GUICtrlRead($Pubfile)
    $var = FileOpenDialog("Datei", $readpub, "Public (*.pubkey)", 1)
    GUICtrlSetData($Pubfile, $var)
EndFunc   ;==>BrowsePubClick

Func nschluesselClick()
    $readpriv = GUICtrlRead($PrivFile)
    $read = GUICtrlRead($Datei)
    If $readpriv = "" Or $read = "" Then
        MsgBox(0, "ERROR", "Please select only the key files")
    Else
        FileMove($read, "c:\tmp\test.txt")
        FileChangeDir("C:\tmp")
        $file = FileOpen("test.txt", 0)
        If $file = -1 Then
            MsgBox(0, "Error", "Unable to open file.")
            Exit
        EndIf
        $line = FileRead($file)
        FileClose($file)
        $line = RSA_Decrypt($line, $readpriv)
        $file = FileOpen("test.txt", 2)
        FileWrite($file, $line)
        FileClose($file)
        FileMove("C:\tmp\test.txt", $read)
        MsgBox(0, "", "Successful")
    EndIf
EndFunc   ;==>nschluesselClick

Func vschluesselClick()
    $readpub = GUICtrlRead($Pubfile)
    $read = GUICtrlRead($Datei)
    If $readpub = "" Or $read = "" Then
        MsgBox(0, "ERROR", "Please select only the key files")
    Else
        FileMove($read, "C:\tmp\test.txt")
        FileChangeDir("C:\tmp")
        $file = FileOpen("test.txt", 0)
        If $file = -1 Then
            MsgBox(0, "Error", "Unable to open file.")
            Exit
        EndIf
        $line = FileRead($file)
        FileClose($file)
        $line = RSA_Encrypt($line, $readpub)
        $file = FileOpen("test.txt", 2)
        FileWrite($file, $line)
        FileClose($file)
        FileMove("C:\tmp\test.txt", $read)
        MsgBox(0, "Successful", "Encrypted success")
    EndIf
EndFunc   ;==>vschluesselClick

Func privfilegenClick()
    $folder = FileSelectFolder("Keyfiles Location", Default, 1)
    $folder = $folder & "\"
    $bitlen = InputBox("Bit length", "Key bit length", "50")
    $name = InputBox("Store name", "Memory name Keyfiles")
    If $folder <> "" And $name <> "" And $bitlen <> "" Then
        RSA_GenerateKeys($bitlen, $folder, $name)
        MsgBox(0, "Successful", "Keys were created successfully")
    Else
        MsgBox(0, "Error", "Please provide all information")
    EndIf
EndFunc   ;==>privfilegenClick

Func BrowsePrvpClick()
    $readpriv = GUICtrlRead($PrivFilep)
    $var = FileOpenDialog("Datei", $readpriv, "Private (*.privkey)", 1)
    GUICtrlSetData($PrivFilep, $var)
EndFunc   ;==>BrowsePrvpClick

Func BrowsePubpClick()
    $readpub = GUICtrlRead($Pubfilep)
    $var = FileOpenDialog("Datei", $readpub, "Public (*.pubkey)", 1)
    GUICtrlSetData($Pubfilep, $var)
EndFunc   ;==>BrowsePubpClick

Func nschluesselpClick()
    $readpriv = GUICtrlRead($PrivFilep)
    $read = GUICtrlRead($pwp)
    If $readpriv = "" Or $read = "" Then
        MsgBox(0, "ERROR", "Please select only the key files")
    Else
        $pw = RSA_Decrypt($read, $readpriv)
        GUICtrlSetData($Dateip, $pw)
    EndIf
EndFunc   ;==>nschluesselpClick

Func vschluesselpClick()
    $readpub = GUICtrlRead($Pubfilep)
    $read = GUICtrlRead($Dateip)
    If $readpub = "" Or $read = "" Then
        MsgBox(0, "ERROR", "Please select only the key files")
    Else
        $pw = RSA_Encrypt($read, $readpub)
        GUICtrlSetData($pwp, $pw)
    EndIf
EndFunc   ;==>vschluesselpClick

Func clipputpClick()
    ClipPut(GUICtrlRead($pwp))
EndFunc   ;==>clipputpClick

 

RSA.dll


Nothing is so strong as gentleness. Nothing is so gentle as real strength

 

Share this post


Link to post
Share on other sites
22 hours ago, jchd said:

AutoIt plugin support has been abandonned long ago.

 

Yeah, that's what I wrote in my reply above.

Now the only problem is (Terenz already wrote), how does one now convert the PluginOpen/Close functions to DLLCalls? It needs documentation.

Share this post


Link to post
Share on other sites

Here is an example showing some other concepts:

Indeed it is using crypto card, but I believe that using Certificate Enrollment API  you can do what you need, all is a matter of your own involmend.


ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button:

Spoiler

Last update: 2016-12-23
Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft Components * TeamViewer API -UDF * JavaManagement UDF * VIES over SOAPPOP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF * WinSCP UDF *

My contribution to others projects: * _sql.au3 UDF  *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities *

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, The Art of Computer Programming
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

 

Share this post


Link to post
Share on other sites

Still needing this.

mLipok, I think your script basically prints out the detail of a certificate? Not sure how that helps, since I am not signing but encrypting and decrypting to secure data (since autoit is easily decompiled, and therefore AES keys can be stolen. However RSA can't because it is public/private key)

Share this post


Link to post
Share on other sites

Still needing this, please help me!

Share this post


Link to post
Share on other sites
On 11.6.2016 at 3:01 PM, mLipok said:

Indeed it is using crypto card, but I believe that using Certificate Enrollment API  you can do what you need, all is a matter of your own involmend.

What are the issue by coding a test script using the Certificate Enrollment API? Please show script. Or is there any  Oozlum bird that eaten your script and fly away?

Share this post


Link to post
Share on other sites

So reading here:

About the Certificate Enrollment API

Quote

The Certificate Enrollment API enables you to create client applications that can be used to request and install certificates.

There is nothing about singnig/encrypting.

 

After some diging I comes to this:
Cryptography API: Next Generation
About CNG
Encrypting Data with CNG

Please check this above links and say what you think.

 


ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button:

Spoiler

Last update: 2016-12-23
Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft Components * TeamViewer API -UDF * JavaManagement UDF * VIES over SOAPPOP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF * WinSCP UDF *

My contribution to others projects: * _sql.au3 UDF  *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities *

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, The Art of Computer Programming
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

 

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

  • Similar Content

    • AlecSadler
      By AlecSadler
      Hello all, I would like to present my proof of concept work to the autoit forum and community. (I saw this as a concept in a few sci-fi shows and thought I would bring it into real life)
      What is it?: DARTIS (Dimensions And Relative Time Information System)© is a 4 dimensional holographic encryption algorithm which uses the current timestamp(measured down to femto seconds) to encrypt data under several layers of calculations. One large keyfile is used and multiple keys are extracted from it, and overlaid on each other to create 1,000,000,000,000,000  unique keys per second. Special thanks to the creator of the matrix maths udf (if this is you please let me know and I will put your name here.) Also special thanks to trancexx for her LZNT compression code.
      Please see attached file for the full set of functions and an example debugging application, which shows usage of all the functions.
      Secure Interface Module.zip
    • Osys2010
      By Osys2010
      My RSA script, 128 bit and lower fast (for UDF attachment)
      Using :
      "RSATool2v17.exe" open and input (E) key and Keysize (Bits) "128", Generate "P, Q, D".  Copy "P, Q, D" to my code
      ; Script Start - Add your code below here #include <String.au3> #include "BigNum.au3" Global $P, $Q, $SelectBase = 64 $base64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" ;base64 ;Sexagesimal $base60_2 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwx" ;sexagesimal $base32 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567" ;base32 $base24 = "0123456789ABCDEFGHJKLMNP" ;base24 $base16 = "0123456789ABCDEF" ;hex ;Duodecimal system or dozenal $base12 = "0123456789AB" ;duodecimal $base10 = "0123456789" ;base10 $base8 = "01234567" ;oct $base2 = "01" ;binary $P = _BigNum_Add($P, "18429553113751821539") $Q = _BigNum_Add($Q, "14963134653035728619") $n = _BigNum_Mul($P, $Q) $PHI = _BigNum_Mul(_BigNum_Sub($P, 1), _BigNum_Sub($Q, 1)) $e = _NumToDec("10001100011000110001", $base16) $D = "263455903565562556840568120179103558669" ConsoleWrite(@CRLF) ConsoleWrite("P: " & NumberBase($P) & @CRLF) ConsoleWrite("Q: " & NumberBase($Q) & @CRLF) ConsoleWrite("N: " & NumberBase($n) & @CRLF) ConsoleWrite("PHI: " & NumberBase($PHI) & @CRLF & @CRLF) ConsoleWrite("D: " & NumberBase($D) & @CRLF) ConsoleWrite("E: " & NumberBase($e) & @CRLF & @CRLF) $Message = _NumToDec(_StringToHex("TEST MESSAGE"), $base16) If StringLen($Message) > StringLen($n) Then Exit (1) $c = _BigNum_PowerMod($Message, $e, $n) $D = _BigNum_PowerMod($c, $D, $n) ConsoleWrite("C: " & NumberBase($c) & @CRLF) ConsoleWrite("D: " & _HexToString(_DecToNum($D, $base16)) & @CRLF) ConsoleWrite(@CRLF) ;==================================================================================== ;~ Func modpow($a, $b, $c) ;~ $res = 1 ;~ While $b > 0 ;~ ;/* Need long multiplication else this will overflow... */ ;~ If Mod(StringRight($b, 1), 2) Then ;If BitAND($b,1) Then ;~ $res = _BigNum_Mod(_BigNum_Mul($res, $a), $c) ;~ EndIf ;~ $b = BitShift($b, 1) ;~ $a = _BigNum_Mod(_BigNum_Mul($a, $a), $c) ; /* Same deal here */ ;~ WEnd ;~ Return $res ;~ EndFunc ;==>modpow Func NumberBase($num, $base = $SelectBase) If $base = 10 Then Return _DecToNum($num, $base10) ElseIf $base = 16 Then Return _DecToNum($num, $base16) ElseIf $base = 60 Then Return _DecToNum($num, $base60_2) ElseIf $base = 64 Then Return _DecToNum($num, $base64) EndIf Return $num EndFunc ;==>NumberBase Func _DecToNum($iDec, $Symbol) Local $Out, $ost $Symbol = StringSplit($Symbol, '') If @error Or $Symbol[0] < 2 Then Return SetError(1, 0, $iDec) Do $ost = _BigNum_Mod($iDec, $Symbol[0]) $iDec = _BigNum_Div(_BigNum_Sub($iDec, $ost), $Symbol[0]) $Out = $Symbol[$ost + 1] & $Out Until Not Number($iDec) Return SetError(0, $Symbol[0], $Out) EndFunc ;==>_DecToNum Func _NumToDec($num, $sSymbol, $casesense = 1) Local $i, $iPos, $Len, $n, $Out $Len = StringLen($sSymbol) If $Len < 2 Then Return SetError(1, 0, $num) $n = StringSplit($num, '') For $i = 1 To $n[0] $iPos = StringInStr($sSymbol, $n[$i], $casesense) If Not $iPos Then Return SetError(2, 0, $num) $Out = _BigNum_Add(_BigNum_Mul($iPos - 1, _BigNum_Pow($Len, $n[0] - $i)), $Out) Next Return SetError(0, $Len, $Out) EndFunc ;==>_NumToDec ; #FUNCTION# ;==================================================================================== ; ; Name...........: _BigNum_PowerMod ; Description ...: Modular Exponentiation Mod($n^$e, $k) ; Syntax.........: _BigNum_Pow($n, $e, $k) ; Parameters ....: $n - Positive StringNumber: Digits"0"..."9" ; $e - Positive StringNumber: Exponent ; $k - Positive StringNumber: Modulus ; Return values .: Success - Result Mod($n^$e, $k) ; Failure - -1, sets @error to 1 if $n is not a positive valid StringNumber ; -1, sets @error to 2 if $e is not a positive valid StringNumber ; -1, sets @error to 3 if $k is not a positive valid StringNumber ; Author ........: jchd ; Date ..........: 17.12.13 ; Remarks .......: Fractional exponents not allowed - use BigNum_n_root instead. ; ;=============================================================================================== Func _BigNum_PowerMod($n, $e, $k) If Not __BigNum_IsValid_3($n, $e, $k) Then Return SetError(1, 0, -1) Local $res = "1" While $e <> "0" If Mod(StringRight($e, 1), 2) Then $res = _BigNum_Mod(_BigNum_Mul($res, $n), $k) $e = _BigNum_Sub($e, "1") EndIf $n = _BigNum_Mod(_BigNum_Mul($n, $n), $k) $e = _BigNum_Div($e, "2") WEnd Return $res EndFunc ;==>_BigNum_PowerMod Func __BigNum_IsValid_3($sX, $sY, $sZ) If StringRegExp($sX, "[^0-9.-]") Or StringRegExp($sY, "[^0-9.-]") Or StringRegExp($sZ, "[^0-9.-]") Then Return False Return True EndFunc ;==>__BigNum_IsValid_3  
       
      RSA 2 (TEST NOW).zip
    • RTFC
      By RTFC
      CodeCrypter enables you to encrypt scripts without placing the key inside the script.
      This is because this key is extracted from the user environment at runtime by, for example:
      password user query any macro (e.g., @username) any AutoIt function call any UDF call some permanent environment variable on a specific machine (and not created by your script) a server response a device response anything else you can think of, as long as it's not stored in the script any combination of the above You need several scripts to get this to work, and they are scattered over several threads, so here's a single bundle that contains them all (including a patched version of Ward's AES.au3; with many thanks to Ward for allowing me to include this script here):
      CodeScannerCrypter.bundle.v2.1.7z
      Note: if you experience issues under Win8/8.1 (as some users have reported), please upgrade to Win10 (or use Win7) if you can; as far as I can tell, the scripts in the bundle all work under Win7 & Win10 (and XP). Moreover, I have no access to a Win8 box, so these issues will not be fixed, at least not by yours truly.
       
      How the bits and pieces fit together:
      CodeCrypter is a front-end for the MCF UDF library (you need version 1.3 or later). Its thread is here:
      '?do=embed' frameborder='0' data-embedContent>>
      The MCF package (also contained in the CodeScannerCrypter bundle) contains MCF.au3 (the library itself) plus a little include file called MCFinclude.au3. The latter you have to include in any script you wish to encrypt. Any code preceding it will not be encrypted, any code following it will be encrypted. You define the dynamic key inside MCFinclude.au3, in the UDF: _MCFCC_Init().
      From the same post you can download an MCF Tutorial which I heartily recommend, because encrypting a script requires a number of steps in the right order, namely:
      In MCFinclude.au3, define and/or choose your dynamic key(s) (skip this step = use default setting) include MCFinclude.au3 in your target script Run CodeScanner (version 2.3+) on your target script, with setting WriteMetaCode=True (see '?do=embed' frameborder='0' data-embedContent>>), then close CodeScanner. Start CodeCrypter press the Source button to load your target file enable Write MCF0 (tick the first option in Main Settings) Enable "Encrypt" (last option in the Main Settings) Go to the Tab Encrypt and set up the encryption the way you want (skip this = use default settings) Return to Main Tab and press "Run" if all goes well, a new script called MCF0test.au3 is created in the same directory as your target. It has no includes and no redundant parts. Please check that it works as normal. (see Remarks if not) It all sounds far more complicated than it is, really.
      Not convinced? Check out this updated and extended Q & A pdf (FAQ, also included in the bundle) to help you get started:
      CodeCrypterFAQ.pdf
       
      BackTranslation is a test to check that the MetaCode translation worked. Skip it at your peril. It also turns your multi-include composite script into a single portable file without redundant parts (you can opt to leave the redundant parts in, if you want).
      CodeCrypter can also obfuscate (vars and UDF names) and replace strings, variable names and UDF names with anything else you provide, for  example, for language translation). After CodeScanner separates your target's structure from its contents, CodeCrypter (actually MCF, under the hood) can change any part, and then generate a new script from whichever pieces you define. See the MCF Tutorial for more explanation and examples.
       
      Important!
      You need the following additional scripts to get anything to work (now all included in the bundle):
      CodeScanner.au3 version 2.9+ (in the CodeScanner zip in the CodeScanner thread, link above) readCSdatadump.au3 (version 1.1+, in the CodeScanner zip) MCF.au3 (version 1.3+, in the MCF zip in the MCF thread, link above) MCFinclude.au3 (version 1.1+, in the MCF zip) AES.au3, by Ward (now also included in bundle, thanks to Ward), see '?do=embed' frameborder='0' data-embedContent>> As you can see, encryption currently relies on Ward excellent AES UDF, but you can replace this with any other algorithm you like; just edit MCFinclude.au3 UDF _MCFCC(), and MCF.au3 UDF _EncryptEntry().
      Going to lie down now...
      RT
      CodeCrypterFAQ.pdf
    • RTFC
      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.
       
      The MCF library itself can be found in the CodeScannerCrypter bundle:
      CodeScannerCrypter.bundle.v2.1.7z
       
       
      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
    • argumentum
      By argumentum
      so there is this post "Holographic Encryption with DARTIS" and the RSA came up.
      There is  _RSA_crypt.7z  from autoit-script.ru but the file is not available ( if anyone has the file, please get me a working link ) , so I don't know what or how it was done.
      My idea is to do the public key / private key (RSA) to exchange the hash/password ( call it what you will ), then, carry the rest of the communication with $CALG_AES_256 or the like. So it'd be doing a hybrid TCP/IP SSL, let's call it TCL 2.5  
      Anyhow, I need help for the simple reason that I'm quite clueless.
      CryptoAPI Cryptographic Service Providers may have a clue via the CryptoAPI ( but to me is all just words ).
      CryptEncrypt function say that: 
      The Microsoft Enhanced Cryptographic Provider supports direct encryption with RSA public keys and decryption with RSA private keys. The encryption uses PKCS #1 padding. On decryption, this padding is verified. The length of plaintext data that can be encrypted with a call to CryptEncrypt with an RSA key is the length of the key modulus minus eleven bytes. The eleven bytes is the chosen minimum for PKCS #1 padding. The ciphertext is returned in little-endian format. so it should be possible from server 2003 / XP onwards.
      Thank you all who dare to go at it