title: How to create an RSA key from hex-encoded modulus and encrypt in node.js
body: <p>I'm finding the way to RSA encryption in node.js, I want to handle big numbers, so I use this: <a href="https://github.com/eschnou/node-bignumber" rel="nofollow noreferrer">https://github.com/eschnou/node-bignumber</a></p>
  
  <p>What I'm going to do is just encryption, with modulus and exponent. I don't have to do decryption. anyway, I got an error on and on, but I don't know what's wrong. Can anyone know what it is wrong? Thanks.</p>
  
  <p><strong>Code</strong> </p>
  
  <pre><code>require("node-bignumber");
  var nvalue="ad6eb61316ff805e9c94667ab04aa45aa3203eef71ba8c12afb353a5c7f11657e43f5ce4483d4e6eca46af6b3bde4981499014730d3b233420bf3ecd3287a2768da8bd401f0abd7a5a137d700f0c9d0574ef7ba91328e9a6b055820d03c98d56943139075d";
  var evalue="010001";
  var encpw="";
  var rsa = new RSAKey;
  
  function encryptMessage() {
      var message = "All your bases are belong to us.";
      rsa.setPublic(evalue, nvalue);
      encpw.value = rsa.encrypt(message);
      console.log(encpw);
  }
  
  encryptMessage();
  </code></pre>
  
  <p><strong>Error</strong></p>
  
  <pre><code>ReferenceError: RSAKey is not defined
      at Object.&lt;anonymous&gt; (c:\Users\win\Desktop\untitled\juntae.js:5:15)
      at Module._compile (module.js:435:26)
      at Object.Module._extensions..js (module.js:442:10)
      at Module.load (module.js:356:32)
      at Function.Module._load (module.js:311:12)
      at Function.Module.runMain (module.js:467:10)
      at startup (node.js:136:18)
      at node.js:963:3
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/OrygN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OrygN.png" alt="enter image description here"></a></p>