I have the following code to generate an SHA-1 hash.
@Override
public String generateHash(String plainTextPassword) {
String hashedPassword = "";
try {
MessageDigest msdDigest = MessageDigest.getInstance("SHA-1");
msdDigest.update(plainTextPassword.getBytes("UTF-8"), 0, plainTextPassword.length());
hashedPassword = DatatypeConverter.printHexBinary(msdDigest.digest());
} catch (Exception e) {
System.out.println("HASHING FAILED");
}
return hashedPassword;
}
On my local machine, I have no problem using the DatatypeConverter class. The package is javax.xml.bind.DatatypeConverter; When I transfer my project over to a linux machine running Ubuntu, the DatatypeConverter class is not resolved.