The design of most shared software (also known as serial numbers) of most shared software is not very good, and it is easier to be a registration machine for the crack. A method of making a registration code using a public key algorithm (also known as an asymmetric algorithm) RSA. With this method, it is difficult to write the registration machine when you don't know the key. In fact, some software has used this type of method.
Everyone knows that RSA uses a pair of keys, namely public key, and private key. It is difficult to launch private keys from public keys, and vice versa, this difficulty is based on large-scale decomposition. The idea of using the RSA to generate a shared software registration code is as follows: 1, first randomly generate a pair of public key E and private key D; 2, the software author writes a registration machine, the registration machine is completed, using the user name M with private key D Encryption, ciphertext C is the registration code. Since cipherology often contains non-display characters, it is best to encode ciphertext, which is changed to display characters, such as Base64, UuEncode encoding, and more. Ciphertext C = (M ^ D) MOD n where ^ represents the power, the MOD indicates that the modulus of the RSA is determined. 3, shared software to decode the registration code entered by the user (such as Base64 decoding, etc.), get the ciphertext, then use the public key E to decrypt the cipher text, to obtain the plain text M ', if the name of the user name is the same (ie Meet M '= M), then the registration code is correct, otherwise it is an illegal registration code. Cracks can get the public key E by tracking your software, but cannot get the private key D. There are a few points in the plaintext m '= (c ^ e) Mod D. With the current computing power, it is recommended to take the value of 512-bit or more. However, the length of such a registration code is also growing, and it may bring it inconvenience to the user. The large arithmetic library generally needs to implement RSA. 2, when the key is randomly generated, use as good random number generation algorithm, otherwise n is still very likely to be decomposed. 3. You can also encrypt the username by the public key e to obtain a registration code in the registration machine, and the registration code input by the user is decrypted with the private key D to obtain the username. At this time, the public key E cannot be used for 3, 65537, etc., otherwise, once it is guess, the registration machine can also be written, because the crack can get private key D from your software at this time. 4, this method is just to prevent the registration machine from being written, it cannot prevent the way to crack your software by modifying the jump instruction in the program. In order to prevent others from modifying your program file, you can encrypt your program code or data in a part of the registration code. 5, this method is slightly changed to prevent the genuine user from distributing the registration code, that is, use a method of one machine, replacing the user name to the hardware software information of the user machine, this hard software information should be able to uniquely represent the user. Machine, otherwise it is also easy to be forged. 6. After using the above method, only those who know at least one legal registration code can crack the program.
Here, an example is used to implement RSA with large arithmetic library free (http://www.und.nodak.edu/org/crypto/nodak.edu/org/crypto/crypto/num/program/programs/freelip/freelip_1.1.tar.gz). The library is written by C, commercial use requires a license. 1. First, the key pair is randomly generated. You can program a random search to search. Because of example, we use rsatool (http://www.secretashell.com/tmg/rsatool2v15.zip) to generate a parameter of 64-bit RSA: a large number of p = a57f2b33, a large number Q = E7C441B3, analog number n = 95D49FD119EF27A9, private key D = 76d2a6e2ac86cc99, public key E = 655372, making a registration machine. Encrypt the user name with the private key D, the ciphertext obtained as a registration code: first define the macro Win32 (VC comes, but you need yourself in the BCB), then include the header file "lip.h": # qdef win32 #define Win32 # Endif # include "lip.h" and add "lip.c" to Project. Then convert the username ASCII code to the corresponding hex string: char username [] = "4e6574677579"; char Serialnumber [256]; Verylong n = 0, D = 0, M = 0, c = 0; / The large number of freeelip is Verylong. ZHSREAD (Username, & M); // Initialization Mind M, M is equal to the sixteenth of the username represents ZHSREAD ("95D49FD119EF27A9", & n); // Initialization mode NZHSREAD ("76d2a6e2ac86cc99", & d); // Initial private Key DZEXPMOD (M, D, N, & C); // Calculate Cipheet C = (M ^ D) MOD NZSWRITE (SerialNumber, c); // Write C's decimal string to serialNumber, namely the registration code 3 , Determine the registration code in the software.