Commit df973df8 authored by Kamil Trzcinski's avatar Kamil Trzcinski

Simplify JWT::RSAToken::kid

parent 715a8cfa
...@@ -29,10 +29,14 @@ module JWT ...@@ -29,10 +29,14 @@ module JWT
end end
def kid def kid
fingerprint = Digest::SHA256.digest(public_key.to_der) # calculate sha256 from DER encoded ASN1
Base32.encode(fingerprint).split('').each_slice(4).each_with_object([]) do |slice, mem| kid = Digest::SHA256.digest(public_key.to_der)
mem << slice.join
end.join(':') # we encode only 30 bytes with base32
kid = Base32.encode(kid[0..29])
# insert colon every 4 characters
kid.scan(/.{4}/).join(':')
end end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment