Solved

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

Posted on 2008-06-13
4
954 Views
Last Modified: 2013-11-07
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
0
Comment
Question by:Dnx_7
  • 2
  • 2
4 Comments
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 21780738
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
0
 
LVL 2

Author Comment

by:Dnx_7
ID: 21781152
Hi,

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

Regards.
0
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 500 total points
ID: 21783725
well, you have to entirely process the base64 string.
You can use this ready-made source code as a base:
http://www.codeproject.com/KB/cs/base64encdec.aspx
0
 
LVL 2

Author Comment

by:Dnx_7
ID: 21826826
Thank you!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now