Represents the abstract class from which all implementations of the System.Security.Cryptography.MD5 hash algorithm inherit.
MD5Hash
01 Syntax
02 Methods
| Name | Overloads | Summary |
|---|---|---|
| GetMd5Hash | 1 | Calculate md5 hash value for the input string. |
| GetHashCode | 2 | Gets the hashcode of the input string. |
| ToLong | 2 | CityHash algorithm for convert the md5 hash value as a Int64 value. |
| StringToByteArray | 1 | 由于md5是大小写无关的,故而在这里都会自动的被转换为小写形式,所以调用这个函数的时候不需要在额外的转换了 |
| VerifyMd5Hash | 1 | Verify a hash against a string. |
| VerifyFile | 1 | 校验两个文件的哈希值是否一致 |
| GetFileMd5 | 1 | Get the md5 hash calculation value for a specific file.(获取文件对象的哈希值,请注意,当文件不存在或者文件的长度为零的时候,会返回空字符串) |
| SaltValue | 1 | SHA256 8 bits salt value for the private key. |
| Sha256ByteString | 1 | sha256 computed byte array in a readable format. |
| Fletcher32 | 1 | Calculate the Fletcher32 checksum. |
| GetSha1Hash | 1 | Generate SHA1 checksum of a file |
| NewUid | 1 | |
| GetMd5Hash2 | 1 |
03 Members
String)Calculate md5 hash value for the input string.
| Name | Type | Description |
|---|---|---|
input | String | - |
this function may returns empty hashcode string if the given input string is empty.
String)Gets the hashcode of the input string. (input => MD5Hash.GetMd5Hash() => MD5Hash.ToLong())
| Name | Type | Description |
|---|---|---|
input | String | 任意字符串 |
IEnumerable(Of Byte))Gets the hashcode of the input string.
String)Gets the hashcode of the md5 string.
| Name | Type | Description |
|---|---|---|
md5 | String | 计算所得到的MD5哈希值 |
CityHash algorithm for convert the md5 hash value as a Int64 value.
http://stackoverflow.com/questions/9661227/convert-md5-to-long
The very best solution I found (based on my needs... mix of speed and good hash function) is Google's CityHash. The input can be any byte array including an MD5 result and the output is an unsigned 64-bit long.
CityHash has a very good but Not perfect hash distribution, And Is very fast.
I ported CityHash from C++ To C# In half an hour. A Java port should be straightforward too.
Just XORing the bits doesn't give as good a distribution (though admittedly that will be very fast).
I'm not familiar enough with Java to tell you exactly how to populate a long from a byte array (there could be a good helper I'm not familiar with, or I could get some details of arithmetic in Java wrong). Essentially, though, you'll want to do something like this:
Long a = md5[0] * 256 * md5[1] + 256 * 256 * md5[2] + 256 * 256 * 256 * md5[3];
Long b = md5[4] * 256 * md5[5] + 256 * 256 * md5[6] + 256 * 256 * 256 * md5[7];
Long result = a ^ b;
Note I have made no attempt To deal With endianness. If you just care about a consistent hash value, though, endianness should Not matter.
| Name | Type | Description |
|---|---|---|
bytes | Byte() | this input value should compute from Md5HashProvider.GetMd5Bytes() |
String)由于md5是大小写无关的,故而在这里都会自动的被转换为小写形式,所以调用这个函数的时候不需要在额外的转换了
| Name | Type | Description |
|---|---|---|
hex | String | - |
String, String)Verify a hash against a string.
| Name | Type | Description |
|---|---|---|
input | String | - |
comparedHash | String | - |
String, String)校验两个文件的哈希值是否一致
| Name | Type | Description |
|---|---|---|
query | String | - |
subject | String | - |
String)Get the md5 hash calculation value for a specific file.(获取文件对象的哈希值,请注意,当文件不存在或者文件的长度为零的时候,会返回空字符串)
| Name | Type | Description |
|---|---|---|
PathUri | String | The file path of the target file to be calculated. |
String)SHA256 8 bits salt value for the private key.
| Name | Type | Description |
|---|---|---|
value | String | - |
Char)sha256 computed byte array in a readable format.
| Name | Type | Description |
|---|---|---|
array | Byte() | - |
Calculate the Fletcher32 checksum.
| Name | Type | Description |
|---|---|---|
bytes | Byte() | the bytes data for verify |
offset | Int32 | initial offset |
length | Int32 | the message length (if odd, 0 is appended) |
String)Generate SHA1 checksum of a file
| Name | Type | Description |
|---|---|---|
filePath | String | - |
T)