Recently I came across a use case to store the license associated with a software securely in a vault. The license was a binary file. The only way to store in the secure vault was to convert it as a string.

I used the following command to convert the file into a single line base64 string.

cat <file-name> | base64 -w 0

The -w 0 option aligns the encoded string into a single line string. If you remove that option, the output will come in a block.

This will work from the command line of almost all popular Linux distributions.

I hope this tip is useful. Feel free to comment below this article if you have any queries or feedback.

Advertisement