Online Base64 Encode/Decode (Encrypt/Decrypt)

Base64 Encoding Principles

  1. Partition Data: Divide the binary data to be encoded into blocks of 6 bits each.
  2. Convert to Integers: Convert each 6-bit block into an integer value ranging from 0 to 63.
  3. Map to Character Set: Use a character set with 64 characters, mapping each integer value to the corresponding character.
  4. Padding: If the original data's length is not a multiple of 3, add 1 to 2 additional bytes at the end and use one or two equal signs ('=') in the Base64 encoding to ensure a length that is a multiple of 4.

Base64 Decoding Principles

  1. Character to Integer: Map Base64 encoded characters back to integer values.
  2. Integer to Binary Blocks: Convert integer values back to 6-bit binary blocks.
  3. Combine Blocks: Assemble all binary blocks to form the original binary data.

Base64 Encoding and Decoding Example

Original Data: Hello, World!
ASCII Codes: 72 101 108 108 111 44 32 87 111 114 108 100 33
Binary Data: 01001000 01100101 01101100 01101100 01101111 00101100 00100000 01010111 01101111 01110010 01101100 01100100 00100001
Base64 Encoding: SGVsbG8sIFdvcmxkIQ==

Related Tools