Link to home
Create AccountLog in
Avatar of Dnx_7
Dnx_7Flag for Belgium

asked on

How can i parse and check if a string is in BASE64 format?

Hi experts,

Is there a way to check/parse a string and see if it is a valid base64 ?

because i don't want to do a try/Catch, guess it will slow my system if we don't have base64 string...


Regards
Avatar of Jaime Olivares
Jaime Olivares
Flag of Peru image

You can make some checkings, like the valid characters:
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/ plus the = sign

also have a look to the following explanation about how a base64 string is made:
http://en.wikipedia.org/wiki/Base64
Avatar of Dnx_7

ASKER

Hi,

i'm agree with you but suppose the application receive a string like this : "Hello=/Script"
kind of valid base64?!

Regards.
ASKER CERTIFIED SOLUTION
Avatar of Jaime Olivares
Jaime Olivares
Flag of Peru image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of Dnx_7

ASKER

Thank you!