File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
1010
1111For a steady stream of TILs, [ sign up for my newsletter] ( https://crafty-builder-6996.ck.page/e169c61186 ) .
1212
13- _ 1426 TILs and counting..._
13+ _ 1427 TILs and counting..._
1414
1515---
1616
@@ -1376,6 +1376,7 @@ _1426 TILs and counting..._
13761376- [ Fix Unlinked Node Binaries With asdf] ( unix/fix-unlinked-node-binaries-with-asdf.md )
13771377- [ Forward Multiple Ports Over SSH] ( unix/forward-multiple-ports-over-ssh.md )
13781378- [ Generate A SAML Key And Certificate Pair] ( unix/generate-a-saml-key-and-certificate-pair.md )
1379+ - [ Generate Base64 Encoding Without Newlines] ( unix/generate-base64-encoding-without-newlines.md )
13791380- [ Generate Random 20-Character Hex String] ( unix/generate-random-20-character-hex-string.md )
13801381- [ Get A List Of Locales On Your System] ( unix/get-a-list-of-locales-on-your-system.md )
13811382- [ Get Matching Filenames As Output From Grep] ( unix/get-matching-filenames-as-output-from-grep.md )
Original file line number Diff line number Diff line change 1+ # Generate Base64 Encoding Without Newlines
2+
3+ There are a variety of tools that can generate a Base64 encoding of given text.
4+ Most of them that I've encountered have a number of characters at which they
5+ introduce a newline character. Here is ` openssl ` as an example:
6+
7+ ``` bash
8+ ❯ echo " here is a long bit of text to base64 encode with openssl" | openssl base64
9+ aGVyZSBpcyBhIGxvbmcgYml0IG9mIHRleHQgdG8gYmFzZTY0IGVuY29kZSB3aXRo
10+ IG9wZW5zc2wK
11+ ```
12+
13+ [ The theory I've seen] ( https://superuser.com/a/1225139 ) is that this is to
14+ accommodate 80-character terminal screens when chunks of encoding were included
15+ in emails.
16+
17+ With the ` openssl base64 ` command, there is not an option to exclude the
18+ newlines, but we can pipe it through ` tr ` to remove them.
19+
20+ ``` bash
21+ ❯ echo " here is a long bit of text to base64 encode with openssl" | \
22+ openssl base64 | \
23+ tr -d ' \n'
24+ aGVyZSBpcyBhIGxvbmcgYml0IG9mIHRleHQgdG8gYmFzZTY0IGVuY29kZSB3aXRoIG9wZW5zc2wK
25+ ```
You can’t perform that action at this time.
0 commit comments