All pastes #483425 Raw Edit

Unnamed

public java v1 · immutable
·published 2007-05-11 18:51 UTC
rendered paste body
$ echo "56933" | md5sum83e2a84f530af983fdfa33663573221d  -java outputsa517c0412873dc9c1f5b25c65603c1f4	public static String byteArrayToHexString(byte[] input) {        StringBuffer hexString = new StringBuffer();        for (int i=0;i<input.length;i++) {            String hex = Integer.toHexString(0xFF & input[i]);            if (hex.length() == 1)                hexString.append("0");            hexString.append(hex);        }        return hexString.toString();			}	public static String digest(String input) {        if (input == null)            return null;        byte[] defaultBytes = input.getBytes();        try{            MessageDigest algorithm = MessageDigest.getInstance("MD5");            algorithm.reset();            algorithm.update(defaultBytes);            byte messageDigest[] = algorithm.digest();            return byteArrayToHexString(messageDigest);        } catch(NoSuchAlgorithmException nsae){            return null;        }    }