Created
July 2, 2020 03:58
-
-
Save aereal/27235bada46e55b8c03acf6ea3b60f17 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'openssl' | |
require 'jwe' | |
require 'jwt' | |
require 'json' | |
private_key = OpenSSL::PKey::RSA.new(File.read('/Users/aereal/devel/src/github.com/aereal/playground-jwt/internal/key/test-private.pem')) | |
payload = { name: 'aereal' } | |
results = [] | |
10.times do |i| | |
sleep 1 if i.even? | |
token = JWT.encode(payload, private_key, 'RS512') | |
encrypted = JWE.encrypt(token, private_key) | |
results.push({signed: token, encrypted: encrypted}) | |
end | |
results.each_cons(2).with_index(1) do |(prev, current), i| | |
unless prev[:signed] == current[:signed] | |
warn "! ##{i} signed token mismatched: previous:#{prev[:signed]} current:#{current[:signed]}" | |
end | |
unless prev[:encrypted] == current[:encrypted] | |
warn "! ##{i} encrypted token mismatched: previous:#{prev[:encrypted]} current:#{current[:encrypted]}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment