Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the implementation of the design of C # serial number that does not repeat?

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "what is the realization method of non-repetition in the design of C# serial number". In daily operation, I believe that many people have doubts about the realization method of non-repetition in the design of C# serial number. I have consulted all kinds of data and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubt of "what is the realization method of non-repetition in the design of C# serial number"! Next, please follow the editor to study!

Design of serial number

As one of the ways of software authorization, serial number is widely used in application software. The main considerations are as follows: 1. After all, mental and manual work is paid for the protection of intellectual property rights. two。 Increase the ability of defense in business competition to prevent it from being stolen by competitors. 3. Enhance the effectiveness of the implementation of the contract to prevent the other party from undermining the cooperation mechanism for various reasons.

Based on the above aspects, from the point of view of protection and defensive thinking mode, it is necessary to increase the serial number function. Each author or company designs the serial number in a different way, and it is because it is different that we can add this function.

14.1 Design principles

The serial number is as short as possible

It is mainly considered from the perspective of cost. For example, the user site needs a legitimate software serial number, how do you transmit the serial number information to the user? Suppose we generate a long serial number symmetrically or asymmetrically, and if the other party is told orally, then the other party must record it with paper and pen, and it may not be correct after entering it into the software; if the serial number is transmitted to the other party through the network as a file, it needs to take up network resources, and the other party's computer does not necessarily have a network environment. In any case, the costs that may be involved in the generation and transmission of long serial numbers include: material cost, flow cost, labor cost, time cost and so on.

It is ideal if a character can express the complete information required by the serial number. However, this is an ideal state and is impossible to achieve, at least with my current ability. Therefore, it is necessary to express all the information of the serial number with the best length.

Avoid confusing characters to generate a serial number sent to the user, which includes the number 0 and the letter O, the number 1 and the letter l. Is it possible for users to try again and again? this kind of user experience is too bad, although it doesn't say it, at least it doesn't feel very comfortable.

14.2 Design idea

The idea of the design depends on what functions and attributes the serial number should achieve. From the functional point of view, including: 1. One computer, one serial number; 2. Although the input conditions are all the same, the serial number generated each time is different; 3. Verify the time limit of use; 4. The serial number has a registration time limit, which exceeds the prescribed use time, and the serial number will be invalidated to avoid multiple registration in a short time. From the attribute point of view, including: the same computer, the same input conditions generate different serial numbers.

Taking the above factors into account, the length of the serial number is 25 characters, and the format and element information of the serial number are shown below:

X01-X05: for the computer signature, 5-bit string, get the ID of a part of the machine, this part may be CPU, network card, hard disk and other information, the ID after MD5 encryption take the first five characters as the feature code, to achieve one code per machine. In this way, the signature may have the same situation, but the probability is very small.

X06-X13: the date on which the serial number is generated, an 8-bit string in the format: yyyyMMdd. Use in conjunction with later usage time limits to verify the useful life of the software.

X14-X15: for the registration time limit, 2-digit characters. Beyond this registration time limit, the serial number will not be able to register normally from the date of generating the serial number.

X16-X20: to use the time limit, 5-digit characters are used in conjunction with the generated serial number date to verify the life of the software.

X21: for the offset of the sequence number, 1-bit character, no matter in what scenario, the offset of the sequence number is different each time.

X22-X25: to preserve data bits, do not use them for the time being. Customize a sequence number dictionary information, such as: _ Dictionary = "JCB8EF2GH7K6MVP9QR3TXWY4", to remove confusing characters, which can be customized. Each part of the sequence number shifts the dictionary through a randomly generated offset (X21), and the corresponding character is extracted as a character of the sequence number according to the input digital information corresponding to the subscript of the dictionary.

The approximate process of generating a serial number:

An offset number is randomly generated within the length range of the dictionary information.

Circularly move the dictionary left or right according to the offset number.

According to the input digital information, such as 2 in 2015, as the subscript, the corresponding characters are extracted from the dictionary information.

The reverse parsing process is similar, only need to match the characters of the dictionary according to the X21 characters, and the corresponding subscript is used as the offset, the information can be parsed in reverse.

14.3 code implementation

1.MD5 operation class:

1234567891011121314public class Safety {public static string MD5 (string str) {string strResult = ""; MD5 md5 = System.Security.Cryptography.MD5.Create (); byte [] bData = md5.ComputeHash (Encoding.Unicode.GetBytes (str)); for (int I = 0; I < bData.Length; iTunes +) {strResult = strResult + bdata [I] .ToString ("X");} return strResult;}}

2. Register the information class:

12345678910111213141516public class RegInfo {public RegInfo () {KeySn = ""; Date=DateTime.MinValue; RegLimitDays = 0; UseLimitDays = 0; Offset = 0;} public string KeySn {get; set;} public DateTime Date {get; set;} public int RegLimitDays {get; set;} public int UseLimitDays {get; set;} public int Offset {get; set;}

3. Offset operation type:

12345internal enum OffsetType {Left, Right}

4. Serial number management class

+ View Code

14.4 Code confusion

From a security point of view, .NET programs can easily be decompiled into source code without confusion. From a professional point of view, even if the serial number function is added, it will not help. Professionals can crack it every minute, although very few people do so, but there is such a possibility. If a software person wants to know about good software, the first reaction may be decompilation.

For software used by companies or businesses, it is necessary to increase confusion, although open source is now very popular.

14.5 code cracking

No matter how the .NET program is confused, it can be cracked in theory, and there is no need to dwell on the theory. There are usually two ways to crack: registration machine and violence.

In the way of the registration machine, it is necessary to calculate the generating algorithm of the serial number through the process and mechanism of verifying the serial number of the software, and develop a small software according to the inverse algorithm, which is used to generate the serial number away from the authorization of the author. This approach does not break the code of the program itself, and is relatively mild. The way of violence is to find the code in the sequence number verification part and prevent the code from being executed effectively by deleting or bypassing the validation code. This approach will make changes to the code of the program itself, so there are some risks.

14.6 Summary

There are many ways to implement serial numbers, and the above methods are not necessarily the best, but I hope it will be helpful to developers.

The final realization effect is as follows:

At this point, on the "C# serial number design does not repeat the implementation of what is the end of the study, I hope to be able to solve everyone's doubts." The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report