Short chain generation and management system based on hash algorithm
Through the short chain generation and management system based on the hash algorithm, the problem of hash conflict and the limited code space of the TinyURL algorithm solution is solved, the uniqueness and efficient management of the short chain are achieved, and it is suitable for multi-user and large-volume marketing scenarios to ensure Data security and information transmission efficiency support precise positioning and data analysis of one household and one chain.
Patent Information
- Application Number
- CN202410807873.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-21
- Publication Date
- 2024-10-15
AI Technical Summary
There are problems in the existing short link generation technology such as hash conflicts and the limited code space of the TinyURL algorithm solution, which leads to data confusion or loss, and it is difficult to achieve accurate positioning and data analysis of one user and one link in a large-volume marketing scenario.
A short chain generation and management system based on a hash algorithm is adopted, and the long chain is converted into a short chain through the short chain conversion module. The hash algorithm and the 62-digit sequential generation method are used to solve the problems of hash conflicts and limited code space. And through the management module, effective management and authority control of short chains are carried out.
It achieves the uniqueness and efficient management of short chains, is suitable for multi-user low-frequency calls and large-volume marketing scenarios, ensures data security and information transmission efficiency, and supports precise positioning and data analysis of one household and one chain.
Smart Images

Figure CN118779546A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of network information processing, and in particular to a short link generation and management system based on a hash algorithm. Background Art
[0002] As network information becomes increasingly abundant, URL (Uniform Resource Locator) is widely used in various network services as an identifier of resources on the Internet. However, with the increase of information and the complexity of links, the length and complexity of URLs are also increasing. Long URLs not only bring inconvenience to users in some usage scenarios that require manual input (such as advertising, publications, text messages, Weibo, etc.), but also limit the efficiency of network services due to the network bandwidth occupied during the transmission process. At present, there are mainly the following technical solutions for short link generation technology:
[0003] 1. Hash algorithm scheme: Through hash algorithms, such as MD5, SHA, etc., long chains are converted into short chains of fixed length. The main advantage of this scheme is that it is simple and intuitive. But its main problem is hash conflict, that is, two different long links may be mapped to the same short link. If an appropriate conflict resolution strategy is not adopted, this may cause data confusion or loss.
[0004] 2. Database self-increment ID solution: Each long chain is stored in the database and assigned a self-increment ID, which is then converted into base 62 to form a short chain. This method is simple and can effectively avoid hash conflicts. However, the disadvantage of this solution is that it requires database support and needs to process a large number of database read and write requests, which may pose challenges to database performance and storage.
[0005] 3. TinyURL algorithm: The main idea is to use 62 printable characters (10 numbers + 26 uppercase and lowercase letters) as the base for conversion. The short link generated by this method is relatively short, but the code space size of this method is limited, and too many characters may result in the inability to generate new short links.
[0006] 4. Use memory databases such as Redis to store the mapping relationship between short links and long links to improve access efficiency. However, due to the limited storage space of memory databases, a large number of long links may consume a lot of storage space and may also cause data loss due to the implementation mechanism of memory databases. Summary of the invention
[0007] The purpose of the present invention is to propose a short link generation and management system based on a hash algorithm in view of the hash conflict in short link generation and the limited code space size of the TinyURL algorithm scheme in the background technology.
[0008] The technical solution of the present invention is a short link generation and management system based on a hash algorithm, comprising:
[0009] The short-link conversion module is the core module of the system, responsible for converting long-link addresses into short-link addresses;
[0010] Input module, where the user enters the long chain address. The module will perform basic format verification on the input and then pass the address to the short chain conversion module;
[0011] The output module feeds back the short link address generated by the short link conversion module to the user. After obtaining the short link address, the user uses this short link address to access the short link system, and then is redirected to the original long link address.
[0012] And a management module, which is responsible for managing the generated short link addresses.
[0013] Preferably, the management module functions include tracking the usage of short link addresses, setting the expiration time of short link addresses, and managing access rights to short link addresses.
[0014] Preferably, in the short link conversion module, there are two different ways to convert the long link address into the short link address.
[0015] Preferably, converting the address of the long chain into the address of the short chain adopts a hash algorithm, including the following steps:
[0016] S11, define the chars array to contain lowercase letters az, array 0-9, uppercase letters AZ;
[0017] S12, concatenate a custom key with the incoming URL and perform MD5 encryption to generate a 32-bit encrypted string. The four groups of numbers generated in this step can generate four groups of strings;
[0018] S13, perform bitwise AND operation on the encrypted characters in hexadecimal format of 8 bits each and 0x3FFFFFFF, and obtain 4 groups of long numbers;
[0019] S14, perform a bitwise AND operation on the obtained long value and 0x0000003D, obtain the index of the character array chars and add the obtained characters;
[0020] S15, loop step 3, shift right 5 bits each time, and get a string of length 6 after 6 loops;
[0021] S16, take a random number according to the length of the long chain to obtain the short chain subscript, and select one of the four strings generated in S2 as the actual short chain;
[0022] S17. Return to the short link and save.
[0023] Preferably, the address of the long chain is converted into the address of the short chain by using a 62-base digital sequence generation method, including the following steps:
[0024] S21. Define and store a long type initial value A according to the desired short chain length of the lock, and generate the short chain according to the value A;
[0025] S22, when generating a short chain, convert the value A into base 62, save the result as a character, and increment A;
[0026] S23, the system pre-generates the character strings required for 10 million short links, and automatically supplements the character strings when the number of scheduled monitoring is less than 2 million;
[0027] S24. When users conduct mass marketing, they transmit millions of long chains to the system. The system allocates the pre-generated strings to these long chains through multi-threaded processing and saves them, and then returns the results to the users.
[0028] S25. The system supports concurrent calls. When pre-allocation is insufficient, real-time allocation will be triggered.
[0029] Compared with the prior art, the present invention has the following beneficial technical effects: two short link generation methods, the first one uses a hash algorithm to generate unique characters based on the long chain, and if repeated, it will be rehashed and regenerated to solve the hash conflict of the hash algorithm scheme. It is suitable for low-frequency call scenarios of multiple users with a single short chain, and a short chain can be used repeatedly within the time limit. The second method generates in a 62-hexadecimal order, the short chain will not be repeated, the short chain obtained each time for the same long chain is inconsistent, and the problem of limited code space size of the TinyURL algorithm scheme is solved, and sensitive words in random combinations are removed. It is suitable for large-scale marketing scenarios with one household and one chain, accurately locates user behavior, and facilitates data analysis. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] Figure 1 The working flow chart of the hash algorithm proposed by the present invention;
[0031] Figure 2 The present invention provides a workflow diagram for the method of generating a 62-base digital sequence. DETAILED DESCRIPTION
[0032] Embodiment 1
[0033] The present invention proposes a short link generation and management system based on a hash algorithm, comprising:
[0034] The short chain conversion module is the core module of the system, responsible for converting the long chain address into the short chain address. In the short chain conversion module, there are two different ways to convert the long chain address into the short chain address;
[0035] Input module, where users input long link addresses. This module will perform basic format verification on the input, such as checking whether the input content complies with the URL format, and then pass the address to the short link conversion module;
[0036] The output module feeds back the short link address generated by the short link conversion module to the user. After obtaining the short link address, the user can conveniently use this short link address to access the short link system, and then redirect to the original long link address;
[0037] And the management module, which is responsible for managing the generated short link addresses. The management module functions include tracking the use of short link addresses, setting the expiration time of short link addresses, and managing the access rights of short link addresses; specifically, tracking the use of short link addresses, including recording the number of visits, visiting users and other information; setting the expiration time of short link addresses, after which the user can no longer access the original address through the short link address; managing the access rights of short link addresses, such as setting whether to allow public access, whether to restrict access to certain users, etc.
[0038] Embodiment 2
[0039] like Figure 1 As shown, the present invention proposes a short chain generation and management system based on a hash algorithm. Compared with the first embodiment, this embodiment introduces a method for converting the address of a long chain into the address of a short chain, specifically a hash algorithm, including the following steps:
[0040] S11, define the chars array to contain lowercase letters az, array 0-9, uppercase letters AZ;
[0041] S12, concatenate a custom key with the incoming URL and perform MD5 encryption to generate a 32-bit encrypted string. The four groups of numbers generated in this step can generate four groups of strings;
[0042] S13, perform bitwise AND operation on the encrypted characters in hexadecimal format of 8 bits each and 0x3FFFFFFF, and obtain 4 groups of long numbers;
[0043] S14, perform a bitwise AND operation on the obtained long value and 0x0000003D, obtain the index of the character array chars and add the obtained characters;
[0044] S15, loop step 3, shift right 5 bits each time, and get a string of length 6 after 6 loops;
[0045] S16, take a random number according to the length of the long chain to obtain the short chain subscript, and select one of the four strings generated in S2 as the actual short chain;
[0046] S17. Return to the short link and save.
[0047] The input long chain address is processed to generate a unique key value, and this key value is encoded into characters to generate a short chain address. During the conversion process, if the generated short links collide, that is, multiple long links generate the same short link, the module will use a specially designed collision handling mechanism, such as rehashing, chain address expansion, etc., to prevent data loss or errors caused by address collisions.
[0048] Embodiment 3
[0049] like Figure 2 As shown, the present invention proposes a short chain generation and management system based on a hash algorithm. Compared with the first embodiment, this embodiment introduces another method for converting the address of a long chain into the address of a short chain, specifically a 62-base digital sequence generation method, including the following steps:.
[0050] S21. Define and store a long type initial value A according to the desired short chain length of the lock, and generate the short chain according to the value A;
[0051] S22, when generating a short chain, convert the value A into base 62, save the result as a character, and increment A;
[0052] S23, the system pre-generates the character strings required for 10 million short links, and automatically supplements the character strings when the number of scheduled monitoring is less than 2 million;
[0053] S24. When users conduct mass marketing, they transmit millions of long chains to the system. The system allocates the pre-generated strings to these long chains through multi-threaded processing and saves them, and then returns the results to the users.
[0054] S25. The system supports concurrent calls. When the pre-allocation is insufficient, real-time allocation will be triggered. The value is pre-occupied according to the number of long chains called each time. For example, if A is currently 1000, user A needs 10 long chains, and user B needs 20 long chains. At the same time, A is called to lock first. If A grabs the lock, A first changes the value to 1010, then releases the lock, and B gets the lock again and changes the value to 1030. At this time, the 10 long chains required by A are the 62-decimal strings corresponding to 1001 to 1010, and the 20 long chains required by B are 1011-1030. Then the two threads generate all the long chains of A and B at the same time and return.
[0055] Character pre-generation, high-frequency and large data volume calls, multi-threaded allocation, the system uses multi-threading in many places to achieve pre-generation, fast allocation, and fast response.
[0056] In summary, the present invention can effectively handle the address collision problem of short links based on the hash algorithm, and ensure the uniqueness of the generated short links; for some short-term valid content or activities, set the validity period of the short link, and the link will automatically expire after the time is over, so as to improve the timeliness and security of information; when meeting the large amount of data marketing, a large number of short links are generated to achieve one link for one household. It is easy to track, which is very helpful for data analysis and market research; the domain name can be customized, which is convenient for specific activities to enhance the brand image and popularity; it improves the efficiency of information transmission and improves the user experience, which plays an important role in business promotion and data analysis.
[0057] The embodiments of the present invention are described in detail above with reference to the accompanying drawings, but the present invention is not limited thereto, and various changes can be made within the knowledge scope of technicians in the relevant technical field without departing from the purpose of the present invention.
Claims
1. A short link generation and management system based on hash algorithm, characterized in that: include: The short-link conversion module is the core module of the system, responsible for converting long-link addresses into short-link addresses; Input module, where the user enters the long chain address. The module will perform basic format verification on the input and then pass the address to the short chain conversion module; The output module feeds back the short link address generated by the short link conversion module to the user. After obtaining the short link address, the user uses this short link address to access the short link system, and then is redirected to the original long link address. And a management module, which is responsible for managing the generated short link addresses.
2. The short link generation and management system based on hash algorithm according to claim 1 is characterized in that: The management module functions include tracking the usage of short link addresses, setting the expiration time of short link addresses, and managing the access rights to short link addresses.
3. The short link generation and management system based on hash algorithm according to claim 1 is characterized in that: In the short chain conversion module, there are two different ways to convert the long chain address to the short chain address.
4. The short link generation and management system based on hash algorithm according to claim 3 is characterized in that: The hash algorithm is used to convert the long chain address to the short chain address, including the following steps: S11, define the chars array to contain lowercase letters az, array 0-9, uppercase letters AZ; S12, concatenate a custom key with the incoming URL and perform MD5 encryption to generate a 32-bit encrypted string. The four groups of numbers generated in this step can generate four groups of strings; S13, perform bitwise AND operation on the encrypted characters in hexadecimal format of 8 bits each and 0x3FFFFFFF, and obtain 4 groups of long numbers; S14, perform a bitwise AND operation on the obtained long value and 0x0000003D, obtain the index of the character array chars and add the obtained characters; S15, loop step 3, shift right 5 bits each time, and get a string of length 6 after 6 loops; S16, take a random number according to the length of the long chain to obtain the short chain subscript, and select one of the four strings generated in S2 as the actual short chain; S17. Return to the short link and save.
5. The short link generation and management system based on hash algorithm according to claim 1 is characterized in that: The address of the long chain is converted into the address of the short chain using a 62-base digital sequence generation method, including the following steps: S21. Define and store a long type initial value A according to the desired short chain length of the lock, and generate the short chain according to the value A; S22, when generating a short chain, convert the value A into base 62, save the result as a character, and increment A; S23, the system pre-generates the character strings required for 10 million short links, and automatically supplements the character strings when the number of scheduled monitoring is less than 2 million; S24. When users conduct mass marketing, they transmit millions of long chains to the system. The system allocates the pre-generated strings to these long chains through multi-threaded processing and saves them, and then returns the results to the users. S25. The system supports concurrent calls. When pre-allocation is insufficient, real-time allocation will be triggered.
Citation Information
Patent Citations
Short link address generating method and system thereof
CN106412140A
Network long and short chain configuration management method
CN107135283A
Method and system for generating and analyzing short link
CN115344799A
Short link two-dimensional code generation method and device
CN115587609A
Method and Apparatus for Embedding Information in a Short URL
US20110295990A1
