如何创建简单的哈希值?例如,我有字符串"TechnologyIsCool"以及如何从此字符串中获取哈希值?
我想做一些方法,如:
public string HashThis(string value)
{
string hashResult = string.Empty;
...
return hashResult;
}
Run Code Online (Sandbox Code Playgroud)
并将此方法称为:
string hash = HashThis("TechnologyIsCool");
Run Code Online (Sandbox Code Playgroud)
之后就像"5qazws"那样哈希.
Hab*_*bib 13
public static void Main()
{
DisplayHashCode( "Abcdei" );
}
static void DisplayHashCode( String Operand )
{
int HashCode = Operand.GetHashCode( );
Console.WriteLine("The hash code for \"{0}\" is: 0x{1:X8}, {1}",
Operand, HashCode );
}
Run Code Online (Sandbox Code Playgroud)
使用 GetHashCode();
public string HashThis(string value)
{
return hashResult = value.GetHashCode();
}
Run Code Online (Sandbox Code Playgroud)