What is encoding / decoding ?
Encoding refers to the process of translating a file into an ASCII based string.
Decoding refers to the process of decoding the ASCII based string.
In order to perform this decoding/encoding process Base64 is typically used. Base64 is a program that converts each 6 bits and then converts this to an ASCII based character out of a 64 ASCII character set. (this includes the characters of azAZ09+/.
Why would I want to do this ?
This is useful for situations were you need to transfer binary files across systems that have no network connectivity. Other applications were this is used is with SMTP which being a completely ASCII based protocol uses encoding to send any binary or not ASCII based data to the recipient.
Below we will be encoding and decoding a floppy disc image.
1. On the first machine we will be encoding the file into an ASCII based string.
Note : we use the file command to confirm the file type.
[root@host1 tmp]# file vmscsi-188.8.131.52.flp
vmscsi-184.108.40.206.flp: DOS floppy 1440k, x86 hard disk boot sector
[root@host1 tmp]# base64 vmscsi-220.127.116.11.flp > vmscsi-18.104.22.168.flp.encoded
[root@host1 tmp]# head -n3 vmscsi-22.214.171.124.flp.encoded
[root@host1 tmp]# file vmscsi-126.96.36.199.flp.encoded
vmscsi-188.8.131.52.flp.encoded: ASCII text
2. Once we have copy and pasted the ASCII text to the other machine (into the file vmscsi-184.108.40.206.flp.encoded) we decode the file back into its original floppy image format.
[root@host2 tmp]# cat vmscsi-220.127.116.11.flp.encoded | base64 -di > vmscsi-18.104.22.168.flp.decoded
[root@host2 tmp]# file vmscsi-22.214.171.124.flp.decoded
vmscsi-126.96.36.199.flp.decoded: DOS floppy 1440k, x86 hard disk boot sector
- How to Configure a BIND Server on Ubuntu - March 15, 2018
- What is a BGP Confederation? - March 6, 2018
- Cisco – What is BGP ORF (Outbound Route Filtering)? - March 5, 2018
Want to become a Linux expert?
Here is our hand-picked selection of the best courses you can find online:
Linux Mastery course
Linux Administration Bootcamp
and our recommended certification practice exams:
AlphaPrep Practice Tests - Free Trial