Revision: 1948
          http://svn.sourceforge.net/vexi/?rev=1948&view=rev
Author:   mkpg2
Date:     2007-07-08 09:34:35 -0700 (Sun, 08 Jul 2007)

Log Message:
-----------
Oops forgot this. Adding hex encoding. Used when representing md5 hash.

Modified Paths:
--------------
    core/branches/vexi2/org.ibex.util/src/org/ibex/util/Encode.java

Modified: core/branches/vexi2/org.ibex.util/src/org/ibex/util/Encode.java
===================================================================
--- core/branches/vexi2/org.ibex.util/src/org/ibex/util/Encode.java     
2007-07-08 16:18:18 UTC (rev 1947)
+++ core/branches/vexi2/org.ibex.util/src/org/ibex/util/Encode.java     
2007-07-08 16:34:35 UTC (rev 1948)
@@ -115,7 +115,29 @@
         }
     }
 
+    public static String bytesToHex(byte[] data) {
+        StringBuffer buf = new StringBuffer();
+        for (int i = 0; i < data.length; i++) {
+            buf.append(byteToHex(data[i]).toUpperCase());
+        }
+        return (buf.toString());
+    }
 
+    public static String byteToHex(byte data) {
+        StringBuffer buf = new StringBuffer();
+        buf.append(toHexChar((data >>> 4) & 0x0F));
+        buf.append(toHexChar(data & 0x0F));
+        return buf.toString();
+    }
+
+    public static char toHexChar(int i) {
+        if ((0 <= i) && (i <= 9)) {
+            return (char) ('0' + i);
+        } else {
+            return (char) ('a' + (i - 10));
+        }
+    }
+    
     private static final byte[] encB64 = {
         (byte)'A', (byte)'B', (byte)'C', (byte)'D', (byte)'E', (byte)'F', 
(byte)'G',
         (byte)'H', (byte)'I', (byte)'J', (byte)'K', (byte)'L', (byte)'M', 
(byte)'N',


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Vexi-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/vexi-svn

Reply via email to