Parity check". The smallest unit in memory is a bit, also called a "bit". Bits have only two states, labeled 1 and 0. Each 8 consecutive bits is called a word Each byte of memory without parity check has only 8 bits. If one of its bits stores an incorrect value, it will cause the corresponding data stored to change, which will lead to application errors. Parity check adds one bit to each byte (8 bits) as an error detection bit. After data is stored in a byte, the data stored in its 8 bits is fixed because the bits are only one bit. There can be two states of 1 or 0. Assume that the stored data is marked with bits as 1, 1, 1, 0, 0, 1, 0, 1. Then add each bit (1+1+1+1+1=5), and the result is an odd number. Then the check digit is defined as 1, otherwise it is 0. When the CPU reads the stored data, it will add the data stored in the first 8 bits again to determine whether the result is consistent with the check digit. Detected memory errors, parity can only detect errors but cannot correct them. At the same time, although the probability of double-bit errors occurring at the same time is quite low, parity cannot detect double-bit errors.
The full name of MD5 is Message-Digest Algorithm 5. It was invented by MIT's Computer Science Laboratory and RSA Data Security Inc in the early 1990s. The practical application of MD5 is developed from MD2/MD3/MD4. String) generates a fingerprint (fingerprint), which can prevent "tampering". For example, Tiantian Security Network provides downloadable MD5 check value software WinMD5.zip. Its MD5 value is 1e07ab3591d25583eff5129293dc98d2, but after you download the software, you find that the MD5 is calculated. Its value is 81395f50b94bb4891a4ce4ffb6ccf64b, which means that the ZIP has been modified by others. You can figure it out yourself whether you need this software.
MD5 is widely used in encryption and decryption technology. In the operating system, the user's password is saved in the form of MD5 value (or other similar algorithms). When the user logs in, 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. Compare to verify the legitimacy of the user.
The Chinese version of MD5 check value software WinMD5.zip is extremely simple to use. After running the software, drag the file that needs to calculate the MD5 value with the mouse to In the processing box, the MD5 value and the name of the tested file will be directly displayed below. The MD5 value of multiple file tests can be retained. Select the MD5 value that needs to be copied, and use CTRL C to copy it to other places.
Reference materials: /question/3933661.html
CRC algorithm principle and C language implementation - from (I love microcontrollers)
Abstract This article derives it theoretically The implementation principle of CRC algorithm is given, and three C language programs adapted to different computer or microcontroller hardware environments are given. Readers can use different languages ??to write unique and more practical CRC calculation programs based on the principles of this algorithm.
Keywords CRC algorithm C language
1 Introduction
Cyclic redundancy code CRC check technology is widely used in the fields of measurement, control and communications. CRC calculation can be implemented by dedicated hardware, but for low-cost microcontroller systems, the key issue when implementing CRC verification without hardware support is how to complete CRC calculation through software, which is the problem of CRC algorithm.
Three algorithms will be provided here, which are slightly different. One is suitable for microcontroller systems with very demanding program space but low CRC calculation speed requirements, and the other is suitable for microcontroller systems with large program space and low CRC calculation speed. Computers or microcontroller systems that require high CRC calculation speed. The last one is suitable for microcontroller systems that have a small program space and a CRC calculation speed that cannot be too slow.
2 Introduction to CRC
The basic idea of ??CRC check is to use linear coding theory to generate a check at the sending end according to certain rules according to the k-bit binary code sequence to be transmitted. The supervision code (that is, the CRC code) r bits are used and attached to the end of the information to form a new binary code sequence of ***(k r) bits, which is finally sent out. At the receiving end, it is checked according to the rules followed between the information code and the CRC code to determine whether there is an error in the transmission.
The rule for generating a 16-bit CRC code is to first shift the binary sequence number to be sent by 16 bits to the left (that is, multiply it), and then divide it by a polynomial. The final remainder is the CRC code, such as As shown in Equation (2-1), B(X) represents an n-bit binary sequence number, G(X) is a polynomial, Q(X) is an integer, and R(X) is the remainder (that is, CRC code).
(2-1)
Find the modulo 2 addition and subtraction algorithm used in the CRC code. It is a bit-wise addition and subtraction without carry and borrow. This addition and subtraction operation In fact, it is a logical XOR operation. Addition and subtraction are equivalent. Multiplication and division operations are the same as the multiplication and division operations of ordinary algebraic expressions and comply with the same rules. The polynomial that generates the CRC code is as follows, where CRC-16 and CRC-CCITT produce a 16-bit CRC code, while CRC-32 produces a 32-bit CRC code. This article does not discuss the 32-bit CRC algorithm. Interested friends can derive the calculation method by themselves based on the ideas of this article.
CRC-16: (Adopted in the US binary synchronization system)
CRC-CCITT: (Recommended by the European CCITT)
CRC-32:
The receiver divides the received binary sequence number (including information code and CRC code) by the polynomial. If the remainder is 0, it means that no error occurred during the transmission. Otherwise, it means that the transmission was incorrect. The principle will not be discussed here. Tell more. When using software to calculate the CRC code, the receiver can calculate the CRC code from the received information code and check whether the comparison result is the same as the received CRC code.
3 Calculate CRC bit by bit
For a binary sequence number, it can be expressed as formula (3-1):
(3-1)
When finding the CRC code of this binary sequence number, first multiply it (that is, shift it to the left by 16 bits), and then divide it by the polynomial G(X). The remainder obtained is the required CRC code. As shown in formula (3-2):
(3-2)
It can be set as: (3-3)
where is an integer, which is 16 Bit binary remainder. Substituting equation (3-3) into equation (3-2) we get:
(3-4)
Suppose again: (3-5)
where is an integer and is the 16-bit binary remainder. Substituting equation (3-5) into equation (3-4), and so on, we finally get:
(3-6)
According to the definition of CRC, it is obvious that the sixteen-bit binary number is the CRC code we require.
Equation (3-5) is the key to programming CRC calculation. It shows that the CRC code after calculating the bit is equal to the previous CRC code multiplied by 2 and divided by the polynomial. The remainder is added to the bit value. The remainder obtained by dividing a polynomial. From this, it is not difficult to understand the following C language program to find the CRC code. *ptr points to the first byte of the send buffer, len is the total number of bytes to be sent, and 0x1021 is related to the polynomial.
[code]
unsigned int cal_crc(unsigned char *ptr, unsigned char len) {
unsigned char i;
unsigned int crc=0;
while(len--!=0) {
for(i=0x80; i!=0; i/=2) {
if((crcamp;0x8000)!=0) {crc*=2; crc^=0x1021;} /* Multiply the remainder CRC by 2 and find the CRC */
else crc*= 2;
if((*ptramp;i)!=0) crc^=0x1021; /* plus the local CRC */
}
ptr;
}
return(crc);
}
[code]
Bitwise Although the code for calculating CRC is simple and takes up relatively little memory, its biggest disadvantage is that calculating it bit by bit takes up a lot of processor processing time. Especially in high-speed communication situations, this shortcoming is intolerable. Therefore, let’s introduce a method to quickly calculate CRC by byte table lookup.
4 Calculate CRC by bytes
It is not difficult to understand that a binary sequence number can be expressed by bytes as formula (4-1), where is a byte (** *8 bits).
(4-1)
When finding the CRC code of this binary sequence number, first multiply it (that is, shift it to the left by 16 bits), and then divide it by the polynomial G(X), the result The remainder is the required CRC code. As shown in formula (4-2):
(4-2)
It can be set as: (4-3)
where is an integer, which is 16 Bit binary remainder. Substituting formula (4-3) into formula (4-2) we get:
(4-4)
Because:
(4-5)
Among them, yes is the upper eight bits, and yes is the lower eight bits. Substituting equation (4-5) into equation (4-4), we get:
(4-6)
Assume again: (4-7)
Where is an integer and is the 16-bit binary remainder. Substituting Equation (4-7) into Equation (4-6), and so on, we finally get:
(4-
Obviously, the sixteen-digit binary number is what we require CRC code.
Formula (4-7) is the key to writing a byte-by-byte CRC calculation program. It shows that the CRC code after calculating this byte is equal to the lower 8 bits of the remainder CRC code of the previous byte. After shifting 8 bits to the left, plus the CRC code obtained by shifting the CRC of the previous byte right by 8 bits (also taking the high 8 bits) and the sum of this byte, if we take the CRC of the 8-bit binary sequence number Calculate them all and put them in a table. Using the table lookup method can greatly improve the calculation speed. From this, it is not difficult to understand the following C language program to find the CRC code by byte. *ptr points to the first byte of the sending buffer, len. is the total number of bytes to be sent, and the CRC remainder table is calculated based on the 0x11021 polynomial.
[code]
unsigned int cal_crc(unsigned char *ptr, unsigned char len) {
unsigned int crc;
unsigned char da;
unsigned int crc_ta[256]={ /* CRC remainder table*/
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,
0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef,
0x 1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x7 2f7, 0x62d6,
0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de,
0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4 , 0x5485,
0xa56a , 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d,
0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4 ,
0xb75b, 0xa77a, 0x9719 , 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc,
0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823,
0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948 , 0x9969, 0xa90a, 0xb92b,
0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 050, 0x3a33, 0x2a12,
0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b , 0xab1a,
0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41,
0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49,
0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70,
0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0 x8f78,
0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f,
0x1080, 0x00a1, 0x30c2, 0x20e3
, 0x5004, 0x4025, 0x7046, 0x6067,
0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e,
0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214 , 0x6277, 0x7256,
0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d,
0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405 ,
0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c,
0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634,
0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab,
0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x38 82, 0x28a3,
0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xbb9a,
0x4a75, 0x5a54, 0x6a37, 0x7a16, 0f1, 0x1ad0, 0x2ab3, 0x3a92 ,
0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9,
0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1,
0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8,
0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0
};
crc=0;
while(len--!=0) {
da=(uchar) (crc/256); /* Temporarily store the high 8 of CRC in the form of 8-bit binary number Bit */
crclt;lt;=8; /* Shift left by 8 bits, which is equivalent to multiplying the lower 8 bits of CRC */
crc^=crc_ta[da^* ptr]; /* Add the high 8 bits to the current byte and then look up the table to find the CRC, plus the previous CRC */
ptr;
}
return(crc);
}
Obviously, when calculating CRC by bytes, the calculation speed is greatly improved due to the use of table lookup method. However, for the widely used 8-bit microprocessors, the code space is limited, and the requirement of 256 CRC remainder tables (maximum 512 bytes of memory) is already insufficient. However, the calculation speed of CRC cannot be too slow, so it is difficult to Introducing the following algorithm for calculating CRC by nibble.
5 Calculate CRC in half bytes
Similarly, a binary sequence number can be expressed in bytes as formula (5-1), where is half a byte (* **4 digits).
(5-1)
When finding the CRC code of this binary sequence number, first multiply it (that is, shift it to the left by 16 bits), and then divide it by the polynomial G(X), the result The remainder is the required CRC code. As shown in formula (4-2):
(5-2)
It can be set as: (5-3)
where is an integer, which is 16 Bit binary remainder. Substituting formula (5-3) into formula (5-2) we get:
(5-4)
Because:
(5-5)
Among them, the high 4 bits of , and the low 12 bits of . Substituting equation (5-5) into equation (5-4), we get:
(5-6)
Assume again: (5-7)
Where is an integer and is the 16-bit binary remainder. Substituting Equation (5-7) into Equation (5-6), and so on, we finally get:
(5-
Obviously, the sixteen-digit binary number is what we require CRC code.
Formula (5-7) is the key to writing a byte-by-byte CRC calculation program. It shows that the CRC code after calculating this byte is equal to the lower 12 bits of the previous byte's CRC code. After 4 bits, add the CRC code obtained by shifting the remainder CRC of the previous byte to the right by 4 bits (also taking the high 4 bits) and the sum of this byte. If we take the CRC of the 4-digit binary sequence number Calculate them all and put them in a table. Using the table lookup method, each byte is counted twice (nibble is counted once), which can achieve a balance between speed and memory space. It is not difficult to understand that the following calculation is based on nibble. C language program of CRC code. *ptr points to the first byte of the sending buffer, len is the total number of bytes to be sent, and the CRC remainder table is calculated according to the 0x11021 polynomial.
unsigned cal_crc(unsigned char *ptr, unsigned char len) {
unsigned int crc;
unsigned char da;
unsigned int crc_ta[16]={ /* CRC remainder table*/
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,
0x8108, 0x9129, 0xa14a , 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef,
}
crc=0;
while(len--!=0) {
da=((uchar)(crc/256))/16; /* Temporarily store the high four bits of CRC*/
crclt; lt; = 4; /* Shift CRC right by 4 bits, equivalent to taking the lower 12 bits of CRC) */
crc^=crc_ta[da^(*ptr/16)]; /* The upper 4 bits of CRC and the first half byte of this byte After adding, look up the table to calculate the CRC,
Then add the remainder of the last CRC*/
da=((uchar)(crc/256))/16; /* Temporarily Store the upper 4 bits of CRC */
crclt;lt;=4; /* CRC is shifted right by 4 bits, which is equivalent to the lower 12 bits of CRC) */
crc^= crc_ta[da^(*ptramp;0x0f)]; /* Add the high 4 bits of the CRC to the second half byte of this byte, then look up the table to calculate the CRC,
Then add the last CRC Remainder*/
ptr;
}
return(crc);
}
[code ]
5 Conclusion
The three programs for finding CRC introduced above, the bit-wise method is slower, but takes up the smallest memory space; the byte-based table lookup method is used to find CRC It is faster, but takes up a lot of memory; the half-byte table lookup method to find the CRC is a balance between the first two, that is, it does not take up too much memory, and at the same time, the speed is not too slow. It is more suitable for 8-bit small Memory microcontroller applications. The C program given above can be changed according to the characteristics of each microprocessor compiler, such as placing the CRC remainder table in the program storage area. [/code]
hjzgq replied at: 2003-05-15 14:12:51
CRC32 algorithm study notes and how to implement it with java from: csdn bootcool October 19, 2002 23:11 CRC32 algorithm study notes and how to implement it with java
CRC32 algorithm study notes and how to implement it with java
1: Description
About CRC32 on the forum There are not many details on the verification algorithm. I happened to see Ross N. Williams's article a few days ago, and finally figured out the ins and outs of the CRC32 algorithm. I originally wanted to translate the original text, but due to time constraints, I had to write down some of my learning experiences. In this way, everyone can understand the main idea of ??CRC32 faster. Due to the limited level, I also kindly ask for your corrections. The original text can be accessed:]
Three: How to implement the CRC algorithm with software
Now our main problem is how to implement CRC check, encoding and decoding. It is currently impossible to implement it with hardware. We mainly consider the method of software implementation.
The following is a translation of the author's original text:
We assume that there is a 4-bit register. Through repeated shifting and CRC division, the final value in the register is The remainder we require.
3 2 1 0 Bits
--- --- --- ---
Pop lt;-- | | | | lt; ----- Augmented message (original data with 0 expansion)
--- --- --- ---
1 0 1 1 1 = The Poly
(Note: The augmented message is the message followed by W zero bits.)
Based on this model, we get the simplest algorithm:
Set the value in register to 0.
Add r zeros after the original data.
While (there is still unprocessed data)
Begin
Shift the value in the register one bit to the left, read in a new data and place it at the 0 bit position of the register.
If (if the bit shifted out in the previous left shift operation is 1)
register = register XOR Poly.
End
The current value in register is the crc remainder we require.
My study notes:
Why do I do this? Let's illustrate with the following example:
1100001010
_______________
10011 11010110110000
10011,,.,,....
-----,,.,,....
-》 10011,.,,....
10011,., ,....
-----,.,,....
-》00001.,,....
00000 .,,....
-----.,,....
00010,,....
00000,, ....
-----,,....
00101,....
00000,.... p>
We know that the highest digit of G(x) must be 1, and whether the quotient is 1 or 0 is determined by the highest digit of the dividend. And we don't care what the quotient is, we care about the remainder. For example, G(x) in the above example has 5 bits. We can see that the remainder obtained by the division operation at each step is actually the XOR of the last four digits of G(x) after the highest digit of the dividend. So what is the use of the highest bit of the dividend? We know the reason from the two different remainders marked. When the highest bit of the dividend is 1, the quotient 1 then XORs the four bits after the highest bit with the last four bits of G(x) to get the remainder; if the highest bit is 0, the quotient 0 then puts the four bits after the highest bit of the dividend in G The last four digits of (x) are XORed to get the remainder, and we find that this remainder is actually the value of the four digits after the highest digit of the original dividend. In other words, if the highest bit is 0, there is no need to perform XOR operation. At this point we finally know why we built the model this way before, and the principle of the algorithm is clear.
The following is a translation of the author's original text:
However, the algorithm implemented in this way is very inefficient. To speed it up, we enable it to process data larger than 4 bits at a time. That is the 32-bit CRC check we want to implement.
We still assume that there is the same 4 "bit" register as before. But each bit of it is an 8-bit byte.
3 2 1 0 Bytes
---- ---- ---- ----
Pop lt;-- | | | | | lt;----- Augmented message
---- ---- ---- ----
1lt;------32 bits------gt; (implies a highest bit "1")
According to the same principle, we can get the following algorithm:
While (there are remaining No processed data)
Begin
Check the register header byte and obtain its value
Find the sum of polynomials at different offsets
Shift register to the left by one byte, and store the newly read byte in the rightmost position
Perform XOR operation on register value and polynomial sum
End p>
My study notes:
But why do we do this? Similarly, we will use a simple example to illustrate the problem:
Suppose there are some values ??like this:
The value in the current register: 01001101
4 bits should be The value moved out: 1011
The generator polynomial is: 101011100
Top Register
---- --------
1011 01001101
1010 11100 (CRC XOR)
-------------
0001 10101101
If the first 4 bits are not 0, it means the division is not complete and the division must continue:
0001 10101101
1 01011100 (CRC XOR)
--- ----------
0000 11110001
^^^^
The first 4 bits are all 0, indicating that there is no need to continue except.
What will be the result of following the algorithm?
1010 11100
1 01011100
-------------
1011 10111100
1011 10111100
1011 01001101
-------------
0000 11110001
Now we see the fact that the result of doing this is consistent with the above result. This also explains why in the algorithm it is necessary to first sum the polynomial values ??according to different offset values, and then perform an XOR operation with the register. In addition, we can also see that each header byte corresponds to a value. For example, in the above example: 1011 corresponds to 01001101. So for the 32 bits CRC header byte, according to our model. There should be 2^8 first 8 bits, that is, there are 256 values ??corresponding to it. So we can create a table in advance and then, when encoding, just take out the first byte of the input data and look up the corresponding value from the table. This can greatly improve the speed of encoding.
---- ---- ---- ----
-----lt; | | | | | lt;----- Augmented message
| ---- ---- ---- ----
| ^
| |
| XOR
| |
| 0 ---- ---- ---- ----
v ---- -- -- ---- ----
| ---- ---- ---- ----
| ---- ---- ---- ----
| ---- ---- ---- ----
| ---- ---- -- -- ----
| ---- ---- ---- ----
-----gt; ---- -- -- ---- ----
---- ---- ---- ----
---- ---- -- -- ----
---- ---- ---- ----
---- ---- ---- -- --
255 ---- ---- ---- ----
The following is a translation of the author's original text:
Above The algorithm of The byte is used as a subscript to locate a 32-bit value in the table
3: XOR this value into register.
4: If there is still unprocessed data, return to the first step and continue execution.
It can be written like this in C:
r=0;
while (len--)
r = ((r lt ;lt; | p* ) ^ t[(r gt; gt; 24) amp; 0xFF];
But this algorithm is based on the original data that has been extended with 0, so in the end. We also need to add such a loop to add W 0s to the original data.
My study notes:
Note that W 0s are not added first during preprocessing, but instead. Add such processing after the loop described in the above algorithm
for (i=0; ilt; W/4; i)
r = (r lt; lt; ^ t[. (r gt; gt; 24) amp; 0xFF];
So it is W/4 because if there are W 0s, because we use bytes (8 bits) as the unit, it is W/ 4 0 bytes. Note that it is not looped w/8 times
The following is the translation of the author's original text:
1: For the w/4 0 bytes at the end, the fact Their function is only to ensure that all original data has been sent to the register and processed by the algorithm.
2: If the initial value in the register is 0, then the first 4 cycles only serve to change the original data. The first 4 bytes of the original data are sent to the register (this depends on the generation of the table). Even if the initial value of register is not 0, the first 4 bytes of the original data are only transferred. XOR with some constants from register, and then send them to register.
3A xor B) xor C = A xor (B xor C)
In summary, the original algorithm can be changed to:
--- --lt;Message (non augmented)
|
v 3 2 1 0 Bytes
| ---- ---- ---- ----
XOR----lt; | | | | |
| ---- ---- ---- ----
| ^
| |
| XOR
| |
| 0 ---- ---- ---- ----
v ---- ---- ---- ----
| ---- ---- -- -- ----
| ---- ---- ---- ----
| ---- ---- ---- ----
| ---- ---- ---- ----
| ---- ---- ---- -- --
-----gt; ---- ---- ---- ----
---- ---- --- - ----
---- ---- ---- ----
---- ---- ---- --- -
---- ---- ---- ----
255 ---- ---- ---- ----
p>
Algorithm:
1: Shift register to the left by one byte and read a new byte from the original data.
2: Use the data just moved out of register The byte is XORed with the new byte read to generate a positioning subscript, and the corresponding value is obtained from the table.
3: XOR the value into register
4: If there is still unprocessed data, return to the first step and continue execution.
My study notes:
I still don’t know much about this algorithm. Maybe it has something to do with the properties of XOR. Please point out why?
Thank you.
At this point, we have basically understood the algorithm principles and ideas of CRC32. In the next chapter, I want to focus on implementing it in Java language based on algorithmic ideas.
hjzgq replied on: 2003-05-15 14:14:51
Mathematical algorithm has always been the core of password encryption, but in general soft-path encryption, it does not seem to People don't care much about it, because most of the time software encryption itself is a programming technique. However, with the popularity of serial number encryption programs in recent years, the proportion of mathematical algorithms in software encryption seems to be increasing.
Let’s first take a look at how the serial number encryption that is so popular on the Internet works. When a user downloads a piece of Shareware -- free software from the Internet, there is usually a time limit for use. After the trial period of the free software has expired, you must go to the company of the software to register. Can continue to be used. The registration process generally involves the user telling the software company their personal information (usually mainly their name) and their credit card number. The software company will calculate a serial code based on the user's information. After the user obtains the serial code, he will follow the registration requirements. Steps: Enter the registration information and registration code into the software. After the legality of the registration information is verified by the software, the software will cancel its various restrictions. This kind of encryption is relatively simple to implement, does not require additional costs, and is very convenient for users to purchase. 80% of the software on the Internet is protected in this way.
We can notice that the legality process of the software verifying the serial number is actually the process of verifying whether the conversion relationship between the user name and the serial number is correct. There are two most basic verification methods. One is to generate a registration code based on the name entered by the user, and then compare it with the registration code entered by the user. The formula is as follows:
Serial number = F (user name )