Simple implementation of registration in Shared Software

Source: Internet
Author: User
The simple implementation of the registration part in the shared software-general Linux technology-Linux programming and kernel information. The following is a detailed description. Currently, many shared software use registration codes to protect the software. The so-called registration code is a set of strings related to certain user information (such as user name and computer hardware. Because the registration code is relatively simple to transmit and easy to verify (compared with the disk, disk fingerprint, etc.), the registration code is now more and more widely used, and even some commercial software, for example, Windows XP uses a similar mechanism (Microsoft is called Windows Product ).
Activation ).

When talking about the registration code, you can't help but mention the register. A register is a program used to generate registration codes. Its computing logic is usually the same as that of a protected application. The registration number obtained through the same or pre-agreed computing logic as the protected application determines the behavior of the protected application, such as displaying "software not registered" or disabling certain functions, or display the registrant's name in the "about" dialog box.

The end user submits his/her registration information in some way, such as the name of his/her organization, or even the extremes, providing information that can determine the identity of a person, such as the cpu id of the Pentium iii cpu, the serial number of the hard disk, and the MAC address of the NIC. Then, register the server or call center service personnel to calculate a registration number based on the information provided by the user and notify the end user.

Generally, because manual operations may cause errors, we hope that the registration process will be automatically implemented by the computer. However, this raises the question: why do users believe that our programs will not disclose their personal privacy? To address this problem, the popular practice is to provide a number of options, including telephone registration, online registration, and normal mail registration, and to inform users of the content submitted by the program.

In addition, some information related to the user's computer, such as configuration, should not be transmitted in plaintext. This is because the user may not be willing to disclose the information to us, and the other is because the transmission of information in plaintext may cause third parties (such as cracker) to intercept the information. Currently, the popular method is to use a hash algorithm to encode the information that we don't need but determine the user identity and then send it again. Of course, we can use SSL encryption or other methods to ensure security during the sending process. Since it has little to do with the main content of this article, we will not repeat it here. Readers can refer to relevant books.

User information to be kept confidential → hash algorithm → secure transmission (such as SSL) → Server

In my personal experience, using different algorithms to calculate and verify the registration code can improve the security of the registration process to a certain extent. Of course, no security measures can be guaranteed not to be decrypted. "No locks cannot be opened in the world." decryption is only a matter of time. When constructing a registration code algorithm, as long as the decryption cost exceeds the value of the software, it does not have to be too complicated.

As a user, No matter what registration method is used, he does not want to be too complicated. Direct registration through a computer is undoubtedly the most convenient, but many users may not want to do so. As a user, the user uses phone registration to indicate his/her registration ID (usually including the product ID, user name, and other information ), and entering the registration code should be the most troublesome of all kinds of registration methods.

The registration ID and registration code should have the following features:
(1) easy to identify and input. The registration code is not a password and does not need to use a large number of special characters and combinations of upper and lower cases. Therefore, the registration code and registration ID should not contain uppercase/lowercase letters or confusing numbers (1-I, 0-O, 2-Z ).
(2) ability to check errors. Statistics show that when you enter the registration code, the order of errors (for example, 1234 is entered as 1243) and the key-hitting error is the most common error. The common method is to divide the registration code into several sections, each section includes a verification code, so that the registration code has the ability to check errors.

To reflect the above requirements, I constructed an algorithm like this:
(1) Calculate the entered user name, and calculate and follow the following rules:
Set the result to a and the preset value to 0.
Take the ASCII value of each character of the user name string in sequence, multiply the upper digit, and accumulate it to.
For example:
J a s o n L I
1 2 3 4 5 6 7 8
In this way, a = (char) 'J' + (char) 'A') * 2 + (char)'s ') * 3 +...

(2) convert a and a 2 into registration strings according to certain rules.
The implementation procedure is as follows:

// Reg. cpp: Demo program for Keygen
// By Jason Li, 2001. Written for FrontFree techonology network

# Include <string>
# Include <iostream>

Using namespace std;

Typedef int BOOL;

Const bool true = (1 = 1 );
Const bool false =! TRUE;

// Define the magic string
Const string sMagic = "l5wxtuyj1_vmb4ga8sfkqn9e36rpdc ";

String GetRegstr (string & sName ){
String sResult = "FFTN -";
Long lSum = 0;
Long lSum1;
Long lChksum;

Register unsigned int I;

// Calculate the registration string
For (I = 0; I <sName. length (); I ++ ){
LSum + = sName. at (I) * (I + 1 );
}
// The checksum prevents accident input
LChksum = sMagic. at (lSum % 30 );
SResult + = sMagic. at (lSum % 30 );
LSum1 = lSum;
For (I = 0; I <4; I ++ ){
SResult + = (char) (lSum % 10) + '0 ');
LChksum + = (lSum % 10) + '0 ');
LSum/= 10;
}
SResult + = (sMagic. at (lChksum % 30 ));
SResult + = "-";

LChksum = 0;
LSum = lSum1 * lSum1/3;
For (I = 0; I <5; I ++ ){
SResult + = sMagic. at (lSum % 30 );
LChksum + = sMagic. at (lSum % 30) * (I % 2) + 1); // Sum even bytes twice
LSum/= 7;
}
SResult + = (sMagic. at (lChksum % 36 ));
SResult + = "-";

LChksum = 0;
LSum = lSum1 * lSum1/5;
For (I = 0; I <5; I ++ ){
SResult + = sMagic. at (lSum % 30 );
LChksum + = sMagic. at (lSum % 30) * (I % 2) + 1); // Sum even bytes twice
LSum/= 11;
}
SResult + = (sMagic. at (lChksum % 36 ));
SResult + = "-";

LChksum = 0;
LSum = lSum1 * lSum1/7;
For (I = 0; I <5; I ++ ){
SResult + = sMagic. at (lSum % 30 );
LChksum + = sMagic. at (lSum % 30) * (I % 2) + 1); // Sum even bytes twice
LSum/= 17;
}
SResult + = (sMagic. at (lChksum % 30 ));

Return sResult;
}

Int main (void ){
String sName;
String sRegstr;

// Output the prompt for user
Cout <"Registration Code Generator DEMO program version 1.00" <endl;
Cout <"By Jason li, 2001. For test purpose only." <endl;
Cout <endl;

// Loop until the user name is legal to the algorithm
Do {
// Get the user name
Cout <"Enter the user's name (5 chars min), followed by comma (,):";
Getline (cin, sName ,',');
} While (sName. length () <= 5 );

Cout <"User" <sName;

SRegstr = GetRegstr (sName );

Cout <"has the registration string of" <sRegstr;
Cout <endl;

Return 0;
}

The program is written in ansi c ++ standard and can be used in Visual C ++ 6 and gnu c ++.
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.

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.