Add to Favorites    Make Home Page 8973 Online  
 Language Categories  
 Our Services  

Home » ASP Home » Math Home » Base 64 Encode / Decode

A D V E R T I S E M E N T

Search Projects & Source Codes:

Title Base 64 Encode / Decode
Description Base 64 encodeing is used to convert binary files to a "safe" form at for transporting files through smtp (email) and other protocols. It is also used for basic authentication. With this code, you can decode the current UserName/Password who is visiting a protected page on your site by requesting one of the serverVariables.
Category ASP » Math
Hits 379565
Code Select and Copy the Code
Const sBASE_64_CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" ' -------------------------------------- ' --------------------------------------- Function Base64decode(ByVal asContents) Dim lsResult Dim lnPosition Dim lsGroup64, lsGroupBinary Dim Char1, Char2, Char3, Char4 Dim Byte1, Byte2, Byte3 If Len(asContents) Mod 4 > 0 Then asContents = asContents & String(4 - (Len(asContents) Mod 4), " ") lsResult = "" For lnPosition = 1 To Len(asContents) Step 4 lsGroupBinary = "" lsGroup64 = Mid(asContents, lnPosition, 4) Char1 = InStr(sBASE_64_CHARACTERS, Mid(lsGroup64, 1, 1)) - 1 Char2 = InStr(sBASE_64_CHARACTERS, Mid(lsGroup64, 2, 1)) - 1 Char3 = InStr(sBASE_64_CHARACTERS, Mid(lsGroup64, 3, 1)) - 1 Char4 = InStr(sBASE_64_CHARACTERS, Mid(lsGroup64, 4, 1)) - 1 Byte1 = Chr(((Char2 And 48) 16) Or (Char1 * 4) And &HFF) Byte2 = lsGroupBinary & Chr(((Char3 And 60) 4) Or (Char2 * 16) And &HFF) Byte3 = Chr((((Char3 And 3) * 64) And &HFF) Or (Char4 And 63)) lsGroupBinary = Byte1 & Byte2 & Byte3 lsResult = lsResult + lsGroupBinary Next Base64decode = lsResult End Function ' -------------------------------------- ' --------------------------------------- Function Base64encode(ByVal asContents) Dim lnPosition Dim lsResult Dim Char1 Dim Char2 Dim Char3 Dim Char4 Dim Byte1 Dim Byte2 Dim Byte3 Dim SaveBits1 Dim SaveBits2 Dim lsGroupBinary Dim lsGroup64 If Len(asContents) Mod 3 > 0 Then asContents = asContents & String(3 - (Len(asContents) Mod 3), " ") lsResult = "" For lnPosition = 1 To Len(asContents) Step 3 lsGroup64 = "" lsGroupBinary = Mid(asContents, lnPosition, 3) Byte1 = Asc(Mid(lsGroupBinary, 1, 1)): SaveBits1 = Byte1 And 3 Byte2 = Asc(Mid(lsGroupBinary, 2, 1)): SaveBits2 = Byte2 And 15 Byte3 = Asc(Mid(lsGroupBinary, 3, 1)) Char1 = Mid(sBASE_64_CHARACTERS, ((Byte1 And 252) 4) + 1, 1) Char2 = Mid(sBASE_64_CHARACTERS, (((Byte2 And 240) 16) Or (SaveBits1 * 16) And &HFF) + 1, 1) Char3 = Mid(sBASE_64_CHARACTERS, (((Byte3 And 192) 64) Or (SaveBits2 * 4) And &HFF) + 1, 1) Char4 = Mid(sBASE_64_CHARACTERS, (Byte3 And 63) + 1, 1) lsGroup64 = Char1 & Char2 & Char3 & Char4 lsResult = lsResult + lsGroup64 Next Base64encode = lsResult End Function

Related Source Codes

Script Name Author
��������������������� VyomWorld
Resistor color code reader A.Chermarajan.
Telephone Directory dhivya
card swapping game (Mini Project) nityanand
simple hangman-pascalsource Seabert
college dirtectory (Mini Project) msridhar
Poll Application John van Meter
ASP Daily Hit Counter. Tejaskumar Gandhi
To avoid null in asp environment using sql Sami
Maklumbalas webmaster
poll John van Meter
EasyASP Template Engine. TjoekBezoer
Basic Calculator using HTML & Javascript. Patrick M. D Souza
What servers support ASP ? VyomWorld
What is ASP? VyomWorld

A D V E R T I S E M E N T




Google Groups Subscribe to SourceCodesWorld - Techies Talk
Email:

Free eBook - Interview Questions: Get over 1,000 Interview Questions in an eBook for free when you join JobsAssist. Just click on the button below to join JobsAssist and you will immediately receive the Free eBook with thousands of Interview Questions in an ebook when you join.

New! Click here to Add your Code!


ASP Home | C Home | C++ Home | COBOL Home | Java Home | Pascal Home
Source Codes Home Page

 Advertisements  

Google Search

Google

Source Codes World.com is a part of Vyom Network.

Vyom Network : Web Hosting | Dedicated Server | Free SMS, GRE, GMAT, MBA | Online Exams | Freshers Jobs | Software Downloads | Interview Questions | Jobs, Discussions | Placement Papers | Free eBooks | Free eBooks | Free Business Info | Interview Questions | Free Tutorials | Arabic, French, German | IAS Preparation | Jokes, Songs, Fun | Free Classifieds | Free Recipes | Free Downloads | Bangalore Info | Tech Solutions | Project Outsourcing, Web Hosting | GATE Preparation | MBA Preparation | SAP Info | Software Testing | Google Logo Maker | Freshers Jobs

Sitemap | Privacy Policy | Terms and Conditions | Important Websites
Copyright ©2003-2024 SourceCodesWorld.com, All Rights Reserved.
Page URL: http://www.sourcecodesworld.com/source/show.asp?ScriptID=284


Download Yahoo Messenger | Placement Papers | Free SMS | C Interview Questions | C++ Interview Questions | Quick2Host Review