Created
October 23, 2015 20:09
-
-
Save KensoDev/8d060c80c80e495c78f8 to your computer and use it in GitHub Desktop.
Wix signature handle documentation
This file contains hidden or 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
| 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