From 0c848916b76d15982ad7eb8451f99a0fd0cdb3ea Mon Sep 17 00:00:00 2001 From: Matt Tucker Date: Fri, 26 Aug 2005 16:49:25 +0000 Subject: [PATCH] New encodeHex. git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2720 b35dd754-fafc-0310-a699-88a17e54d16e --- .../jivesoftware/smack/util/StringUtils.java | 29 ++++++++----------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/source/org/jivesoftware/smack/util/StringUtils.java b/source/org/jivesoftware/smack/util/StringUtils.java index 740827c37..b8a32959c 100644 --- a/source/org/jivesoftware/smack/util/StringUtils.java +++ b/source/org/jivesoftware/smack/util/StringUtils.java @@ -134,7 +134,7 @@ public class StringUtils { * @param string the string to escape. * @return the string with appropriate characters escaped. */ - public static final String escapeForXML(String string) { + public static String escapeForXML(String string) { if (string == null) { return null; } @@ -217,7 +217,7 @@ public class StringUtils { * @param data the String to compute the hash of. * @return a hashed version of the passed-in String */ - public synchronized static final String hash(String data) { + public synchronized static String hash(String data) { if (digest == null) { try { digest = MessageDigest.getInstance("SHA-1"); @@ -238,27 +238,22 @@ public class StringUtils { } /** - * Turns an array of bytes into a String representing each byte as an - * unsigned hex number. - *

- * Method by Santeri Paavolainen, Helsinki Finland 1996
- * (c) Santeri Paavolainen, Helsinki Finland 1996
- * Distributed under LGPL. + * Encodes an array of bytes as String representation of hexadecimal. * - * @param bytes an array of bytes to convert to a hex-string - * @return generated hex string + * @param bytes an array of bytes to convert to a hex string. + * @return generated hex string. */ - public static final String encodeHex(byte[] bytes) { - StringBuffer buf = new StringBuffer(bytes.length * 2); - int i; + public static String encodeHex(byte[] bytes) { + StringBuffer hex = new StringBuffer(bytes.length * 2); - for (i = 0; i < bytes.length; i++) { + for (int i=0; i