I am no security expert and happen not to give it much thought since most of my app run on local intranet so who cares about security? :)
但事实上,我正试图使其正确。
我在玻璃鱼上建立了JDBC,现在我用MD5从互联网上洗手来挽救我的密码。
public static String getMD5(String input)
{
try
{
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(input.getBytes());
byte byteData[] = md.digest();
//convert the byte to hex format method 1
StringBuffer sb = new StringBuffer();
for (int i = 0; i < byteData.length; i++)
{
sb.append(Integer.toString((byteData[i] & 0xff) + 0x100,
16).substring(1));
}
return sb.toString();
}
catch (NoSuchAlgorithmException e)
{
throw new RuntimeException(e);
}
}
Now my question is, during change password use case... is it just comparing if the hash are equal to validate if the password entered is the same from what is in my DB like this code below?
public static void main(String[] args)
throws NoSuchAlgorithmException
{
String currentPassword = "java";
String inputValue = "java1";
String string1 = getMD5(currentPassword);
String string2 = getMD5(inputValue);
System.out.println("Is equal = " + string1.equals(string2));
}
我已经读到了某个地方,MD5是一种令人厌恶的方式,因此我不能背上描述的密码?
Sorry, if my question is too simple but I d just like to confirm my understanding?
成就