English 中文(简体)
关于比较MD5的h
原标题:Regarding comparing MD5 hash

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?

成就

最佳回答

同样的密码总是具有同样的价值,因此你可以进行你所说的检查。 此外,一般来说,散射功能不能逆转。 也就是说,鉴于一些口号,你不能从原封不动的口号中删除。 http://en.wikipedia.org/wiki/MD5# Security”rel=“nofollow” MD5被打破,因此,你应使用其他散射功能(如SHA-256)。 值得注意的是,为了切实地做到这一点,你应打上你面前的密码,以防暴袭击。

问题回答

是的,鉴于同样的投入,该散列将计算同样的价值。 这将使你能够储存在贵国数据库内的散盘而不是浅层密码。 你正确地指出,你只能比较两轮,以确定所显示的投入是否平等。

你也正确地指出,“MD5”是一种方式,因此,你赢得一定的能力,可以将其转变为原来的扼杀。 然而,这确实阻止攻击者对共同口号进行口腔攻击。 你可能想在你申请额外安全时引入盐类。 这样,如果贵国的数据库被破坏,袭击者还必须发现盐底是什么,这将挫败三维独裁的攻击。

 return getMd5("myS3cre7V4lu3" + inputValue) == getMd5(valueRetrievedFromDatabase) 





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签