Jump to content

Recommended Posts

Posted

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

Posted

_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 ?

Regards,
 

Posted

Maybe you mean PGP / GPG ?

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted
  On 6/2/2016 at 3:52 AM, giangnguyen said:

I found several threads but they are all outdated 

Expand  

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.

Posted

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

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?

Posted

AutoIt plugin support has been abandonned long ago.

 

  Reveal hidden contents

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)

Posted

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

 

Posted

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.

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

  • 4 weeks later...
Posted

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)

  • 2 weeks later...
Posted
  On 6/11/2016 at 1: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.

Expand  

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?

Posted

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.

Expand  

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.

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

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
×
×
  • Create New...