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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...