Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Search!

Blog Contact About byGeoffTaylor

Blog Base64encodinganddecodingin.NET
Categories
Whatdoyoudowhenyougetanemailaskingyouaquestion,butyourreplywith
All theanswerbounces?

.NET
I'mnotsurewhatthebestansweris,butIfigureifIputtheansweruphereit
4WordBookR mighthelpsomeoneelsewiththesamequestion,eveniftheoriginalasker
AllPodcasts doesn'tfindit.
BusinessThoug
TheemailIgotwasaboutmyonlinebase64encoderanddecoder:
CluelessIdiocy
Development Hi
Life Iaskyousomehelp
NornIron
Personal Ihavebigproblemofbase64decode
Podcasting pleasehelpme.
PowerPack
WeirdInterweb pleasebase64decodesourceinVB.netbegivenme
WhatIf... Nowdon'tlaughhisEnglishisahellofalotbetterthanmyKorean.

Thethingis,base64encodinganddecodingin.NETisutterlytrivialaslongas
WebTools youknowthebaseclasslibrarycallstomake.Ifyoudon'tknowthey'rethere,
youcanspendawhileimplementingyourownalgorithm,andthat'sjustNotFun.
OPMLViewer
So,here'smyreply.Maybeit'llhelpsomeoneelsefindtherightfunctionstocall.
RSSViewer
ASP.NETColors Hithere,
Base64Encode
Base64Decode Icouldsendyouthele,butIdon'tthinkitwouldhelpyoumuch.There'sanawfullot
ofASP.NET'plumbing'codeandverylilebase64code.
HTMLEncode

HTMLDecode Instead,here'sasampleprogramIjustwrotethatshowshowtodothebase64
URLEncode encodinganddecodingin.NET.It'sinC#scrolldownfortheVB.NETversion:
URLDecode
CrazyIPs usingSystem
Whois usingSystem.Text

publicclassBase64Decoder
WindowsTools {
publicstaticvoidMain()
{
stringinputText="Thisissometext."
Sourcecode Console.Out.WriteLine("Inputtext:{0}",inputText)
forallthese byte[]bytesToEncode=Encoding.UTF8.GetBytes(inputText)
toolsison
stringencodedText=Convert.ToBase64String(bytesToEncode)
GitHub. Console.Out.WriteLine("Encodedtext:{0}",encodedText)

ADO.NET byte[]decodedBytes=Convert.FromBase64String(encodedText)
ConnTest stringdecodedText=Encoding.UTF8.GetString(decodedBytes)
Asimple,free Console.Out.WriteLine("Decodedtext:{0}",decodedText)
Windows
Console.Out.Write("Pressentertofinish.")
programto Console.In.ReadLine()
testADO.NET
connection return
}
strings.
}
LinesofC#
Everwantedto Here'smyaemptattranslangthattoVB.NET.I'mnotaVB.NETprogrammer,soI
knowhow mayhavedonesomethingsilly.Itseemstoworkthough.
manylinesof
C#codearein
importsMicrosoft.VisualBasic
afileorfolder importsSystem
hierarchy? ImportsSystem.Text
Thisfree
Windows publicmoduleBase64Decoder
programwill subMain
DiminputTextAsString
tellyou.
inputText="Thisissometext."
Console.Out.WriteLine("Inputtext:{0}",inputText)
XmlTools
Freetoolsto DimbytesToEncodeAsByte()
processXML bytesToEncode=Encoding.UTF8.GetBytes(inputText)
filesfromthe
DimencodedTextAsString
commandline.
encodedText=Convert.ToBase64String(bytesToEncode)
Console.Out.WriteLine("Encodedtext:{0}",encodedText)

DimdecodedBytesAsbyte()
decodedBytes=Convert.FromBase64String(encodedText)

DimdecodedTextAsString
decodedText=Encoding.UTF8.GetString(decodedBytes)
Console.Out.WriteLine("Decodedtext:{0}",decodedText)

Console.Out.Write("Pressentertofinish.")
Console.In.ReadLine()
endsub
endmodule


Ifyoudon'twanttomessaroundwithbytearrays,youcanjustuse
Convert.ToBase64StringandConvert.FromBase64String,butdoingtheconversion
to/fromabytearraygivesyouabitmorecontrolifyou'refacedwithstrangecharacter
encodings.
Hopethishelps,

Geo

Unfortunatelythatreply(toaKoreanemailaddress)bouncedwiththeerror
"PERM_FAILURE:SMTPError(state13):551Usernotlocal".Maybetheperson
whooriginallyaskedthequestionwillfindtheanswerintheblogpost.

Categories: .NET
Permalink
#. Postedby'geoff'onThursday,06December2007at
8:25AM

<PreviousBlogPost NextBlogPost>

Comments,TrackbacksandPingbacks

Somebase64tips
IjustsawapostonNovell's'CoolBlogs'blogthathasausefultipon
base64decoding.Apparently,ifyousaveyourbase64texttoafile
withanextensionof'.b64',Winzipcanopenthefileandallowyouto
extractthecontent.That...
Postedby'Geoff'sBlog'onSaturday,12January2008at2:48PM

Covertafile(pdf,docetc)toBase64
Hi
PleasehelptodoBase64Encodinganddecodingofafilelikepdfofdoc.
Regards
Pradeep

Postedby'Pradeep'onTuesday,28September2010at2:37PM

ConvertToJapannese
thanksfortutorial.Buthowtoconvertjapannesecharacter

Postedby'Zho'onSaturday,10November2012at5:29AM

Japanese?

Postedby'GeoffTaylor'onSunday,11November2012at6:33PM

Passwordencryption/decryptioncodein.NET|...
Excerptcouldnotbegenerated.
Postedby'Pingback'onSaturday,16February2013at2:11PM

Convertingfiles
Pradeep,

Ifyou'relookingforaquick,simplewaytodoit,youcangoto:
http://www.opinionatedgeek.com/DotNet/Tools/Base64Encode/default.aspx

Click'Choosefile'andpickthefileyouwantconverted.Thenclickthe'Encode'
button.

TheencodedversionofthefilethenappearsintheEncodedOutputpane.Saveall
ofthattexttoafile,givingitwhateverfilenameandextensionyouwant).

Theblogpostyoucommentedongivesmoredetailonhowtowriteaprogramto
dothis,ifyou'reinterested.

Hopethishelps,

Geoff

Postedby'GeoffTaylor'onSunday,03October2010at5:00PM

Thanku
hithisisvetri.reallythisencodinganddecodinginformationveryusefulinmy
project.i'velittlebitconfusionwheretoimplementandhowtoimplementthese
concept...nowi'vecleared...

Postedby'Vetri'onMonday,15March2010at3:03PM

HElpme
HiPleasehelpmeihaveproblemtodecodehtmlcodeinjavascript
actuallyit'sencodedatserversideandiwanttodecodeatclientside

Postedby'Ajay'onThursday,01April2010at7:14AM

Javascriptencoding/decoding
Hi,

Aquicksearchturnedupthisasawayofdoingbase64decodingclientside:
http://www.webtoolkit.info/javascriptbase64.html

Postedby'GeoffTaylor'onThursday,01April2010at10:58AM

HowdoyouURLBase64EncodeandDecodea
conca...
Excerptcouldnotbegenerated.
Postedby'Pingback'onTuesday,09December2014at9:50PM

PostAComment

YourName:

YourURL(optional):

CommentTitle:

Typethetext
Privacy&Terms

PostComment

SubscribetotheRSS2.0feedforGeoffsBlog.

Blog | Contact | About

Copyright20032015OpinionatedGeekLtd.

You might also like