Skip to content

Instantly share code, notes, and snippets.

@nov
Last active August 9, 2016 07:59
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 nov/765863718e1d3a551b1fd08ae7b9c384 to your computer and use it in GitHub Desktop.
Save nov/765863718e1d3a551b1fd08ae7b9c384 to your computer and use it in GitHub Desktop.
var pem = '-----BEGIN PUBLIC KEY-----\
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApnOaAemDtELggT4BpfuE\
PDImzKZpEX/U8MNSk5RF/j8LGR5V8CjN1ASO0Yy9HxILpTDZFFVEsCVKo4c/Smi6\
PzMlNIyywrpnAJFoqtuSLlD/A8SRBEgyXRWzEwvtfW5fhmGFVLw9qm5ZDgrL/XNW\
gMH4uHvJA1mdQlRyCopUlvAeQJ2aM13rNpkYRnCQIDNfVStEsVbYTjF0m9QR1Nb1\
zYpzB4nDNVQlZmj+SyDwtY+BMH6GAiXwa8JOb0mHgUVnxdWdL6lx8kVUkg16Yv17\
D8u0Jhl+7W1SVVVNEYaGKaB1KKmJ7twibmyX4gwBRbQIamvHyZRc/BBaCg3YZNxh\
pwIDAQAB\
-----END PUBLIC KEY-----';
var pubKey = KEYUTIL.getKey(pem);
var jwk = {
kty: pubKey.type,
e: hextob64u(pubKey.e.toString(16)),
n: hextob64u(pubKey.n.toString(16))
}
jwk.kid = KJUR.jws.JWS.getJWKthumbprint(jwk);
console.info(jwk);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment