From 1690b6bf588cf9d0128a17b92e228e01c81b7711 Mon Sep 17 00:00:00 2001 From: hns Date: Mon, 28 Oct 2002 16:46:10 +0000 Subject: [PATCH] Fixed a bug that dropped some zeros in the message digest. Added a method that directly takes a byte array as input. --- src/helma/util/MD5Encoder.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/helma/util/MD5Encoder.java b/src/helma/util/MD5Encoder.java index 32b296fd..82b43754 100644 --- a/src/helma/util/MD5Encoder.java +++ b/src/helma/util/MD5Encoder.java @@ -22,12 +22,16 @@ public class MD5Encoder { } public static String encode(String str) throws NoSuchAlgorithmException { + return encode (str.getBytes()); + } + + public static String encode(byte[] message) throws NoSuchAlgorithmException { md = MessageDigest.getInstance("MD5"); - byte[] b = md.digest(str.getBytes()); - StringBuffer buf = new StringBuffer(); + byte[] b = md.digest(message); + StringBuffer buf = new StringBuffer(b.length*2); for ( int i=0; i