Skip to content

Instantly share code, notes, and snippets.

@KensoDev
Created October 23, 2015 20:09
Show Gist options
  • Select an option

  • Save KensoDev/8d060c80c80e495c78f8 to your computer and use it in GitHub Desktop.

Select an option

Save KensoDev/8d060c80c80e495c78f8 to your computer and use it in GitHub Desktop.
Wix signature handle documentation
encoded_json_hack = encoded_json + ('=' * (4 - encoded_json.length.modulo(4)))
json_str = Base64.urlsafe_decode64(encoded_json_hack)
hmac = OpenSSL::HMAC.digest(OpenSSL::Digest::SHA256.new, APP_SECRET, encoded_json)
# bug in ruby. why are there '=' chars on urlsafe_encode ?!
my_signature = Base64.urlsafe_encode64(hmac).gsub('=','')
raise "the signatures do not match" if (signature != my_signature)
JSON.parse(json_str)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment