@Test public void testHash() { byte[] bytes1 = new byte[]{-44, 29, -116, -39, -113, 0, -78, 4, -23, -128, 9, -104, -20, -8, 66, 126}; byte[] bytes2 = new byte[]{-84, -67, 24, -37, 76, -62, -8, 92, -19, -17, 101, 79, -52, -60, -92, -40}; byte[] bytes3 = new byte[]{82, -119, -33, 115, 125, -11, 115, 38, -4, -35, 34, 89, 122, -5, 31, -84}; Assert.assertArrayEquals(bytes1, MD5.getInstance().hash("")); Assert.assertArrayEquals(bytes2, MD5.getInstance().hash("foo")); Assert.assertArrayEquals(bytes1, MD5.getInstance().hash(new byte[0])); Assert.assertArrayEquals(bytes3, MD5.getInstance().hash(new byte[]{1, 2, 3})); }
public byte[] hash(String str) { opLock.lock(); try { byte[] bt = mHasher.digest(str.getBytes(Constants.ENCODE)); if (null == bt || bt.length != DIGITS_SIZE) { throw new IllegalArgumentException("md5 need"); } return bt; } catch (UnsupportedEncodingException e) { throw new RuntimeException("unsupported utf-8 encoding", e); } finally { opLock.unlock(); } }
MD5 { public byte[] hash(String str) { opLock.lock(); try { byte[] bt = mHasher.digest(str.getBytes(Constants.ENCODE)); if (null == bt || bt.length != DIGITS_SIZE) { throw new IllegalArgumentException("md5 need"); } return bt; } catch (UnsupportedEncodingException e) { throw new RuntimeException("unsupported utf-8 encoding", e); } finally { opLock.unlock(); } } }
MD5 { public byte[] hash(String str) { opLock.lock(); try { byte[] bt = mHasher.digest(str.getBytes(Constants.ENCODE)); if (null == bt || bt.length != DIGITS_SIZE) { throw new IllegalArgumentException("md5 need"); } return bt; } catch (UnsupportedEncodingException e) { throw new RuntimeException("unsupported utf-8 encoding", e); } finally { opLock.unlock(); } } private  MD5(); }
MD5 { public byte[] hash(String str) { opLock.lock(); try { byte[] bt = mHasher.digest(str.getBytes(Constants.ENCODE)); if (null == bt || bt.length != DIGITS_SIZE) { throw new IllegalArgumentException("md5 need"); } return bt; } catch (UnsupportedEncodingException e) { throw new RuntimeException("unsupported utf-8 encoding", e); } finally { opLock.unlock(); } } private  MD5(); static MD5 getInstance(); String getMD5String(String content); String getMD5String(byte[] content); byte[] getMD5Bytes(byte[] content); byte[] hash(String str); byte[] hash(byte[] data); String bytes2string(byte[] bt); }
MD5 { public byte[] hash(String str) { opLock.lock(); try { byte[] bt = mHasher.digest(str.getBytes(Constants.ENCODE)); if (null == bt || bt.length != DIGITS_SIZE) { throw new IllegalArgumentException("md5 need"); } return bt; } catch (UnsupportedEncodingException e) { throw new RuntimeException("unsupported utf-8 encoding", e); } finally { opLock.unlock(); } } private  MD5(); static MD5 getInstance(); String getMD5String(String content); String getMD5String(byte[] content); byte[] getMD5Bytes(byte[] content); byte[] hash(String str); byte[] hash(byte[] data); String bytes2string(byte[] bt);  }