import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class GenerateSHA1fromastring {
public static void main(String[] args) {
String password = "password";
String sha1 = "";
try {
MessageDigest crypt = MessageDigest.getInstance("SHA-1");
crypt.reset();
crypt.update(password.getBytes("UTF-8"));
sha1 = byteToHex(crypt.digest());
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
System.out.println(sha1);
}
private static String byteToHex(final byte[] hash) {
Formatter formatter = new Formatter();
for (byte b : hash) {
formatter.format("%02x", b);
}
String result = formatter.toString();
formatter.close();
return result;
}
}
For further actions, you may consider blocking this person and/or reporting abuse
Oldest comments (0)