echo -n "" | openssl dgst -sha1
=> da39a3ee5e6b4b0d3255bfef95601890afd80709
echo -n "" | md5
=> d41d8cd98f00b204e9800998ecf8427e
public class FooCrypt {
public static void main(String[] args) throws Exception {
MessageDigest sha1 = MessageDigest.getInstance("SHA-1");
System.out.println("sha-1: " + bytesToHex(sha1.digest("".getBytes("UTF-8"))));
MessageDigest md5 = MessageDigest.getInstance("MD5");
System.out.println("md5: " + bytesToHex(md5.digest("".getBytes("UTF-8"))));
}
public static String bytesToHex(byte[] bs) {
StringBuilder ret = new StringBuilder(bs.length);
for (int i = 0; i < bs.length; i++) {
String hex = Integer.toHexString(0x0100 + (bs[i] & 0x00FF)).substring(1);
ret.append((hex.length() < 2 ? "0" : "")).append(hex);
}
return ret.toString();
}
}
=>
sha-1: da39a3ee5e6b4b0d3255bfef95601890afd80709
md5: d41d8cd98f00b204e9800998ecf8427e
# posted by rot13(Unafba Pune) @ 9:40 AM