Bootstrap FreeKB - Linux Commands - base64 command
Linux Commands - base64 command

Updated:   |  Linux Commands articles

The base64 command is used to encode or decode a base 64 string. In this example, "Hello World" is encoded.

~]$ echo "Hello World" | base64
SGVsbG8gV29ybGQK

 

The -d or --decode option is used to decode an encoded string. 

~]$ echo SGVsbG8gV29ybGQK | base64 --decode
Hello World

 

The base64 command can also be used to convert a .pfx or .p12 file into a base 64 string.

~]# base64 foo.pfx
MIIbaAIBAzCCGyEGCSqGSIb3DQEHAaCCGxIEghsOMIIbCjCCBeYGCSqGSIb3DQEHAaCCBdcEggXT
MIIFzzCCBcsGCyqGSIb3DQEMCgECoIIE8zCCBO8wKQYKKoZIhvcNAQwBAzAbBBQmzsoyWZwqKd0v
dYnOXssQp . . .

 

By default, the output will be split at every 77th character. The following sed command can be used if you want the output to be inline.

~]# base64 foo.pfx | sed ':label; N; $! b label; s|\n||g'
MIIbaAIBAzCCGyEGCSqGSIb3DQEHAaCCGxIEghsOMIIbCjCCBeYGCSqGSIb3DQEHAaCCBdcEggXTMIIFzzCCBcsGC...

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter e8c002 in the box below so that we can be sure you are a human.