Here you can find the source of fromHexDigest(String hexDigest)
public static byte[] fromHexDigest(String hexDigest)
//package com.java2s; /*//w ww . ja va 2 s.c om * ==================================================================== * Copyright (c) 2004-2010 TMate Software Ltd. All rights reserved. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms * are also available at http://svnkit.com/license.html * If newer versions of this license are posted there, you may use a * newer version instead, at your option. * ==================================================================== */ public class Main { public static byte[] fromHexDigest(String hexDigest) { if (hexDigest == null || hexDigest.length() == 0) { return null; } hexDigest = hexDigest.toLowerCase(); int digestLength = hexDigest.length() / 2; if (digestLength == 0 || 2 * digestLength != hexDigest.length()) { return null; } byte[] digest = new byte[digestLength]; for (int i = 0; i < hexDigest.length() / 2; i++) { if (!isHex(hexDigest.charAt(2 * i)) || !isHex(hexDigest.charAt(2 * i + 1))) { return null; } int hi = Character.digit(hexDigest.charAt(2 * i), 16) << 4; int lo = Character.digit(hexDigest.charAt(2 * i + 1), 16); Integer ib = new Integer(hi | lo); byte b = ib.byteValue(); digest[i] = b; } return digest; } private static boolean isHex(char ch) { return Character.isDigit(ch) || (Character.toUpperCase(ch) >= 'A' && Character.toUpperCase(ch) <= 'F'); } }