{"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":"

What is encoding \/ decoding ?<\/strong><\/h2>\n

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

Why would I want to do this ?<\/strong><\/h2>\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

Example<\/strong><\/h2>\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.
\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

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

[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":"

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":"\nHow to Encode \/ Decode a File - Fir3net<\/title>\n<meta name=\"description\" content=\"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\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.fir3net.com\/UNIX\/Linux\/how-to-encode-decode-a-file.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Encode \/ Decode a File - Fir3net\" \/>\n<meta property=\"og:description\" content=\"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\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.fir3net.com\/UNIX\/Linux\/how-to-encode-decode-a-file.html\" \/>\n<meta property=\"og:site_name\" content=\"Fir3net\" \/>\n<meta property=\"article:published_time\" content=\"2010-01-06T16:55:14+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-01-15T22:45:31+00:00\" \/>\n<meta name=\"author\" content=\"Rick Donato\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Rick Donato\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.fir3net.com\/UNIX\/Linux\/how-to-encode-decode-a-file.html#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.fir3net.com\/UNIX\/Linux\/how-to-encode-decode-a-file.html\"},\"author\":{\"name\":\"Rick Donato\",\"@id\":\"https:\/\/www.fir3net.com\/#\/schema\/person\/ab35009601b7687ee1c5310be6038037\"},\"headline\":\"How to Encode \/ Decode a File\",\"datePublished\":\"2010-01-06T16:55:14+00:00\",\"dateModified\":\"2023-01-15T22:45:31+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.fir3net.com\/UNIX\/Linux\/how-to-encode-decode-a-file.html\"},\"wordCount\":200,\"publisher\":{\"@id\":\"https:\/\/www.fir3net.com\/#organization\"},\"articleSection\":[\"Linux\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.fir3net.com\/UNIX\/Linux\/how-to-encode-decode-a-file.html\",\"url\":\"https:\/\/www.fir3net.com\/UNIX\/Linux\/how-to-encode-decode-a-file.html\",\"name\":\"How to Encode \/ Decode a File - Fir3net\",\"isPartOf\":{\"@id\":\"https:\/\/www.fir3net.com\/#website\"},\"datePublished\":\"2010-01-06T16:55:14+00:00\",\"dateModified\":\"2023-01-15T22:45:31+00:00\",\"description\":\"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\",\"breadcrumb\":{\"@id\":\"https:\/\/www.fir3net.com\/UNIX\/Linux\/how-to-encode-decode-a-file.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.fir3net.com\/UNIX\/Linux\/how-to-encode-decode-a-file.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.fir3net.com\/UNIX\/Linux\/how-to-encode-decode-a-file.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.fir3net.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Operating Systems\",\"item\":\"https:\/\/www.fir3net.com\/os\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Linux\",\"item\":\"https:\/\/www.fir3net.com\/os\/linux\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"How to Encode \/ Decode a File\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.fir3net.com\/#website\",\"url\":\"https:\/\/www.fir3net.com\/\",\"name\":\"Fir3net\",\"description\":\"Keeping you in the know\",\"publisher\":{\"@id\":\"https:\/\/www.fir3net.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.fir3net.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.fir3net.com\/#organization\",\"name\":\"Fir3net\",\"url\":\"https:\/\/www.fir3net.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.fir3net.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.fir3net.com\/wp-content\/uploads\/Fir3net-Background-Logo-compressed.png\",\"contentUrl\":\"https:\/\/www.fir3net.com\/wp-content\/uploads\/Fir3net-Background-Logo-compressed.png\",\"width\":390,\"height\":88,\"caption\":\"Fir3net\"},\"image\":{\"@id\":\"https:\/\/www.fir3net.com\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.fir3net.com\/#\/schema\/person\/ab35009601b7687ee1c5310be6038037\",\"name\":\"Rick Donato\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.fir3net.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/d75d69a54c0ca3b32c24c3a9703b623c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/d75d69a54c0ca3b32c24c3a9703b623c?s=96&d=mm&r=g\",\"caption\":\"Rick Donato\"},\"description\":\"Rick Donato is a Network Automation Architect\/Evangelist and the founder of Packet Coders.\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Encode \/ Decode a File - Fir3net","description":"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","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.fir3net.com\/UNIX\/Linux\/how-to-encode-decode-a-file.html","og_locale":"en_US","og_type":"article","og_title":"How to Encode \/ Decode a File - Fir3net","og_description":"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","og_url":"https:\/\/www.fir3net.com\/UNIX\/Linux\/how-to-encode-decode-a-file.html","og_site_name":"Fir3net","article_published_time":"2010-01-06T16:55:14+00:00","article_modified_time":"2023-01-15T22:45:31+00:00","author":"Rick Donato","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Rick Donato","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.fir3net.com\/UNIX\/Linux\/how-to-encode-decode-a-file.html#article","isPartOf":{"@id":"https:\/\/www.fir3net.com\/UNIX\/Linux\/how-to-encode-decode-a-file.html"},"author":{"name":"Rick Donato","@id":"https:\/\/www.fir3net.com\/#\/schema\/person\/ab35009601b7687ee1c5310be6038037"},"headline":"How to Encode \/ Decode a File","datePublished":"2010-01-06T16:55:14+00:00","dateModified":"2023-01-15T22:45:31+00:00","mainEntityOfPage":{"@id":"https:\/\/www.fir3net.com\/UNIX\/Linux\/how-to-encode-decode-a-file.html"},"wordCount":200,"publisher":{"@id":"https:\/\/www.fir3net.com\/#organization"},"articleSection":["Linux"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.fir3net.com\/UNIX\/Linux\/how-to-encode-decode-a-file.html","url":"https:\/\/www.fir3net.com\/UNIX\/Linux\/how-to-encode-decode-a-file.html","name":"How to Encode \/ Decode a File - Fir3net","isPartOf":{"@id":"https:\/\/www.fir3net.com\/#website"},"datePublished":"2010-01-06T16:55:14+00:00","dateModified":"2023-01-15T22:45:31+00:00","description":"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","breadcrumb":{"@id":"https:\/\/www.fir3net.com\/UNIX\/Linux\/how-to-encode-decode-a-file.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.fir3net.com\/UNIX\/Linux\/how-to-encode-decode-a-file.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.fir3net.com\/UNIX\/Linux\/how-to-encode-decode-a-file.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.fir3net.com\/"},{"@type":"ListItem","position":2,"name":"Operating Systems","item":"https:\/\/www.fir3net.com\/os"},{"@type":"ListItem","position":3,"name":"Linux","item":"https:\/\/www.fir3net.com\/os\/linux"},{"@type":"ListItem","position":4,"name":"How to Encode \/ Decode a File"}]},{"@type":"WebSite","@id":"https:\/\/www.fir3net.com\/#website","url":"https:\/\/www.fir3net.com\/","name":"Fir3net","description":"Keeping you in the know","publisher":{"@id":"https:\/\/www.fir3net.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.fir3net.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.fir3net.com\/#organization","name":"Fir3net","url":"https:\/\/www.fir3net.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.fir3net.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.fir3net.com\/wp-content\/uploads\/Fir3net-Background-Logo-compressed.png","contentUrl":"https:\/\/www.fir3net.com\/wp-content\/uploads\/Fir3net-Background-Logo-compressed.png","width":390,"height":88,"caption":"Fir3net"},"image":{"@id":"https:\/\/www.fir3net.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.fir3net.com\/#\/schema\/person\/ab35009601b7687ee1c5310be6038037","name":"Rick Donato","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.fir3net.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/d75d69a54c0ca3b32c24c3a9703b623c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d75d69a54c0ca3b32c24c3a9703b623c?s=96&d=mm&r=g","caption":"Rick Donato"},"description":"Rick Donato is a Network Automation Architect\/Evangelist and the founder of Packet Coders."}]}},"_links":{"self":[{"href":"https:\/\/www.fir3net.com\/wp-json\/wp\/v2\/posts\/355"}],"collection":[{"href":"https:\/\/www.fir3net.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.fir3net.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.fir3net.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.fir3net.com\/wp-json\/wp\/v2\/comments?post=355"}],"version-history":[{"count":1,"href":"https:\/\/www.fir3net.com\/wp-json\/wp\/v2\/posts\/355\/revisions"}],"predecessor-version":[{"id":3548,"href":"https:\/\/www.fir3net.com\/wp-json\/wp\/v2\/posts\/355\/revisions\/3548"}],"wp:attachment":[{"href":"https:\/\/www.fir3net.com\/wp-json\/wp\/v2\/media?parent=355"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.fir3net.com\/wp-json\/wp\/v2\/categories?post=355"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.fir3net.com\/wp-json\/wp\/v2\/tags?post=355"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}