Base64 Encode Online
Simply enter your data then push the "Base64 Encode" button.
About Base64 Encoder
Base64 Encoder is an easy to use tool that converts text to base64 code. This tool can save your time and help encode base64 data.
You can type or paste any text data in the input text area and Base64 Encoder will convert it into base64 code.
Uses of Base64
The actual use of base64 was limited to a safe way to transmit data across machines. With time, it has been integrated into the implementation of several core Internet technologies such as encryption and file embedding.
- Data transmission: Base64 transfer and store the data while simultaneously avoiding data corruption. Even more, it transmits JSON data and cookie information to users.
- File embedding: Base64 embeds files in scripts and webpages in order to avoid dependence on external files. So, it helps to send Email attachments.
- Data obfuscation: Data hashing schemes, for example, SHA and MD5, give results that cannot be read or transmitted. Thus, hashes are mostly base64 encoded so that they can easily display and use in file integrity checks.
- Cryptography: Encrypted data contains sequences of bytes and those are not readable or transmittable. So, we often use base64 when encrypted data needs to be stored in a database or sent over the Internet. Moreover, public key certificates and certain other certification keys are also stored in base64 format.
Methods of Base64 encoding in various programming languages
"str" indicates the original text and "base64" indicates the encoded result.
Base64 Encoding in Java |
base64 = new BASE64Encoder().encode(str.getBytes()); |
Base64 Encoding in JavaScript |
base64 = btoa(str); // IE 10- Requires the introduction of base64.js
or
var s = CryptoJS.enc.Utf8.parse(str);
base64 = CryptoJS.enc.Base64.stringify(s); // Requires the introduction of CryptoJS |
Base64 Encoding in PHP |
$base64 = base64_encode($str); |
Base64 Encoding in C#/.NET |
byte[] bytes = System.Text.Encoding.UTF8.GetBytes(str);
base64 = System.Convert.ToBase64String(bytes); |
Base64 Encoding in Python |
import base64
base64 = base64.b64encode(str) |
Base64 Encoding in Perl |
use MIME::Base64;
$base64 = encode_base64($str); |
Base64 Encoding in Golang |
import b64 "encoding/base64"
...
base64 := b64.StdEncoding.EncodeToString([]byte(str)) |
Base64 Encoding in Ruby |
require "base64"
base64 = Base64.encode64(str) |
Base64 Encoding in MySQL/MariaDB |
SELECT TO_BASE64(str); |
Base64 Encoding in PostgreSQL |
SELECT encode(str, 'base64'); |
Linux Shell(Take 'test' for example) |
$ echo test | base64 // dGVzdAo= |