Jump to content

Asymmetric encryption & decryption RSA


Recommended Posts

Dear Autoit community ,
i done telnet via TCP socket using pure autoit , i just need to do the same but using SSH , i searched the forums but cant find any example for it using sockets ,i just found some examples using CLI blink but that not what i need . what i looking for a way to generate RSA pair of key , decrypt or encrypt data by using those keys . any idea ? 


 

Link to comment
Share on other sites

With Crypt.au3 

You can crypt decrypt with these key : 

CALG_MD2;

CALG_MD4;

CALG_MD5;

CALG_SHA1;

CALG_SHA_256;

CALG_SHA_384;

CALG_SHA_512;

CALG_3DES;

CALG_AES_128;

CALG_AES_192

CALG_AES_256;

CALG_DES;

CALG_RC2;

CALG_RC4;

PROV_RSA_FULL;

PROV_RSA_AES;
 

#include <Crypt.au3>

Local Const $sUserKey = "CryptPassword" ; Declare a password string to decrypt/encrypt the data.
Local $sData = "..upon a time there was a language without any standardized cryptographic functions. That language is no more." ; Data that will be encrypted.

Local $bEncrypted = _Crypt_EncryptData($sData, $sUserKey, $CALG_RC4) ; Encrypt the data using the generic password string.

MsgBox(0, "Crypted data", "BinaryToString"&@CRLF&BinaryToString($bEncrypted))
MsgBox(0, "Crypted data", "Nothing"&@CRLF&$bEncrypted)
MsgBox(0, "Crypted data", "StringToBinary"&@CRLF&StringToBinary($bEncrypted))

$bEncrypted = _Crypt_DecryptData($bEncrypted, $sUserKey, $CALG_RC4) ; Decrypt the data using the generic password string. The return value is a binary string.
MsgBox(0, "Decrypted data", "BinaryToString"&@CRLF&BinaryToString($bEncrypted)) ; Convert the binary string using BinaryToString to display the initial data we encrypted.
MsgBox(0, "Decrypted data", "Nothing"&@CRLF&$bEncrypted)
MsgBox(0, "Decrypted data", "StringToBinary"&@CRLF&StringToBinary($bEncrypted))

 

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to comment
Share on other sites

17 hours ago, caramen said:

With Crypt.au3 

You can crypt decrypt with these key : 

CALG_MD2;

CALG_MD4;

CALG_MD5;

CALG_SHA1;

CALG_SHA_256;

CALG_SHA_384;

CALG_SHA_512;

CALG_3DES;

CALG_AES_128;

CALG_AES_192

CALG_AES_256;

CALG_DES;

CALG_RC2;

CALG_RC4;

PROV_RSA_FULL;

PROV_RSA_AES;
 

#include <Crypt.au3>

Local Const $sUserKey = "CryptPassword" ; Declare a password string to decrypt/encrypt the data.
Local $sData = "..upon a time there was a language without any standardized cryptographic functions. That language is no more." ; Data that will be encrypted.

Local $bEncrypted = _Crypt_EncryptData($sData, $sUserKey, $CALG_RC4) ; Encrypt the data using the generic password string.

MsgBox(0, "Crypted data", "BinaryToString"&@CRLF&BinaryToString($bEncrypted))
MsgBox(0, "Crypted data", "Nothing"&@CRLF&$bEncrypted)
MsgBox(0, "Crypted data", "StringToBinary"&@CRLF&StringToBinary($bEncrypted))

$bEncrypted = _Crypt_DecryptData($bEncrypted, $sUserKey, $CALG_RC4) ; Decrypt the data using the generic password string. The return value is a binary string.
MsgBox(0, "Decrypted data", "BinaryToString"&@CRLF&BinaryToString($bEncrypted)) ; Convert the binary string using BinaryToString to display the initial data we encrypted.
MsgBox(0, "Decrypted data", "Nothing"&@CRLF&$bEncrypted)
MsgBox(0, "Decrypted data", "StringToBinary"&@CRLF&StringToBinary($bEncrypted))

 

ty for reply but i cant find any RSA Encryption Algorithm ID in crypt UDF + the example provided using symetric RC4 not Asymetric RSA what i seek. if crypt.au3 support RSA can u give me a working example for generating public and private keys , encryption or decryption using them .

 

Link to comment
Share on other sites

@Network_Guy: the Example Scripts Forum contains lots of interesting stuff, like this.^_^

@caramen: Maybe study the difference between a hash function and an encryption algorithm before you confuse others.;)

Link to comment
Share on other sites

No worry i Know it was not asked. But sometime you can swap your first goal.

 

anyway i shared all i Know :) 

sry i canot do much more :) 

 

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to comment
Share on other sites

2 hours ago, Network_Guy said:

can i do the same with Autoit ? 

The short answer is yes. 

If you have the skill, time, and desire, you could use the builtin Windows crypto functions like the ones exposed in the bcrypt.dll, you could use a 3rd party set of functions, like the ones provided by Chilkat, or you could use a combination of command line tools, like OpenSSH, and DLL calls to achieve whatever it is you are trying to do.  In AutoIt, you would use the Dll* functions to create the necessary structures. get/set the structure data, open/close the required dll(s), and to call the functions that you need.

There may even be ways to use some of the .Net assemblies through COM.  I see that there are numerous System.Security.Cryptography CLSIDs defined on my machine but I never tried to use any of those through COM.

With AutoIt, your options are almost limitless.  ;)

Link to comment
Share on other sites

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...