Source language: Translate to:

Encrypt with RSA algorithm

Questions and information about using VBScript and JavaScript in NeoBook functions

Moderator: Neosoft Support

Encrypt with RSA algorithm

Postby Rodrigo » Thu May 22, 2014 10:26 pm

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
User avatar
Rodrigo
 
Posts: 29
Joined: Wed May 30, 2012 6:23 am
Location: Chile

Re: Encrypt with RSA algorithm

Postby Neosoft Support » Fri May 23, 2014 10:13 am

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
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5593
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA

Re: Encrypt with RSA algorithm

Postby Rodrigo » Fri May 23, 2014 11:27 am

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: 29
Joined: Wed May 30, 2012 6:23 am
Location: Chile

Re: Encrypt with RSA algorithm

Postby Rodrigo » Sat May 24, 2014 9:44 pm

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
User avatar
Rodrigo
 
Posts: 29
Joined: Wed May 30, 2012 6:23 am
Location: Chile

Re: Encrypt with RSA algorithm

Postby Neosoft Support » Mon May 26, 2014 10:09 am

I'm glad you found a solution, and thank you for sharing it with us!
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5593
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA


Return to NeoBook Functions - VBScript & JavaScript

Who is online

Users browsing this forum: No registered users and 1 guest