Solved

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

Posted on 2008-06-13
4
955 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

776 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