A pure javascript module for the RSA functionality for BurningPig & Minecraft encryption
This module can generate an RSA public/private key pair in pure JavaScript. It can also generate the ASN.1 for the key.
I have no idea. I only use it for implimenting the encryption for the Minecraft protcol. I don't use it for any important encryption scenarios.
This module is adapated for Node.js from the following libraries:
- rsasign.js library written by Kenji Urushima
- Javascript BigNumber & RSA library written by Tom Wu
- node-bignumber written by Laurent Eschenauer
You can run this example by running node example
var rsa = require("./src/rsa.js");
var key = new rsa.Key();
var message = "All your bases are belong to us.";
console.log("Message:\n"+message+"\n");
// Generate a key
key.generate(1024, "10001");
console.log("Key:\n");
console.log("n:" + key.n.toString(16));
console.log("e:" + key.e.toString(16));
console.log("d:" + key.d.toString(16));
console.log("\n");
// Encrypt
var encrypted = key.encrypt(message);
console.log("Encrypted:\n" + rsa.linebrk(encrypted, 64) + "\n" );
// Decrypt
var decrypted = key.decrypt(encrypted);
console.log("Decrypted:" + rsa.linebrk(decrypted, 64) + "\n");
var sig = key.signString(message, "sha256");
console.log("String signature: \n" + rsa.linebrk(sig, 64));
var pubkey = new rsa.Key();
pubkey.n = key.n;
pubkey.e = key.e;
var verified = pubkey.verifyString(message, sig);
console.log("Verfied: " + verified);
BurningPig-encryption & the base libraries are MIT licensed.
See the LICENSE file for the list of specific licenses for each library