{"id":355,"date":"2010-01-06T16:55:14","date_gmt":"2010-01-06T16:55:14","guid":{"rendered":"https:\/\/fir3netwp.gmsrrpobkbd.com\/2010\/01\/06\/how-to-encode-decode-a-file\/"},"modified":"2023-01-15T22:45:31","modified_gmt":"2023-01-15T22:45:31","slug":"how-to-encode-decode-a-file","status":"publish","type":"post","link":"https:\/\/www.fir3net.com\/UNIX\/Linux\/how-to-encode-decode-a-file.html","title":{"rendered":"How to Encode \/ Decode a File"},"content":{"rendered":"
Encoding refers to the process of translating a file into an ASCII based string.
\nDecoding refers to the process of decoding the ASCII based string.<\/p>\n
In order to perform this decoding\/encoding process Base64 is typically used. Base64 is a program that\u00a0 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+\/.<\/p>\n
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<\/a> which being a completely ASCII based protocol uses encoding to send any binary or not ASCII based data to the recipient.<\/p>\n Below we will be encoding and decoding a floppy disc image.<\/p>\n 1. On the first machine we will be encoding the file into an ASCII based string. 2. Once we have copy and pasted the ASCII text to the other machine (into the file vmscsi-1.2.0.4.flp.encoded) we decode the file back into its original floppy image format.<\/p>\n 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\u00a0 converts each 6 bits and then converts this … Read more<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[52],"tags":[],"yoast_head":"\nExample<\/strong><\/h2>\n
\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Note : we use the file command to confirm the file type.\u00a0 <\/em><\/p>\n[root@host1 tmp]# file vmscsi-1.2.0.4.flp\r\nvmscsi-1.2.0.4.flp: DOS floppy 1440k, x86 hard disk boot sector\r\n[root@host1 tmp]# base64 vmscsi-1.2.0.4.flp > vmscsi-1.2.0.4.flp.encoded\r\n[root@host1 tmp]# head -n3 vmscsi-1.2.0.4.flp.encoded\r\n6zyQTVNET1M1LjAAAgEBAALgAEAL8AkAEgACAAAAAAAAAAAAAAApUpcW7E5PIE5BTUUgICAgRkFU\r\nMTIgICAzyY7RvPB7jtm4ACCOwPy9AHw4TiR9JIvBmeg8AXIcg+s6ZqEcfCZmOwcmilf8dQaAygKI\r\nVgKAwxBz6zPJikYQmPdmFgNGHBNWHgNGDhPRi3YRYIlG\/IlW\/rggAPfmi14LA8NI9\r\n[root@host1 tmp]# file vmscsi-1.2.0.4.flp.encoded\r\nvmscsi-1.2.0.4.flp.encoded: ASCII text<\/pre>\n
[root@host2 tmp]# cat vmscsi-1.2.0.4.flp.encoded | base64 -di > vmscsi-1.2.0.4.flp.decoded\r\n[root@host2 tmp]# file\u00a0 vmscsi-1.2.0.4.flp.decoded\r\nvmscsi-1.2.0.4.flp.decoded: DOS floppy 1440k, x86 hard disk boot sector<\/pre>\n","protected":false},"excerpt":{"rendered":"