Page 1 of 1

Base64 encoding and decoding

Posted: 2023 May 03, 19:04
by Mihai
We have the file test.txt with the following content

Code: Select all

$ cat test.txt
123
321
Encode the file

Code: Select all

$ base64 test.txt > test.txt.base64
$ cat test.txt.base64
MTIzCjMyMQo=
The content for the new file changed
To decode the file to its original form, execute the command

Code: Select all

$ base64 -d test.txt.base64
123
321
For the encoding[1] and decoding[2] of an archive type file we have the following example

Code: Select all

[1]$ tar czvf - folder | base64 > folder.tar.tgz.b64
[2]$ base64 -d folder.tar.tgz.b64 | tar xzvf -