← Lessons/Encoding, Hashing, HMAC & Encryption
← Encoding, Hashing, HMAC & Encryption

Encoding is reversible by anyone

Learn

Encoding is not encryption

Base64 turns arbitrary bytes into 64 "safe" printable characters (A–Z a–z 0–9 + /, with = as padding) so binary data can travel through text-only channels: HTTP headers, JSON, YAML, email. It has no key, so anyone can reverse it.

printf 'deploy:prod' | base64        # ZGVwbG95OnByb2Q=
printf 'ZGVwbG95OnByb2Q=' | base64 -d  # deploy:prod

That's why a Kubernetes Secret or an HTTP Authorization: Basic … header protects nothing on its own: the value is base64, and anyone who sees it can decode it. Use printf, not echo. echo appends a newline, and that newline gets encoded too.

Base64-encode the exact string deploy:prod (no trailing newline) and print the result. Then decode that base64 back and print the original.

$ bash solution.sh
Loading...

Output

Run your solution to see its output here.