如何获取字符串哈希

时间:2010-12-26 03:33:53

标签: .net hash

我创建了这个函数来返回字符串哈希。但它不起作用;

//呼叫 Console.WriteLine(GetHashCode的( “测试”));

    static String getHashCode(String input)
    {
        int HashCode = input.GetHashCode();
        Console.WriteLine("{1:X8}", input, HashCode);
        return("{1:X8}", input, HashCode);
    }

2 个答案:

答案 0 :(得分:2)

static String getHashCode(String input)
{
    string HashCode = String.Format("{0:X8}", input.GetHashCode());
    Console.WriteLine("{1}", input, HashCode);
    return HashCode;
}

你去。

答案 1 :(得分:0)

您可以使用MD5CryptoServiceProvider来计算哈希()。

相关问题