RSA Encryption Javascript

58,426

Solution 1

Never mind found the answer myself!

RSA Encryption standard uses PKCS #1

Best library to use is pidCrypt, nothing else worked for me!

https://sourceforge.net/projects/pidcrypt/

the idiots on the other end failed to let me know that that RSA Public Key was meant to be base64 decoded too before encrypting the DATA before sending.

Solution 2

You may be interested in trying out forge (it does RSA and more). There are lots of examples on the README:

https://github.com/digitalbazaar/forge

Share:
58,426
null
Author by

null

null

Updated on January 02, 2022

Comments

  • null
    null over 2 years

    Can anyone please help me with this - I have been instructed to write an application that takes some data then encrypts it with an RSA public key.

    It apparently needs to be "RSA encryption" (I have never heard or seen this before?)

    Which encryption cipher is RSA meant to use as standard?

    var key = "TUlHZE1BMEdDU3FHU0liM0RRRUJBUVVBQTRHTEFEQ0Jod0tCZ1FDbVFiTWc3SWRpeHVmYWEwcDd2ODVLVytmUnVlZ216UUhibnNoWjhmbXlTQW9MMXRFVzAyNEZKVFlSTFZxN0VsV2p1R0U4aHQ3RmJjN1NURWpxZVViWU5xdnRiVWN6UFZYSE5FdStYRUVndGszazlFNXVQWG0wVzRIc3RtK0FhRXcyMmxxb2lFNGlrT1QzZzdPRXNHSVFCMVNlSlRtVTE1eFBBZ3M3SXRjTVFRSUJFUT09";
    
    var data = "Xa21dr";
    
  • null
    null almost 11 years
    thanks, pidCrypt is working perfectly but will take a look. pidCrypt offers not just RSA too.
  • Houcem Berrayana
    Houcem Berrayana over 10 years
    the last line in your response saved me a lot of time.
  • null
    null over 10 years
    thanks, if you found this useful then please mark the answer as useful :)
  • Tarion
    Tarion over 10 years
    What is the format of the encrypted data? Is it also base 64?
  • Todd Horst
    Todd Horst over 9 years
    forge is very nice. I had a little trouble getting it started, so I created the demo here: digitalbazaar.github.io/forge
  • Toubey
    Toubey about 9 years
    pidder is no longer online?
  • null
    null almost 9 years
    @Toubey looks to be still online to me just checked their website - pidder.com/pidcrypt - still accessible. you can download from source forge directly too - sourceforge.net/projects/pidcrypt
  • Toubey
    Toubey almost 9 years
    Thanks @whitedeath, apparently there was something wrong with by the time i checked it.
  • Philzen
    Philzen over 8 years
    The project is no longer maintained. Also @whitedeath - can you clarify whether it implemented PKCS#1 v1.5 (which is understand is easily attackable since 1998) or PKCS#1 v2.2 (RSA with Optimal Asymmetric Encryption Padding). For those reasons and ease of use i went with forge, which also is a pretty active project on github.
  • null
    null over 8 years
    @Philzen No idea which PKCS v is packaged with pidCrypt you will need to download the source and take a look (i needed PKCS #1 so went with pidCrypt as it worked perfectly for my needs).
  • yeah22
    yeah22 over 2 years
    Note: pidCrypt is licensed under GPL (thus, your software must legally also be licensed under GPL if you use the library)