Search code examples
javascriptencryptionrsapublic-key

RSA Encryption Javascript


I have been instructed to write an application that takes some data then encrypts it with an RSA public key.

It needs to be "RSA encryption":

Which encryption cipher is RSA meant to use as standard?

var key = "TUlHZE1BMEdDU3FHU0liM0RRRUJBUVVBQTRHTEFEQ0Jod0tCZ1FDbVFiTWc3SWRpeHVmYWEwcDd2ODVLVytmUnVlZ216UUhibnNoWjhmbXlTQW9MMXRFVzAyNEZKVFlSTFZxN0VsV2p1R0U4aHQ3RmJjN1NURWpxZVViWU5xdnRiVWN6UFZYSE5FdStYRUVndGszazlFNXVQWG0wVzRIc3RtK0FhRXcyMmxxb2lFNGlrT1QzZzdPRXNHSVFCMVNlSlRtVTE1eFBBZ3M3SXRjTVFRSUJFUT09";

var data = "Xa21dr";

Solution

  • Found the answer -

    RSA Encryption standard uses PKCS #1

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

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

    Forge https://github.com/digitalbazaar/forge

    They failed to let me know that the RSA Public Key was meant to be base64 decoded also before encrypting the DATA before posting.