Calculating SHA-1 hashes in Java and C#

前端 未结 2 565
谎友^
谎友^ 2021-02-06 05:50

Calculating SHA-1 hashes in Java and C#

I\'m trying to replicate the logic of a Java application within a C# application. Part of this involves generating an SHA-1 ha

2条回答
  •  自闭症患者
    2021-02-06 06:24

    your question and the answer were very useful to me, but I noticed that when the password has the character "0" hash codes generated are different, so I changed a little the code (in Java).

    for (int i = 0; i < hash.length; i++)
        {
            String hex = Integer.toHexString(hash[i]);
            if (hex.length() == 1) hex = "0" + hex;
            hex = hex.substring(hex.length() - 2);
            result += hex;
        }
    

提交回复
热议问题