Dwz data verification, added custom validation rules, and dwz Verification
When I was writing data validation, I forgot to write the new custom validation in dwz. Just find dwz. min. if ($. validator) {location, write your own regular expression validation in it. I have added two regular expressions. The mac or mms code is as follows:
If ($. validator) {$. validator. addMethod ("alphanumeric", function (value, element) {return this. optional (element) |/^ \ w + $/I. test (value) ;}, "Letters, numbers or underscores only please"); $. validator. addMethod ("lettersonly", function (value, element) {return this. optional (element) |/^ [a-z] + $/I. test (value) ;}, "Letters only please"); $. validator. addMethod ("phone", function (value, element) {return this. optional (element) |/^ [0-9 \ (\)] {7, 30} $ /. test (value) ;}, "Please specify a valid phone number"); $. validator. addMethod ("mac", function (value, element) {return this. optional (element) |/^ ([a-fA-F0-9] {2}: [a-fA-F0-9] {2}: [a-fA-F0-9] {2}: [a-fA-F0-9] {2 }: [a-fA-F0-9] {2}: [a-fA-F0-9] {2 }) | ([a-fA-F0-9] {2}-[a-fA-F0-9] {2}-[a-fA-F0-9] {2}-[a-fA-F0-9] {2}-[a-fA-F0-9] {2}-[a-fA-F0-9] {2 }) $ /. test (value) ;}, "Please specify a valid phone number"); $. validator. addMethod ("mms", function (value, element) {return this. optional (element) |/^ mms $ /. test (value) ;}, "Please mms ");
Add class = "mms" or class = "mac" to the html tag to be used.
The Code is as follows:
<input type="text" name="aaa" class="required mac"/>
The first class is non-empty, and the second is self-written validation.
Odd parity check
A Method for verifying the correctness of data transmission. Append an odd check bit before data transmission to indicate whether the number of "1" in the transmitted data is an odd or even number. If the number is an odd number, the check position is "0 ", otherwise, it is set to "1" to keep the parity of the Data unchanged. For example, if you want to transmit "11001110" and the data contains five "1", the odd parity bit is "0" and "110011100" is transmitted to the receiver, after receiving the data, the receiver calculates the parity again. "110011100" still contains five "1", so the odd parity bit calculated by the receiver is still "0", consistent with that calculated by the sender, indicates that no error occurred during the transmission. Parity is used by the receiver to verify whether the data transmitted by the sender during transmission is damaged for some reason.
The specific method is as follows:
Odd check: the number of 1 in the original data sequence (including the one you want to add) is an odd number.
1000110 (0) You must add 0. In this case, three of the first ones are already odd, so the number of the first after 0 is added is still odd.
Even verification: the number of 1 in the original data sequence (including the one you want to add) is an even number.
1000110 (1) You must add 1. In this case, if there are three numbers of 1 and the number of 1 is an even number, you can only add 1.
You will surely ask how to calculate parity. in a computer, there is a special operation that follows the following rules:
1 + 1 = 0; 1 + 0 = 1; 0 + 1 = 1; 0 + 0 = 0; we add the sent 1100111000 to get 1, it should be noted that, if 1100111000 is changed to 0000111000 during transmission, 1 will be obtained through the above calculation, and the receiver will think that the transmitted data is correct, this process is called verification. The verification performed using the above method is called odd verification. Odd verification can only judge the situation where odd data in the transmitted data changes from 0 to 1 or from 1 to 0, if an error occurs for an even number of data in the transfer process, it is powerless.
Odd Parity (Odd check) is a method used to check data integrity. The eight data bits in one byte and the parity bit add up to an Odd number of 1. After receiving the number of verification lines, fill in 0 or 1 in the check bit through the generator to ensure that the sum is an odd number of 1. Therefore, when the check bit is 0, there should be an odd number of 1 in the Data bit; when the check bit is 1, there should be an even number of 1. If the read data does not comply with this rule, the CPU will order the data to be re-transmitted. Odd/even verification (ECC) is a method used to correct data errors during data transmission. It can be divided into two types: odd/even verification. If the odd check is used, an additional bit is appended as the check bit when each byte is transferred. When the number of "1" in the actual data is an even number, the check bit is "1 ", otherwise, this check bit is "0", which ensures that the transmitted data meets the requirements of the odd check. When the recipient receives the data, it checks the number of "1" in the data according to the requirements of odd verification. If the number is odd, the transfer is correct; otherwise, the transfer is incorrect. Similarly, the parity check process is the same as the odd check process, but the number of "1" in the test data is an even number.
What are common data verification methods?
Parity ". The smallest unit in the memory is bits, also known as "bits". bits are marked with 1 and 0 respectively. Each eight consecutive bits is called a byte ). The memory with no parity check has only eight bytes. If one of the eight bytes stores the wrong value, the corresponding data stored in the memory will change, in this case, an application error occurs. The parity check adds a bit out of each byte (8 bits) as the error detection bit. After data is stored in a certain byte, the data stored on the eight-bit table is fixed, because the bit can only have two statuses: 1 or 0, assume that the stored data is marked as 1, 1, 1, 0, 0, 1, 0, and 1 with bits, then, when each bit is added (1 + 1 + 1 + 0 + 0 + 1 + 0 + 1 = 5) and the result is an odd number, the check bit is defined as 1, and the opposite is 0. When the CPU reads the stored data, it adds the data stored in the first eight bits, and determines whether the calculation result is consistent with the check bit. Thus, memory errors can be detected to a certain extent, and the parity check can only detect errors but cannot correct them. At the same time, although the probability of two-bit simultaneous errors is quite low, however, parity cannot detect double-bit errors.
The full name of MD5 is Message-Digest Algorithm 5, which was invented by MIT's computer science lab and RSA Data Security Inc in Early 1990s and developed by MD2, MD3, and MD4. The actual application of MD5 is to generate fingerprint (fingerprint) for a piece of Message (byte string), which can prevent "tampering ". MD5 value: 1e07ab3591d25583eff5129293dc98d2, if you still don't need the software, you can watch it on your own.
MD5 is widely used in encryption and decryption technology. In many operating systems, users' passwords are stored in MD5 values (or similar algorithms, the system calculates the password entered by the user into an MD5 value, and then compares it with the MD5 value saved in the system to verify the validity of the user.
The winmd5.zip Chinese version of the md5check value software is extremely simple to use. After running the software, drag the file that needs to calculate the MD5 value to the processing box, the following shows the MD5 value and the name of the file to be tested. You can retain the MD5 value for multiple files and select the MD5 value to be copied, press CTRL + C to copy it to other places.
Reference: zhidao.baidu.com/question/3931041.html
CRC algorithm principle and C language implementation-from (I love single chip microcomputer)
Abstract This paper theoretically exports the implementation principle of CRC algorithm, and provides three C language programs that adapt to different computer or microcontroller hardware environments. Readers can write more practical CRC computing programs in different languages based on the principle of this algorithm.
Key words CRC algorithm C Language
1 Introduction
Cyclic Verification Code CRC testing is widely used in the measurement and control and communication fields. CRC computing can be implemented by dedicated hardware. However, for low-cost microcontroller systems, CRC testing is implemented without hardware support. The key issue is how to complete CRC computing through software, that is, the CRC algorithm.
Three algorithms are provided here, which are slightly different. They are applicable to a Microcontroller System with extremely demanding program space but low CRC computing speed, another method is applicable to computer or microcontroller systems with large program space and high CRC computing speed requirements. The last method is applicable to systems with low program space, the CRC computing speed cannot be too slow for a Microcontroller System.
2 C... the remaining full text>