Skip to content

Instantly share code, notes, and snippets.

@maletor
Last active December 30, 2015 10:29
Show Gist options
  • Save maletor/894d59fd75085e031336 to your computer and use it in GitHub Desktop.
Save maletor/894d59fd75085e031336 to your computer and use it in GitHub Desktop.
Example problem tokens from parameters found in bug reports:
1.9.3 (main):0 > Base64.decode64 "eyj1c2vyx2lkijoymty1mjcsimvtywlsijoiandpyxrlckbizwf1bw9udghvc3bpdgfscy5jb20ifq=="
=> "{(\xF5sk\xF2\xC7id\x8A:2\x9A\xDC\xB5\x9A7,\x8Ak\xED\xCB\tl\x8A:\"jwi\xCB\x1A\xE5rF\xE2\xCF\a\xF5o\x0Fnv\bosv\xE9v\a\xECs.com\"~"
1.9.3 (main):0 > Base64.decode64 "eyj1c2vyx2lkijo0odm4mzasimvtywlsijoiymjlcmdlcm9uqhntzgmub3jnin0="
=> "{(\xF5sk\xF2\xC7id\x8A:4\xA1\xD9\xB8\x9B6\xAC\x8Ak\xED\xCB\tl\x8A:\"\xCAh\xE5rgeron\xAA\x19\xED\xCE\t\xAEox\xE7\x8A}"
1.9.3 (main):0 > Base64.decode64 "eyj1c2vyx2lkijo5mzq4njgsimvtywlsijoibwtpbmdaaw5ub3zpc2hlywx0ac5jb20ifq=="
=> "{(\xF5sk\xF2\xC7id\x8A:9\x9B:\xB8\x9E8,\x8Ak\xED\xCB\tl\x8A:\"o\vingZk\x0Eno|\xE9she\xCB\fti\xCEcom\"~"
1.9.3 (main):0 > # This one is slightly differnt. Where is the appended "By" coming from?
1.9.3 (main):0 > Base64.decode64 "eyJ1c2VyX2lkIjo4NTMzNzMsImVtYWlsIjoic3J1YmluQG5zaHMuZWR1In0By"
=> "{\"user_id\":853373,\"email\":\"srubin@nshs.edu\"}\x01"
module Helper
def unsubscribe_token(options)
token = Base64.urlsafe_encode64({ user_id: options[:user_id], email: options[:email] }.to_json)
end
def decode_unsubscribe_token(token)
decoded = Base64.urlsafe_decode64(token)
ActiveSupport::JSON.decode(decoded)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment