0

I have a frontend in angular and a backend in C#. I generated a pair of keys (XML format) and I want to use the public key to encrypt some data in the frontend and send it to the backend where I'll decrypt it. However, I couldn't use any of the libraries/modules that I found on the internet. Does anyone know a good library that I can use? If you could also provide an example, it would be great!

Thanks in advance!

1 Answer 1

1

I found node-forge which was suggested here and managed to put it working. For node-forge, I needed to export my public key in the PEM format. For such thing, I used this code and then I loaded the key and encrypted my data just like this (on angular)

let rsa = forge.pki.publicKeyFromPem("-----BEGIN PUBLIC KEY-----"+
    "MIIBI..."+
    "-----END PUBLIC KEY-----");

return window.btoa(rsa.encrypt(data));
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.