Decodex

Why Base64 output differs between echo and a web encoder

Trace the difference to the final byte. Compare OK with no newline, a Unix LF and a Windows CRLF, then reproduce the exact input in a shell.

Decode both results before changing settings

A typical echo OK command writes a newline after OK. Typing OK into a web text box usually supplies only the two letters. Decode both outputs and compare the byte counts to distinguish a different input from a different encoding setting.

Read the last byte of each sample

The first visible line of all three decoded examples says OK. Their lengths are two, three and four bytes. LF is 0A and CRLF is 0D 0A. Looking at the padding alone cannot tell you which line ending the original file contained.

Input bytes and Base64 output
InputBytes in hexadecimalBase64
OK4F 4BT0s=
OK + LF4F 4B 0AT0sK
OK + CRLF4F 4B 0D 0AT0sNCg==

Repeat with controlled input

Run printf %s OK | base64 for a two-byte input and an output of T0s=. For a whole file, read it directly rather than moving its contents through an editor that normalizes newlines. Line wrapping added to the encoded output is a separate operation from a newline inside the original text.

Open the text decoder

Related guides

References

More online tools

Convert images, test your keyboard, and use other handy tools in your browser.

Explore Altomono tools