{"id":1544,"date":"2022-05-18T08:54:19","date_gmt":"2022-05-17T20:54:19","guid":{"rendered":"https:\/\/www.ronella.xyz\/?p=1544"},"modified":"2022-05-18T08:54:19","modified_gmt":"2022-05-17T20:54:19","slug":"java-utf-16le-base64-codec","status":"publish","type":"post","link":"https:\/\/www.ronella.xyz\/?p=1544","title":{"rendered":"Java UTF-16LE Base64 CODEC"},"content":{"rendered":"<p>The UTF-16LE base64 encoding is compatible to be used with powershell's encoded command.<\/p>\n<h2>Encoding<\/h2>\n<pre><code class=\"language-java\">\/\/The text to encode.\nvar command = &quot;Write-Output \\&quot;Hello World\\&quot;&quot;;\nvar encodedString = Base64.getEncoder().encodeToString(command.getBytes(StandardCharsets.UTF_16LE));\nSystem.out.printf(&quot;Base64: %s%n&quot;, encodedString);<\/code><\/pre>\n<h3>Output<\/h3>\n<pre><code>Base64: VwByAGkAdABlAC0ATwB1AHQAcAB1AHQAIAAiAEgAZQBsAGwAbwAgAFcAbwByAGwAZAAiAA==<\/code><\/pre>\n<blockquote>\n<p>The preceding output can be used with powershell like the following:<\/p>\n<pre><code class=\"language-xml-dtd\">powershell -encodedcommand VwByAGkAdABlAC0ATwB1AHQAcAB1AHQAIAAiAEgAZQBsAGwAbwAgAFcAbwByAGwAZAAiAA==<\/code><\/pre>\n<\/blockquote>\n<h2>Decoding<\/h2>\n<pre><code class=\"language-java\">\/\/The base64 text to decode.\nvar base64=&quot;VwByAGkAdABlAC0ATwB1AHQAcAB1AHQAIAAiAEgAZQBsAGwAbwAgAFcAbwByAGwAZAAiAA==&quot;;\nbyte[] decodedBytes = Base64.getDecoder().decode(base64);\nString decodedString = new String(decodedBytes, StandardCharsets.UTF_16LE);\nSystem.out.printf(&quot;Decoded: %s%n&quot;, decodedString);<\/code><\/pre>\n<h3>Output<\/h3>\n<pre><code>Decoded: Write-Output &quot;Hello World&quot;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>The UTF-16LE base64 encoding is compatible to be used with powershell&#8217;s encoded command. Encoding \/\/The text to encode. var command = &quot;Write-Output \\&quot;Hello World\\&quot;&quot;; var encodedString = Base64.getEncoder().encodeToString(command.getBytes(StandardCharsets.UTF_16LE)); System.out.printf(&quot;Base64: %s%n&quot;, encodedString); Output Base64: VwByAGkAdABlAC0ATwB1AHQAcAB1AHQAIAAiAEgAZQBsAGwAbwAgAFcAbwByAGwAZAAiAA== The preceding output can be used with powershell like the following: powershell -encodedcommand VwByAGkAdABlAC0ATwB1AHQAcAB1AHQAIAAiAEgAZQBsAGwAbwAgAFcAbwByAGwAZAAiAA== Decoding \/\/The base64 text to decode. var [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[47,18],"tags":[],"_links":{"self":[{"href":"https:\/\/www.ronella.xyz\/index.php?rest_route=\/wp\/v2\/posts\/1544"}],"collection":[{"href":"https:\/\/www.ronella.xyz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ronella.xyz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ronella.xyz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ronella.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1544"}],"version-history":[{"count":1,"href":"https:\/\/www.ronella.xyz\/index.php?rest_route=\/wp\/v2\/posts\/1544\/revisions"}],"predecessor-version":[{"id":1545,"href":"https:\/\/www.ronella.xyz\/index.php?rest_route=\/wp\/v2\/posts\/1544\/revisions\/1545"}],"wp:attachment":[{"href":"https:\/\/www.ronella.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1544"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ronella.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1544"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ronella.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1544"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}