Encrypt with RSA algorithm

Questions and information about using VBScript and JavaScript in NeoBook functions

Moderator: Neosoft Support

Locked
User avatar
Rodrigo
Posts: 30
Joined: Wed May 30, 2012 6:23 am
Location: Chile

Encrypt with RSA algorithm

Post 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!
After the game, the nerd and the ignorant will return to the same box
Neosoft Support
NeoSoft Team
Posts: 5628
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA
Contact:

Re: Encrypt with RSA algorithm

Post 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/rs ... trings.asp

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

http://www.neosoftware.com/neobook/modu ... =8&lid=187

And a JavaScript encryption function:

http://www.neosoftware.com/neobook/modu ... 18&lid=242
NeoSoft Support
User avatar
Rodrigo
Posts: 30
Joined: Wed May 30, 2012 6:23 am
Location: Chile

Re: Encrypt with RSA algorithm

Post 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!
After the game, the nerd and the ignorant will return to the same box
User avatar
Rodrigo
Posts: 30
Joined: Wed May 30, 2012 6:23 am
Location: Chile

Re: Encrypt with RSA algorithm

Post 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.
After the game, the nerd and the ignorant will return to the same box
Neosoft Support
NeoSoft Team
Posts: 5628
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA
Contact:

Re: Encrypt with RSA algorithm

Post by Neosoft Support »

I'm glad you found a solution, and thank you for sharing it with us!
NeoSoft Support
Locked