List of usage examples for java.security MessageDigest digest
public byte[] digest(byte[] input)
From source file:Main.java
public static byte[] HashSHA256(byte data[]) throws NoSuchAlgorithmException { MessageDigest sha = MessageDigest.getInstance("SHA-256"); return sha.digest(data); }
From source file:Main.java
public static byte[] calculateSHA1(byte[] data) { try {//from w ww. jav a 2 s.c om MessageDigest md = MessageDigest.getInstance("SHA1"); return md.digest(data); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } return null; }
From source file:Main.java
private static byte[] getMD5Digest(String data) throws IOException { byte[] bytes = null; try {/*from ww w . j ava2 s .co m*/ MessageDigest md = MessageDigest.getInstance("MD5"); bytes = md.digest(data.getBytes("UTF-8")); } catch (GeneralSecurityException gse) { throw new IOException(gse); } return bytes; }
From source file:Main.java
private static byte[] getSHA1Digest(String data) throws IOException { byte[] bytes = null; try {/*w w w . j a v a 2 s. c om*/ MessageDigest md = MessageDigest.getInstance("SHA-1"); bytes = md.digest(data.getBytes("UTF-8")); } catch (GeneralSecurityException gse) { } return bytes; }
From source file:Main.java
private static byte[] getSHA1Digest(String data) throws IOException { byte[] bytes = null; try {/*from w w w . jav a 2 s . co m*/ MessageDigest md = MessageDigest.getInstance("SHA-1"); bytes = md.digest(data.getBytes("UTF-8")); } catch (GeneralSecurityException gse) { throw new IOException(gse.getMessage()); } return bytes; }
From source file:Main.java
private static byte[] getSHA1Digest(String data) throws IOException { byte[] bytes = null; try {//from w w w . j a v a2 s .co m MessageDigest md = MessageDigest.getInstance("SHA-1"); bytes = md.digest(data.getBytes("UTF-8")); } catch (GeneralSecurityException gse) { throw new IOException(gse); } return bytes; }
From source file:Main.java
/** * Compute the MD5 hash of the byte array provided. Does not accumulate * input.//from w w w . j a v a 2 s . co m * @param in the byte array to hash * @return the MD5 hash of the byte array */ public static byte[] computeMd5Hash(byte[] in) { try { MessageDigest md5 = MessageDigest.getInstance("MD5"); return md5.digest(in); } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); } }
From source file:Main.java
public static String md5Hex(String message) { try {//w w w . ja v a 2s . c om MessageDigest md = MessageDigest.getInstance("MD5"); return hex(md.digest(message.getBytes())); } catch (NoSuchAlgorithmException e) { } return null; }
From source file:Main.java
private static String md5(String message) throws Exception { MessageDigest md = MessageDigest.getInstance("md5"); return bytesToHex(md.digest(message.getBytes("utf-8"))); }
From source file:Main.java
public static byte[] digest(byte[] input, String algoritmo) throws NoSuchAlgorithmException { MessageDigest md = MessageDigest.getInstance(algoritmo); md.reset();//from w ww . j a v a 2 s . c o m return md.digest(input); }