Skip to content

Instantly share code, notes, and snippets.

Last active Feb 5, 2022
What would you like to do?
# Smart Health Card decoder
# This decodes the SHC url thing that is stored in smart health card QR codes
str = DATA.readline
require "base64"
require "zlib"
require "json"
require "pp"
payload = str.delete_prefix("shc:/").scan(/\d\d/).map { |x| (x.to_i + 45).chr }.join
payload = payload.split(".").map { |x|
pad = x.bytesize % 4
Base64.urlsafe_decode64("#{x}#{pad == 0 ? nil : '=' * (4-pad)}")
pp JSON.load payload.first
zlib =
pp JSON.load zlib.inflate payload[1]
Decode your health card QR code and paste the shc "URL" above
Copy link

tenderlove commented Jan 4, 2022

@sorah fixed! Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment