Encode a Computer File Into a Base64 Encoded Text File

Text files can be stored as text, of course. But what if there was a way to store any other kind of file as text? This would mean that, for instance, if your webmail didn't allow attachments, you would still be able to send them the file!

Base64 encoding has been around since the dawn of the internet. Users in newsgroups, the Usenet, have been using base64 encoding to post files in normal message long before attachments were allowed.

We'll use a tiny program to do the conversion for us. There may be others out there that do the same thing. But this one, base64, is simple and free.

Steps

  1. Get a program that converts files to base64. See the External Links section.
  2. Find the directory that you put the base64.exe program in
  3. Create a new text file (using Windows Notepad is better than MS Word) in that same directory and name it DropOnMe.bat
  4. Open the file and put the following text into it as the contents:
    base64 -e %1 test.b64
    pause
  5. Save the file and close it.
  6. Now drag-and-drop any non-text file (i.e. binary) onto the icon of the BAT file you just created.
  7. A DOS window will pop up. If there was an error during conversion, you'll see it. (Sorry, but I don't have the time to construct instructions on how to interpret the text in the DOS window).
  8. Pause will be the last command, and it is what is causing the window to stay open. Hit the [Enter] key and the window will disappear.
  9. You should now find a file called test.b64 in the folder you've been working in. Inside it is the text that is the base64 "version" of the binary file you dropped onto the icon.

Tips

  • Creating the batch file (i.e. the file whose name ends in .bat) is actually not necessary, but just very convenient. By creating it, you don't have to memorize the command syntax to type the command directly. And if you knew how to do such things anyway, you wouldn't need this article, probably ;-).
  • You should make sure that you have the Windows option for hiding file extensions turned off. If you don't know what I'm talking about, then you probably don't have the skills to do this WikiHow. Sorry.
  • If you don't use the same base64 program referenced here, you may need to alter how you work with it. Hopefully it came with documentation you understand!
  • You may omit the second line of that DropOnMe.bat file once you find that everything is working fine. If there are no errors, then you don't need to see that everything worked. I included it just for confirmation.
  • In the sample file (DropOnMe.bat), I set the name of the output/result file to test.b64, but you can change that to whatever you want. Result.b64 might be a good alternative.

Warnings

  • This is a pretty safe procedure. You'd really have to screw something up royally for any of the actions described in this tutorial to harm your computer!

Things You'll Need

  • A program that converts files to base64-encoded text. See External Links section for more info.

Related Articles

References