title: Hex to Base64 Conversion
body: <p>I tried to follow the few examples on web to convert Hex value into Base64 and failed. 
  <a href="https://stackoverflow.com/questions/33704327/hex-to-base64-convertion">Hex to Base64 convertion</a></p>
  
  <p><a href="http://tomeko.net/online_tools/hex_to_base64.php?lang=en" rel="nofollow noreferrer">http://tomeko.net/online_tools/hex_to_base64.php?lang=en</a></p>
  
  <p>I need to compare eTag value of a an AWS object and Google Cloud Storage MD5 values. 
  <code>base64(eTag)=GCS_MD5</code>.
  <code>eTag:6a95b4dd5419f2ffb9f655309c931cb0</code> and <code>MD5:apW03VQZ8v+59lUwnJMcsA==</code>
  How can I convert Hex to Base64? </p>
  
  <p>I tried various examples from stack-overflow but still could not do that.</p>
  
  <pre><code>public static void main(String[] args) throws IOException {
      String hexadecimal = "6a95b4dd5419f2ffb9f655309c931cb0";
      System.out.println("hexadecimal: " + hexadecimal);
      String binaryNum = hexToBin(hexadecimal);
      System.out.println("" + binaryNum + ", length:" + binaryNum.length());
      byte[] encoded = Base64.encodeBase64(binaryNum.getBytes());
      byte[] decoded = Base64.decodeBase64(binaryNum.getBytes());
      System.out.println("encoded: " + Base64.isBase64(encoded));
      System.out.println("decoded: " + Base64.isBase64(decoded));
      System.out.println(Arrays.toString(encoded));
      String encodedString = new String(encoded);
      System.out.println(binaryNum + " = " + encodedString);
  
      String decodedString = new String(decoded);
      System.out.println(binaryNum + " = " + decodedString);
  
      System.out.println("ByteEncoding::" + base64Encode(binaryNum.getBytes()));
      System.out.println("ByteDecoding::" + base64Decode(binaryNum));
  }
  </code></pre>