Base64 Question

Just starting out? Need help? Post your questions and find answers here.
Straker
Enthusiast
Enthusiast
Posts: 701
Joined: Wed Apr 13, 2005 10:45 pm
Location: Idaho, USA

Base64 Question

Post by Straker »

Here's my issue. I have been trying to decode from Base64 several different MIME Email attachments. I use Base64Decoder mostly without problems, but on some encoded strings (large ones - like pictures), it fails because of the trailing "=", which once removed, will work.

So my question is: Why is it that some Base64 encoded strings can only be decoded if they have the trailing "=", and some can only be decoded if the trailing "=" is removed? Is it a string length issue?

Just trying to get a better understanding...
Image Image
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

Test for proper string length with this. You should get a 0 every time.

Code: Select all

Debug (Len(YourBase64EncodedString)*8) % 32
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
Straker
Enthusiast
Enthusiast
Posts: 701
Joined: Wed Apr 13, 2005 10:45 pm
Location: Idaho, USA

Post by Straker »

Once again, thanks Sparkie!
Image Image
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

You're welcome Straker :)
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
Post Reply