Skip to content

Instantly share code, notes, and snippets.

{struct,
[{"algorithm","HMAC-SHA256"},
{"credits",
{struct,
[{"buyer",1027419793},
{"receiver",1027419793},
{"order_id",163932157040089},
{"order_info", "{\"title\":\"BFF Locket\",\"description\":\"This is a BFF Locket...\",\"price\":\"10\",\"image_url\":\"http://www.facebook.com/images/gifts/21.png\",\"item_id\":12345,\"product_url\":\"http://www.facebook.com/images/gifts/21.png\"}"},
{"test_mode",1}]
}
-module (base64ex).
-export ([urlsafe_decode64/1, urlsafe_encode64/1]).
urlsafe_decode64(Str) ->
Str2 = re:replace(Str, "-", "+", [global, {return,list}]),
Str3 = re:replace(Str2, "_", "/", [global, {return,list}]),
base64:decode(Str3).
urlsafe_encode64(Bin) ->