[erlang-questions] base64:decode fails on facebook base64 encoded strings

Heinz N. Gies heinz@REDACTED
Wed Dec 21 16:54:30 CET 2011


As an addition look closely at the decoding on the webside, it also fails the last two characters are missing unless you add the missing '=' to the base64 encoded data.

Regards,
Heinz
--
Heinz N. Gies
heinz@REDACTED
http://licenser.net

On Dec 21, 2011, at 16:44, Max Bourinov wrote:

> Hi guys,
> 
> Does anybody knows why base64:decode fails on strings like this:
> 
> eyJhbGdvcml0aG0iOiJITUFDLVNIQTI1NiIsImNyZWRpdHMiOnsib3JkZXJfZGV0YWlscyI6IntcIm9yZGVyX2lkXCI6Mjg1NTAwMDgxNTAxMTU4LFwiYnV5ZXJcIjoxMDI3NDE5NzkzLFwiYXBwXCI6MTY4MzExOTc2NTgwNDUwLFwicmVjZWl2ZXJcIjoxMDI3NDE5NzkzLFwiYW1vdW50XCI6MSxcInVwZGF0ZV90aW1lXCI6MTMyNDQ3OTA3NixcInRpbWVfcGxhY2VkXCI6MTMyNDQ3OTA3NCxcImRhdGFcIjpcIlwiLFwiaXRlbXNcIjpbe1wiaXRlbV9pZFwiOlwiMFwiLFwidGl0bGVcIjpcIkEgRmFjZWJvb2sgSGF0XCIsXCJkZXNjcmlwdGlvblwiOlwiVGhlIGNvb2xlc3QgaGF0IHlvdSd2ZSBldmVyIHNlZW4uXCIsXCJpbWFnZV91cmxcIjpcImh0dHA6XFxcL1xcXC93d3cuZmFjZWJvb2suY29tXFxcL2ltYWdlc1xcXC9naWZ0c1xcXC83NDAucG5nXCIsXCJwcm9kdWN0X3VybFwiOlwiaHR0cDpcXFwvXFxcL3d3dy5mYWNlYm9vay5jb21cXFwvaW1hZ2VzXFxcL2dpZnRzXFxcLzc0MC5wbmdcIixcInByaWNlXCI6MSxcImRhdGFcIjpcIlwifV0sXCJzdGF0dXNcIjpcInBsYWNlZFwifSIsInN0YXR1cyI6InBsYWNlZCIsIm9yZGVyX2lkIjoyODU1MDAwODE1MDExNTgsInRlc3RfbW9kZSI6MX0sImV4cGlyZXMiOjEzMjQ0ODMyMDAsImlzc3VlZF9hdCI6MTMyNDQ3OTA3Niwib2F1dGhfdG9rZW4iOiJBQUFDWkFGQ1pCVFZXSUJBQzBhYkhWb3dLRWdTVHVOQ3ZDYjRTR21hWkE4STdYc3Z0bXBZZU1hTWx3clNia0U5dkxKTHRldUdraWpNakh4aVpBVWY5am9RcG9aQ3ZWYW9YVUN6N21zU3Bjb0FuWGhKRDVRU0lRIiwidXNlciI6eyJjb3VudHJ5IjoicnUiLCJsb2NhbGUiOiJlbl9VUyIsImFnZSI6eyJtaW4iOjIxfX0sInVzZXJfaWQiOiIxMDI3NDE5NzkzIn0
> 
> You can easily decode it with online tool like this: http://www.motobit.com/util/base64-decoder-encoder.asp
> 
> But lovely Erlang says:
> 
> ** exception error: no function clause matching base64:decode("Jye",
>                                                               [133,177,157,189,201,165,209,161,180,136,232,137,33,53,5,12,
>                                                                181,77,33,4,200,212,216,136,176,137,141|...])
>      in function  base64:decode/1
> 
> Seems something wrong with pattern matching or what could it be? And most interesting question - how to find a proper work around?
> 
> 
> Best regards,
> Max
> 
> 
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20111221/d6aab8bb/attachment.htm>


More information about the erlang-questions mailing list