{"id":4935,"date":"2023-03-29T22:20:00","date_gmt":"2023-03-30T03:20:00","guid":{"rendered":"https:\/\/www.incredigeek.com\/home\/?p=4935"},"modified":"2023-03-31T22:15:44","modified_gmt":"2023-04-01T03:15:44","slug":"decoding-base64-atob-in-javascript-nodejs","status":"publish","type":"post","link":"https:\/\/www.incredigeek.com\/home\/decoding-base64-atob-in-javascript-nodejs\/","title":{"rendered":"Decoding base64 &#8220;atob&#8221; in Javascript NodeJS"},"content":{"rendered":"\n<p>atob() is a javascript function that decodes base64 encoded text. btoa() is the encoding function. We can use NodeJS to dedcode atob() functions.  For instance, we can lanch nodejs woth<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">nodejs<\/pre>\n\n\n\n<p>and decode the sting SGVsbG8gV29ybGQgIQ==<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">console.log(atob(\"SGVsbG8gV29ybGQgIQ==\"));<\/pre>\n\n\n\n<p>If we wanted to break that down into a couple variables we can do something like the following.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">> var b64 = atob(\"SGVsbG8gV29ybGQgIQ==\")\n> console.log(b64\");<\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2023\/03\/image-14.png\"><img loading=\"lazy\" decoding=\"async\" width=\"695\" height=\"237\" src=\"https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2023\/03\/image-14.png\" alt=\"\" class=\"wp-image-4940\" srcset=\"https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2023\/03\/image-14.png 695w, https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2023\/03\/image-14-300x102.png 300w, https:\/\/www.incredigeek.com\/home\/wp-content\/uploads\/2023\/03\/image-14-500x171.png 500w\" sizes=\"auto, (max-width: 695px) 100vw, 695px\" \/><\/a><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>You can also create a javascript file and then run the file with nodejs.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">var b64 = atob(atob(\"U0dWc2JHOGdWMjl5YkdRZ0lRPT0=\"))\n\nconsole.log(b64);<\/pre>\n\n\n\n<p>We can then run the file with <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">nodejs .\/file.js<\/pre>\n\n\n\n<p>In the file the string &#8220;Hello World !&#8221; is double encoded so we process it twice with the &#8220;atob(atob(base64);&#8221; <\/p>\n\n\n\n<p>There is more info available at the following links<\/p>\n\n\n\n<p><a href=\"https:\/\/www.npmjs.com\/package\/atob\">https:\/\/www.npmjs.com\/package\/atob<\/a><br><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/atob\">https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/atob<\/a><\/p>\n\n\n\n<p>Check out the following article if you want to use Python to decode base64.<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-wp-embed is-provider-incredigeek wp-block-embed-incredigeek\"><div class=\"wp-block-embed__wrapper\">\n<blockquote class=\"wp-embedded-content\" data-secret=\"tNDfVfo7Wh\"><a href=\"https:\/\/www.incredigeek.com\/home\/decode-base64-in-python\/\">Decode base64 in python<\/a><\/blockquote><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"&#8220;Decode base64 in python&#8221; &#8212; Incredigeek\" src=\"https:\/\/www.incredigeek.com\/home\/decode-base64-in-python\/embed\/#?secret=FtsXbiTAKe#?secret=tNDfVfo7Wh\" data-secret=\"tNDfVfo7Wh\" width=\"584\" height=\"329\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\n<\/div><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>atob() is a javascript function that decodes base64 encoded text. btoa() is the encoding function. We can use NodeJS to dedcode atob() functions. For instance, we can lanch nodejs woth nodejs and decode the sting SGVsbG8gV29ybGQgIQ== console.log(atob(&#8220;SGVsbG8gV29ybGQgIQ==&#8221;)); If we wanted &hellip; <a href=\"https:\/\/www.incredigeek.com\/home\/decoding-base64-atob-in-javascript-nodejs\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[420],"tags":[1438,953,954,1437,1436],"class_list":["post-4935","post","type-post","status-publish","format-standard","hentry","category-hacking","tag-atob","tag-base64","tag-decode","tag-javascript","tag-nodejs"],"_links":{"self":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/4935","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/comments?post=4935"}],"version-history":[{"count":2,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/4935\/revisions"}],"predecessor-version":[{"id":4941,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/4935\/revisions\/4941"}],"wp:attachment":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/media?parent=4935"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/categories?post=4935"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/tags?post=4935"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}