From 51f20c2c3352e1a534ac3167bb36b0e2dbaf3811 Mon Sep 17 00:00:00 2001
From: zzz <zzz@mail.i2p>
Date: Fri, 9 Dec 2011 13:15:19 +0000
Subject: [PATCH]   * Base64: Add decodestring command in main()

---
 core/java/src/net/i2p/data/Base64.java | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/core/java/src/net/i2p/data/Base64.java b/core/java/src/net/i2p/data/Base64.java
index d93fc080a4..6f5fc34a57 100644
--- a/core/java/src/net/i2p/data/Base64.java
+++ b/core/java/src/net/i2p/data/Base64.java
@@ -184,6 +184,19 @@ public class Base64 {
             System.out.println(encode(args[1].getBytes()));
             return;
         }
+        if ("decodestring".equals(cmd)) {
+            byte[] dec = decode(args[1]);
+            if (dec != null) {
+                try {
+                    System.out.write(dec);
+                } catch (IOException ioe) {
+                    System.err.println("output error " + ioe);
+                }
+            } else {
+                System.err.println("decode error");
+            }
+            return;
+        }
         InputStream in = System.in;
         OutputStream out = System.out;
         try {
@@ -238,6 +251,8 @@ public class Base64 {
         System.out.println("or    : Base64 decode <inFile> <outFile>");
         System.out.println("or    : Base64 decode <inFile>");
         System.out.println("or    : Base64 decode");
+        System.out.println("or    : Base64 encodestring 'string to encode'");
+        System.out.println("or    : Base64 decodestring 'string to decode'");
         System.out.println("or    : Base64 test");
     }
 
@@ -684,6 +699,7 @@ public class Base64 {
      * returns it as a string.
      * Equivlaent to calling
      * <code>new String( decode( s ) )</code>
+     * WARNING this uses the locale's encoding, it may not be what you want.
      *
      * @param s the strind to decode
      * @return The data as a string
-- 
GitLab