Jump to content
Sigmahokies

RSA encryption

Recommended Posts

Hello everyone,

I'm trying to create a RSA encryption, but seem it is not function correctly.

Is Javascript know RSA? like, let rsa = new RSA(); do I have to download from github? 

here my code:

	                    let rsa = new RSA();
                    let prime = ["2", "3", "5", "7", "11", "13"]  //<-- Prime number
                    let random = prime[Math.floor(Math.random() * prime.length)];
                    let text = document.getElementById("readed");
                    document.getElementById("en").innerHTML = rsa.encrypt(random, text);
	

Seem  console log show it is not function.

Edited by Sigmahokies

Share this post


Link to post
Share on other sites

RSA is not a native Javascript object, you will have to find a library. Wherever you found that code should have some documentation telling you where to get the library.

Share this post


Link to post
Share on other sites

You will need to include a script file on your page to use it, but you might not need to host it on your own server if they are offering a CDN.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×