Skip to content

Instantly share code, notes, and snippets.

@zglozman
Created September 5, 2016 20:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zglozman/b6591825a8923b61f78071e2b2b4ce03 to your computer and use it in GitHub Desktop.
Save zglozman/b6591825a8923b61f78071e2b2b4ce03 to your computer and use it in GitHub Desktop.
function getPublicKeyFromModulustoDer(n) {
var modulus = new Buffer(n, 'hex');
var header = new Buffer("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA", "base64");
var midheader = new Buffer("0203", "hex");
var exponent = new Buffer("010001", "hex");
var buffer = Buffer.concat([header, modulus, midheader, exponent]);
return buffer;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment