Page 1 of 1

Encrypt with RSA algorithm

PostPosted: Thu May 22, 2014 10:26 pm
by Rodrigo
Hello everyone!.
I have the following problem.

I have a private key in PEM format. Now, I need to encrypt a Hash Value using the RSA algorithm with this private key.

Any idea?

Thank you!

Re: Encrypt with RSA algorithm

PostPosted: Fri May 23, 2014 10:13 am
by Neosoft Support
I have no idea if this will work, but I found the following VBScript code for RSA which you might be able to convert into a NeoBook function:

http://www.example-code.com/vbscript/rsa_encryptStrings.asp

Alternatively, here is an encryption/decryption plug-in for NeoBook called npCiph:

http://www.neosoftware.com/neobook/modules/plugins/singlefile.php?cid=8&lid=187

And a JavaScript encryption function:

http://www.neosoftware.com/neobook/modules/plugins/singlefile.php?cid=18&lid=242

Re: Encrypt with RSA algorithm

PostPosted: Fri May 23, 2014 11:27 am
by Rodrigo
Thanks Dave.

I had already looked nCiph, but I think that unfortunately has no support for RSA. I need to find a function that allows me to encrypt a SHA1 hash using the RSA algorithm with a private key in PEM format (base64). That is, SHA1withRSA.

Or alternatively, separate functions that allow me to: (1) decode a Base64. (2) a function that allows me to encrypt using RSA.

Unfortunately I know little VBA, :oops: which is the language that could be used to design a NeoBook function. That's right I'm forced to learn.

I'm reviewing the links you sent me and others. If I find something I'll post. Meanwhile more ideas are welcome :roll: .

Thank you!

Re: Encrypt with RSA algorithm

PostPosted: Sat May 24, 2014 9:44 pm
by Rodrigo
I finally did it!. But I had to install OpenSSL.
I do not know if this code can serve someone. I leave it here anyway.

These are the parameters to encrypt a string (cadena.txt) using a private key in base64 (llaveprivada.pem). The encrypted result (timbre.txt).
Encryption: using "Sha1WithRsa":
Code: Select all
Run "C:\OpenSSL-Win32\bin\openssl.exe" "dgst -sha1 -sign E:/fe/llaveprivada.pem -out E:/fe/timbre.txt E:/fe/cadena.txt" "RunOnce+Wait" "" ""


And if you want the encrypted result (timbre.txt) expressed in Base64 (timbreBase64.txt) use this:
Code: Select all
Run "C:\OpenSSL-Win32\bin\openssl.exe" "base64 -in E:/fe/timbre.txt -out E:/fe/timbreBase64.txt" "RunOnce+Wait" "" ""


Anyway if anyone has a better idea, I welcome it.

Thanks.

Re: Encrypt with RSA algorithm

PostPosted: Mon May 26, 2014 10:09 am
by Neosoft Support
I'm glad you found a solution, and thank you for sharing it with us!