such as Peng Network. NET three-tier architecture chapter III MD5 and NPOI use

Source: Internet
Author: User
Tags md5 hash

The contents of the chapter:

This section mainly explains the use of MD5 and Npoi,

How to use the two technologies in your project.

----------------------------------------------------------------------------------------

MD5 algorithm: is a hash (hash) algorithm (digest algorithm, fingerprint algorithm), not a pure compression algorithm, not a

Encryption algorithm (error-prone). Any content of any length can be computed with MD5 hash value.

MD5 length is generally 32-bit 16 binary numeric string, the number of MD5 values is limited, but the source data is infinite,

Therefore, the probability of generating the same MD5 value with different content is stored, because the MD5 algorithm is irreversible, even if the MD5 value corresponding to the content is obtained,

The content cannot be pushed back by the MD5 value. However, the probability of generating the same MD5 value for different content is very very low.

The password field holds the MD5 value of the user's input password so that the system administrator, the hacker, does not know what the user's password is,

Also avoids the problem that the user's other system password is exploited.

The method of judging correctness: calculates the MD5 value of the password entered by the user, compares it with the MD5 value stored in the database, if

Equality is considered to be the correct password.

Common application: Calculates the MD5 value of a file to verify that the file has been tampered with.

The password of the website can only be reset and the original password cannot be retrieved.

---------------------------------------------------------------------------------------------

The MD5 algorithm is theoretically irreversible.

To be more secure: Count two times the MD5 value, or add a fixed string.

Similar to MD5, there are algorithms such as SHA.

---------------------------------------------------------------------------------

Npoi reading Excel files

An Excel file-"Workbook has a lot of pages-" Sheet,

There are many lines in each page-"row, there are many cells in each row-" cell

Strings that look like numbers start with a half-width single quote.

Add references;

using (Stream fs = new FileStream ("Myexcel.xls", FileMode.Open, FileAccess.Read))                {//create sheet Iworkbook workbook = new  Hssfworkbook (FS); Gets the page var sheet = workbook.                Getsheetat (0 ); Traverse the row for (var i = 0; I <= sheet. Lastrownum; i++ ) {var row =  sheet. GetRow (i); Traverse cell var sb = new  StringBuilder (); for (var j = 0; J < row. Lastcellnum; J + + ) {var cell =  row. Getcell (j); if (cell. Celltype = =  celltype.numeric) {sb. Append (cell. Numericcellvalue + ""); The cell's Data } if (cell. Celltype = =  celltype.string) {sb. Append (cell. Stringcellvalue + ""); Cell Data }}//end for J  Console.WriteLine (sb.) ToString ()); }//end for I  Console.WriteLine (sheet. SheetName); Console.readkey (); }//end using              

such as Peng Network: http://www.rupeng.com

such as Peng Network. NET three-tier architecture chapter III MD5 and NPOI use

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.