Sample Base 64 Encoding and Decoding

ID: Q191239


The information in this article applies to:
  • Microsoft Internet Server Application Programming Interface (API)
  • Internet Client SDK, version 4.01


SUMMARY

B64_samp.exe is a sample that shows how to programmatically encode and decode Base 64 encoding mechanism. This encoding mechanism was introduced for use with Multipurpose Internet Mail Extensions (MIME). It is the default mechanism used when authenticating in clear text (Basic Authentication) between a Web browser and a Web server.

The sample is in the form of a simple Win32 command line application. Usage is 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 for Base 64 requires that each line of the encoded message not be greater than 76 characters. After 76 characters, the message must have a hard line break inserted (that is, carriage return + line feed). Furthermore, the encoded message when fed into a decoder must be padded so that the total number of characters be divisible by 4. The decoder sample included with this file will handle situations where the padding is missing. The encoded message should be padded with an equal sign character (=) at the end. Please refer to section 5.2 of RFC 1521 for more detailed description of the Base 64 Encoding 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 into your own project. Note that the self-extracting executable is a Win32 EXE.


MORE INFORMATION

The following files are available for download from the Microsoft Download Center. Click the file names below to download the files:

B64_samp.exe
For more information about how to download files from the Microsoft Download Center, please visit the Download Center at the following Web address
http://www.microsoft.com/downloads/search.asp
and then click How to use the Microsoft Download Center.


REFERENCES

For additional information, please see the following article(s) in the Microsoft Knowledge Base:

Q179323 Encoding and Decoding: Overview and List of Third-Party Vendors


RFC 1521 : MIME (Multipurpose Internet Mail Extensions) Part One: Mechanisms for Specifying and Describing the Format of Internet Message Bodies

Additional query words:

Keywords : kbfile kbsample
Version : WINDOWS:4.01; winnt:
Platform : WINDOWS winnt
Issue type : kbinfo


Last Reviewed: December 8, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.