{"id":5659,"date":"2018-07-23T22:30:51","date_gmt":"2018-07-23T20:30:51","guid":{"rendered":"https:\/\/michlstechblog.info\/blog\/?p=5659"},"modified":"2018-07-25T09:14:19","modified_gmt":"2018-07-25T07:14:19","slug":"hexdump-hexdump-a-binary-file-and-convert-it-back","status":"publish","type":"post","link":"https:\/\/michlstechblog.info\/blog\/hexdump-hexdump-a-binary-file-and-convert-it-back\/","title":{"rendered":"Hexdump: Hexdump a binary file and convert it back"},"content":{"rendered":"<div class=\"twoclick_social_bookmarks_post_5659 social_share_privacy clearfix 1.6.4 locale-en_US sprite-en_US\"><\/div><div class=\"twoclick-js\"><script type=\"text\/javascript\">\/* <![CDATA[ *\/\njQuery(document).ready(function($){if($('.twoclick_social_bookmarks_post_5659')){$('.twoclick_social_bookmarks_post_5659').socialSharePrivacy({\"services\":{\"flattr\":{\"uid\":\"Michl\",\"status\":\"on\",\"the_title\":\"Hexdump%3A%20Hexdump%20a%20binary%20file%20and%20convert%20it%20back\",\"the_excerpt\":\"Hi%2C%0D%0A%0D%0Afor%20hexdump%20%28binary%29%20files%20and%20converting%20%20back%20the%20Linux%20command%20line%20xxd%20%20works%20perfect.%0D%0A%0D%0A%20%28more%26hellip%3B%29\",\"txt_info\":\"2 clicks for more data protection:\\r\\n\\r\\nOnly when you click here, the button will be come active and you can send your recommendation to Flattr. When activating, data are transmitted to third parties. \",\"perma_option\":\"off\"}},\"txt_help\":\"When you activate these fields by clicking, information to Flattr may be transferred abroad, and probably may also stored there.\",\"settings_perma\":\"Enable permanently and accept data transmission. \",\"info_link\":\"http:\\\/\\\/www.heise.de\\\/ct\\\/artikel\\\/2-Klicks-fuer-mehr-Datenschutz-1333879.html\",\"uri\":\"https:\\\/\\\/michlstechblog.info\\\/blog\\\/hexdump-hexdump-a-binary-file-and-convert-it-back\\\/\",\"post_id\":5659,\"post_title_referrer_track\":\"Hexdump%3A+Hexdump+a+binary+file+and+convert+it+back\",\"display_infobox\":\"on\"});}});\n\/* ]]> *\/<\/script><\/div><p>Hi,<\/p>\n<p>for hexdump (binary) files and converting <strong> back the Linux command line xxd <\/strong> works perfect.<\/p>\n<p><!--more--><br \/>\nSome examples. A hexdump of a xml file umts.xml<br \/>\n<code><br \/>\n&lt;?xml version=\"1.0\" encoding=\"iso-8859-1\"?&gt;<br \/>\n&lt;umts&gt;<br \/>\n&lt;settings&gt;<br \/>\n&lt;PIN\/&gt;<br \/>\n&lt;AllowRoaming&gt;0&lt;\/AllowRoaming&gt;<br \/>\n&lt;HomeNetwork\/&gt;<br \/>\n&lt;SIM\/&gt;<br \/>\n&lt;\/settings&gt;<br \/>\n&lt;\/umts&gt;<br \/>\n<\/code><\/p>\n<p>Convert the XML file to hexdump format<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nmichael@debdev ~ # xxd umts.xml\r\n00000000: 3c3f 786d 6c20 7665 7273 696f 6e3d 2231  &lt;?xml version=&quot;1\r\n00000010: 2e30 2220 656e 636f 6469 6e67 3d22 6973 .0&quot; encoding=&quot;is \r\n00000020: 6f2d 3838 3539 2d31 223f 3e0a 3c75 6d74 o-8859-1&quot;?&gt;.&lt;umt \r\n00000030: 733e 0a3c 7365 7474 696e 6773 3e0a 3c50 s&gt;.&lt;settings&gt;.&lt;P\r\n....\r\nmichael@debdev ~ # xxd umts.xml &gt; umts.hex\r\n<\/pre>\n<p>Or convert it to an &#8220;simple&#8221; hex format<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nmichael@debdev ~ # xxd -p umts.xml\r\n3c3f786d6c2076657273696f6e3d22312e302220656e636f64696e673d22\r\n69736f2d383835392d31223f3e0a3c756d74733e0a3c73657474696e6773\r\n3e0a3c50494e2f3e0a3c416c6c6f77526f616d696e673e303c2f416c6c6f\r\n....\r\nmichael@debdev ~ # xxd umts.xml &gt; umts_simple.hex\r\n<\/pre>\n<p>And reverse the &#8220;simple&#8221; hex format<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nmichael@debdev ~ # cat umts_simple.hex\r\n3c3f786d6c2076657273696f6e3d22312e302220656e636f64696e673d22\r\n69736f2d383835392d31223f3e0a3c756d74733e0a3c73657474696e6773\r\n3e0a3c50494e2f3e0a3c416c6c6f77526f616d696e673e303c2f416c6c6f\r\n....\r\nmichael@debdev ~ # xxd -r -p umts_simple.hex\r\n&lt;?xml version=&quot;1.0&quot; encoding=&quot;iso-8859-1&quot;?&gt;\r\n&lt;umts&gt;\r\n&lt;settings&gt;\r\n&lt;PIN\/&gt;\r\n&lt;AllowRoaming&gt;0&lt;\/AllowRoaming&gt;\r\n&lt;HomeNetwork\/&gt;\r\n.....\r\n<\/pre>\n<p>And from hexdump format<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nmichael@debdev ~ # cat umts.hex\r\n00000000: 3c3f 786d 6c20 7665 7273 696f 6e3d 2231 &lt;?xml version=&quot;1\r\n00000010: 2e30 2220 656e 636f 6469 6e67 3d22 6973 .0&quot; encoding=&quot;is\r\n00000020: 6f2d 3838 3539 2d31 223f 3e0a 3c75 6d74 o-8859-1&quot;?&gt;.&lt;umt\r\n00000030: 733e 0a3c 7365 7474 696e 6773 3e0a 3c50 s&gt;.&lt;-------\r\nmichael@debdev ~ # xxd -r umts.hex\r\n&lt;?xml version=&quot;1.0&quot; encoding=&quot;iso-8859-1&quot;?&gt;\r\n&lt;umts&gt;\r\n&lt;settings&gt;\r\n&lt;PIN\/&gt;\r\n&lt;AllowRoaming&gt;0&lt;\/AllowRoaming&gt;\r\n&lt;HomeNetwork\/&gt;\r\n....\r\n<\/pre>\n<p>Michael<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi, for hexdump (binary) files and converting back the Linux command line xxd works perfect.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,9],"tags":[450,1221,1222,1220],"class_list":["post-5659","post","type-post","status-publish","format-standard","hentry","category-linux","category-scripting","tag-convert","tag-convert-hexdump-to-binary","tag-create-hexdump","tag-hex-to-binary"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts\/5659","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/comments?post=5659"}],"version-history":[{"count":10,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts\/5659\/revisions"}],"predecessor-version":[{"id":5689,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts\/5659\/revisions\/5689"}],"wp:attachment":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/media?parent=5659"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/categories?post=5659"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/tags?post=5659"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}