Sample Base 64 Encoding and Decoding

This article was previously published under Q191239
SUMMARY
B64_samp.exe is a sample that shows how to programmatically encode anddecode Base 64 encoding mechanism. This encoding mechanism was introducedfor use with Multipurpose Internet Mail Extensions (MIME). It is thedefault mechanism used when authenticating in clear text (BasicAuthentication) between a Web browser and a Web server.

The sample is in the form of a simple Win32 command line application. Usageis as follows:
Usage:  Base64.exe -[d|e] <message>           d  :  Decode <message>           e  :  Encode <message>				
The sample does not format the encoded text. The RFC specifications forBase 64 requires that each line of the encoded message not be greater than76 characters. After 76 characters, the message must have a hard line breakinserted (that is, carriage return + line feed). Furthermore, the encodedmessage when fed into a decoder must be padded so that the total number ofcharacters be divisible by 4. The decoder sample included with this filewill handle situations where the padding is missing. The encoded messageshould be padded with an equal sign character (=) at the end. Please referto section 5.2 of RFC 1521 for more detailed description of the Base 64Encoding standard.

NOTE: The sample includes the project files for Microsoft Visual C++ 5.0.For other development environments, simply copy over the .cpp/.h files intoyour own project. Note that the self-extracting executable is a Win32 EXE.
MORE INFORMATION
The following files are available for download from the MicrosoftDownload Center:
For additional information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:
119591 How to Obtain Microsoft Support Files from Online Services
Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help to prevent any unauthorized changes to the file.
REFERENCES
RFC 1521 : MIME (Multipurpose Internet Mail Extensions) Part One:Mechanisms for Specifying and Describing the Format of Internet MessageBodies
Properties

Article ID: 191239 - Last Review: 10/11/2006 21:16:07 - Revision: 3.1

Microsoft Internet Server Application Programming Interface 4.0, Microsoft Internet Client Software Development Kit 4.01, Microsoft Internet Information Services 5.0

  • kbdownload kbfilter kbhttp kbinfo KB191239
Feedback