Base64 encoding is used to transmit binary data in an ASCII format. Typical usage is to embed image data within scripts such as CSS.
Various programming languages allow you to encode binary data (or even text) using built in APIs. For instance, in C#
ToBase64String method of
System.Convert class does this. This method takes a byte array as input. Typically this is some sort of binary data that cannot be transferred over the wire without corruption. However, you can also convert text into byte and then encode it using base64. You should question why this is needed because it is not the intended use of Base-64 encoding. In this form, you are just wasting bytes to represent your text data.
Checkout the Programming Languages section below for a list of APIs for other languages. Read more at wikipedia