MD5 various lengths of cryptographic characters, verification MD5 and other operations auxiliary class Md5util

Source: Internet
Author: User

Label:

Achieve Results1) This auxiliary class is mainly used to facilitate the implementation of MD5 various lengths of cryptographic characters, verification MD5 and other operations. 2) MD5 is message-digest algorithm 5 (Information-Digest algorithm 5), which is used to ensure complete and consistent information transmission.  is one of the widely used hashing algorithms (also translated digest algorithm, hashing algorithm). 3) MD5 has been widely used in providing a certain degree of reliability for file transfer. For example, the server pre-provides a MD5 checksum, the user after downloading the file, using the MD5 algorithm to calculate the MD5 checksum of the downloaded file, and then by checking whether the two checksum is consistent, you can determine whether the downloaded file error Implementation Code1) The method interface provided by the helper class is as follows:

<summary>

Get 32-bit MD5 encryption

</summary>

public static string getmd5_32 (String input)

<summary>

Get 16-bit MD5 encryption

</summary>

public static string Getmd5_16 (String input)

<summary>

Get 8-bit MD5 encryption

</summary>

public static string Getmd5_8 (String input)

<summary>

Get 4-bit MD5 encryption

</summary>

public static string Getmd5_4 (String input)

<summary>

Add MD5 prefixes to check for tampering

</summary>

public static string Addmd5profix (String input)

<summary>

Remove the prefix from the MD5

</summary>

public static string Removemd5profix (String input)

<summary>

Verify that the string processed by the MD5 prefix has not been tampered with

</summary>

public static bool Validatevalue (string input)

#region MD5 Signature Verification

<summary>

Label files for a given file path

</summary>

<param name= "path" > Path to the file to encrypt </param>

Values for <returns> tags </returns>

public static bool AddMD5 (string path)

<summary>

Validates the file for the given path and returns False if it returns true consistently

</summary>

<param name= "Path" ></param>

<returns> whether tag or label value is consistent with content value </returns>
public static bool CheckMD5 (string path)

、、、、、

Add the MD5 encoding label to the file and verify that it is modified

string file = @ "C:\Test.xls";

BOOL Flag2 = md5util.addmd5 (file);

Console.WriteLine (FLAG2);

Validates the file for the given path and returns False if it returns true consistently

BOOL Flag3 = md5util.checkmd5 (file);
Console.WriteLine (FLAG3);

MD5 various lengths of cryptographic characters, verification MD5 and other operations auxiliary class Md5util

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

Tags Index: