Skip to content

Instantly share code, notes, and snippets.

@nov
Created August 13, 2015 11:16
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/b53e2714dea04093da7a to your computer and use it in GitHub Desktop.
Save nov/b53e2714dea04093da7a to your computer and use it in GitHub Desktop.
require 'json/jwt'
k = OpenSSL::PKey::EC.new('prime256v1').generate_key
k.to_jwk
# => JSON::JWK
jwk = JSON::JWK.new(
kty: "EC",
crv: "P-256",
x: "D4L5V9QocZvfuEEGfGD5YCEbIcXR-KfF7RqqZUaovJ8",
y: "VX0T94KUo0YkhuvT2q0MXMOTtfaIjDS4fb9ii54g4gU",
d: "MCOTV6Ncg7KTuGh1hTa029ZVkqdlaXaYnfLSkZjJ_uE"
)
jwk.to_key
# => OpenSSL::PKey::EC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment