Excerpt§
If you want to encode or decode a string to Base64 from your command line, there are some simple steps to follow. Here are some practical ways to achieve this on different operating systems and shells.
Encoding String to Base64§
Encoding in Windows§
Open your command prompt.
Type the following command, replacing
input_file
andoutput_file
with your desired inputs and outputs:1certutil -encode input_file output_file
shellFor example, to encode a string, you can use the following command:
1echo -n "IToolkit" | certutil -encode -
shell
Encoding in Linux§
Open your terminal.
Type the following command, replacing
input_file
andoutput_file
with your desired inputs and outputs:1base64 input_file -w 0 > output_file
shellFor example, to encode a string, you can use the following command:
1echo -n "IToolkit" | base64
shell
Encoding in Mac§
Open your terminal.
Type the following command, replacing
input_file
andoutput_file
with your desired inputs and outputs:1base64 -i input_file -o output_file
shellFor example, to encode a string, you can use the following command:
1echo -n "IToolkit" | base64
shell
Encoding in Shell§
Open your shell.
Type the following command, replacing
input_file
andoutput_file
with your desired inputs and outputs:1openssl enc -base64 -in input_file -out output_file
shellFor example, to encode a string, you can use the following command:
1echo -n "IToolkit" | openssl enc -base64
shell
The free Base64 Encode verification tool is as follows:§
Decoding Base64 to String§
Decoding in Windows§
Open your command prompt.
Type the following command, replacing
input_file
andoutput_file
with your desired inputs and outputs:1certutil -decode input_file output_file
shellFor example, to decode a string, you can use the following command:
1echo -n "SVRvb2xraXQ=" | certutil -decodehex -
shell
Decoding in Linux§
Open your terminal.
Type the following command, replacing
input_file
andoutput_file
with your desired inputs and outputs:1base64 -d input_file -w 0 > output_file
shellFor example, to decode a string, you can use the following command:
1echo -n "SVRvb2xraXQ=" | base64 -d
shell
Decoding in Mac§
Open your terminal.
Type the following command, replacing
input_file
andoutput_file
with your desired inputs and outputs:1base64 -D -i input_file -o output_file
shellFor example, to decode a string, you can use the following command:
1echo -n "SVRvb2xraXQ=" | base64 -D
shell
Decoding in Shell§
Open your shell.
Type the following command, replacing
input_file
andoutput_file
with your desired inputs and outputs:1openssl enc -base64 -d -in input_file -out output_file
shellFor example, to decode a string, you can use the following command:
1echo -n "SVRvb2xraXQ=" | openssl enc -base64 -d
shell
The free Base64 Decode verification tool is as follows:§
Precautions when Using§
- Be careful with sensitive information; Base64 is not encryption.
- Always double-check if you typed the correct syntax for your command.
- Don’t forget to check if the output is correct.
In conclusion, encoding and decoding from Base64 in the command line is a practical skill that is useful in various contexts. By following these simple steps, you can easily encode and decode strings in Base64. Just be sure to follow the noted precautions to avoid any potential issues.