Short link generation method, server, storage medium and program product

By introducing user information and pseudo-random numbers generated at the current time in the short link generation method, combining the index calculation formula and security review mechanism, the problems of high repetition rate and poor security in the existing short link generation method are solved, and the more Safe, reliable and personalized short link generation.

CN119441643AActive Publication Date: 2025-02-14SHAOXING TONGZE NETWORK TECHNOLOGY CO LTD
View PDF 8 Cites 0 Cited by

Patent Information

Application Number
CN202411552096.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-01
Publication Date
2025-02-14
Estimated Expiration
2044-11-01

AI Technical Summary

Technical Problem

Due to the fixedness of the hash function, the same long URL always generates the same short link, resulting in high repetition rate of short links, poor security, and uncontrollable quality.

Method used

By obtaining user information and current time, generating pseudo-random numbers, combining preset index calculation formulas to generate valid indexes, thereby selecting continuous characters from the hash value as hash short codes, and security review and encoding are performed to generate the final Short link.

Benefits of technology

It effectively reduces the duplication rate of short links, improves security and availability, and ensures that the generated short links have a unified structure and format, which is easy to manage and use.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119441643A_ABST
    Figure CN119441643A_ABST
Patent Text Reader

Abstract

The invention discloses a short link generation method, a server, a storage medium and a program product, and relates to the technical field of internet information, and the method comprises the steps: obtaining user information, current time and an original webpage address; inputting the original webpage address into a preset hash function to obtain a hash value of a first length; generating a pseudo-random number according to the user information and the current time; inputting the pseudo-random number into a preset index calculation formula to obtain an effective index; on the basis of the effective index, selecting a continuous character with a second length from the hash value as a hash short code; performing security review on the Hash short code to ensure that the Hash short code does not have preset sensitive vocabularies, preset easily-confused characters and / or preset known vulnerabilities; and if the result of the security review is safe, encoding the Hash short code according to a preset link generation parameter to obtain a final short link. By implementing the method, the security of short link generation can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of Internet information technology, and in particular to a short link generation method, a server, a storage medium and a program product. Background Art

[0002] With the rapid development of the Internet, web links are becoming longer and longer. However, longer web links are not easy to remember, read, and enter manually, especially in social media, text messages, and other environments where the number of characters is limited. Therefore, short link services have emerged to simplify the link sharing process and improve user experience and communication efficiency.

[0003] The relevant short link generation technology is usually that the server puts the long URL into a preset hash function to generate a hash value of a fixed length, and then the server selects a part of the hash value, usually the first or middle few characters, as the identifier of the short link, thereby quickly providing the short link to the user.

[0004] Although existing short link generation methods can effectively shorten URLs, due to the fixed nature of the hash function, the same long URL always generates the same short link, resulting in a high repetition rate of short links, which can easily cause confusion when used on a large scale. Summary of the invention

[0005] The present application provides a short link generation method, a server, a storage medium and a program product for improving the security of short link generation.

[0006] In a first aspect, the present application provides a short link generation method, which is applied to a server, and the method includes: obtaining user information, current time and original web page address; inputting the original web page address into a preset hash function to obtain a hash value of a first length; generating a pseudo-random number based on the user information and the current time; inputting the pseudo-random number into a preset index calculation formula to obtain a valid index; based on the valid index, selecting continuous characters of a second length from the hash value as a hash short code, the first length being greater than the second length; performing a security review on the hash short code to ensure that the hash short code does not contain preset sensitive words, preset easily confusing characters and / or preset known vulnerabilities; if the result of the security review is safe, encoding the hash short code according to preset link generation parameters to obtain a final short link, and the preset link generation parameters are used to represent the structure and properties of the short link generation.

[0007] By adopting the above technical solution, firstly, the server introduces a pseudo-random number based on user information and current time, breaking the limitation of the traditional short link generation method that the same long URL always generates the same short link. Even for the same original web address, different short links can be generated when accessed at different times or by different users, effectively reducing the repetition rate of short links and improving security. Secondly, the server conducts a security review of the hash short code to ensure that the generated short link does not contain preset sensitive words, preset easily confused characters and / or preset known vulnerabilities, thereby improving the security and availability of the short link. Finally, the server standardizes the hash short code by using preset link generation parameters, ensuring that the generated short link has a unified structure and format, which is convenient for unified management and user use.

[0008] In combination with some embodiments of the first aspect, in some embodiments, the preset index calculation formula is: Wherein, I represents the valid index, R represents the pseudo-random number, and p represents a preset prime number. represents the preset golden section constant, L represents the first length of the hash value, represents floor operation, and mod represents modulo operation.

[0009] By adopting the above technical solution, the server achieves efficient and uniform index generation through the preset index calculation formula. Introducing the preset prime number p as the modulus can provide good hashing characteristics and avoid periodic distribution; using the golden section constant As a multiplier, it can produce the most uniform distribution on the number axis and reduce the probability of collision; the rounding down operation and the final modulo L operation ensure that the generated valid index is always within the valid range. This calculation method not only has low computational overhead and high efficiency, but also ensures that the generated valid index has good randomness and uniformity, so that the hash short code selected from the hash value is more evenly distributed, further reducing the probability of duplication of short links.

[0010] In combination with some embodiments of the first aspect, in some embodiments, the hash short code is subjected to a security review to ensure that the hash short code does not contain preset sensitive words, preset easily confused characters and / or preset known vulnerabilities, specifically including: matching the hash short code with a preset sensitive word library to determine whether the preset sensitive words exist; checking whether the preset easily confused characters exist in the hash short code; inputting the hash short code into a preset vulnerability identification model to determine whether the preset known vulnerability exists; if the preset sensitive words, the preset easily confused characters and / or the preset known vulnerabilities do not exist in the hash short code, the result of the security review is safe; if the preset sensitive words, the preset easily confused characters and / or the preset known vulnerabilities exist in the hash short code, the result of the security review is unsafe.

[0011] By adopting the above technical solution and establishing a triple security review mechanism, the security and availability of short links are fully guaranteed. First, the server matches the hash short code with the preset sensitive word library to prevent the generated short link from containing inappropriate content or prohibited words; secondly, the server determines whether there are preset easily confusing characters in the hash short code to avoid generating confusing or difficult to identify short links, thereby improving the user experience; then, the server identifies potential security vulnerabilities in the hash short code through a preset vulnerability identification model, effectively preventing possible security threats. This multi-level security review mechanism can promptly detect and filter out unqualified short links, ensuring that the short links generated in the end are both safe and reliable, and easy to identify and use, significantly improving the quality and security of short link services.

[0012] In combination with some embodiments of the first aspect, in some embodiments, if the result of the security review is safe, the hash short code is encoded according to the preset link generation parameters to obtain the final short link, specifically including: determining the domain name prefix and path separator based on the preset link generation parameters; concatenating the domain name prefix, the path separator and the hash short code in a preset order; URL encoding the concatenated string; combining the encoded string with a preset protocol identifier to obtain the final short link.

[0013] By adopting the above technical solution, the server unifies the generation structure of short links based on preset link generation parameters. The domain name prefix and path separator can ensure that the generated short links have a unified format and hierarchy; splicing in a preset order can ensure the orderliness of the components of the short link; URL encoding processing can solve the compatibility problem of special characters, so that short links can be used normally in various environments; combining the encoded string with the preset protocol identifier can ensure the integrity and availability of the short link. This standardized encoding scheme not only improves the readability and ease of use of short links, but also facilitates unified management and maintenance of short links, and improves the compatibility and reliability of short links in different platforms and scenarios.

[0014] In combination with some embodiments of the first aspect, in some embodiments, after the step of performing a security review on the hash short code to ensure that the hash short code does not contain preset sensitive words, preset easily confusing characters and / or preset known vulnerabilities, the method also includes: if the result of the security review is insecure, determining the cause of the insecurity; based on the cause of the insecurity, selecting a corresponding correction strategy from a preset correction strategy library; according to the correction strategy, correcting the hash short code to obtain an optimized hash short code.

[0015] By adopting the above technical solution, the server effectively handles the situation where the security review fails. That is, when there is a security risk in the short link, the server first determines the cause of the insecurity, and then selects the most suitable correction strategy from the preset correction strategy library based on different insecurity reasons, and then executes the corresponding correction strategy to optimize the problematic hash short code into a safer form. This adaptive correction mechanism not only improves the success rate of short link generation, but also ensures that even in the event of security problems, the server can still generate a short link that meets the requirements through optimization, thereby improving the reliability of the short link generation method.

[0016] In combination with some embodiments of the first aspect, in some embodiments, after the step of encoding the hash short code according to preset link generation parameters to obtain a final short link if the result of the security review is safe, the method also includes: calculating the information entropy of the final short link; when the information entropy is greater than or equal to the preset information entropy threshold, storing the final short link, the original web page address, the user information and the current time in a distributed database; when the information entropy is less than the preset information entropy threshold, processing the final short link according to a preset information enhancement algorithm to obtain an optimized short link.

[0017] By adopting the above technical solution, the server introduces a short link quality evaluation mechanism based on information entropy, which measures the randomness and complexity of the short link by calculating the information entropy of the short link. When the information entropy is greater than or equal to the preset information entropy threshold, it indicates that the short link has sufficient randomness and security. The server stores it together with related information in the distributed database to ensure the reliability and traceability of the data; when the information entropy is less than the preset information entropy threshold, the server will start the information enhancement algorithm for optimization to improve the quality of the short link.

[0018] In combination with some embodiments of the first aspect, in some embodiments, the information entropy of the final short link is calculated, specifically including: counting the total number of characters in the final short link and the number of occurrences of each character; dividing the number of occurrences of each character by the total number of characters in the final short link to obtain the probability of occurrence of each character; inputting the probability of occurrence of each character into a preset information entropy calculation formula to obtain the information entropy of the final short link, and the preset information entropy calculation formula is: H = -∑[P(si)*log 2 (p(si))] Where H represents the information entropy, P(si) represents the occurrence probability of each character, and si represents each character.

[0019] By adopting the above technical solution, the server determines the information entropy of the final short link according to the preset information entropy calculation formula, thereby accurately reflecting the randomness and information density of the final short link, providing reliable data support for the quality control and optimization of the short link, and effectively improving the scientificity and reliability of the short link generation method.

[0020] In a second aspect, an embodiment of the present application provides a server, comprising: one or more processors and a memory; the memory is coupled to the one or more processors, the memory is used to store computer program code, the computer program code includes computer instructions, and the one or more processors call the computer instructions to enable the server to execute the method described in the first aspect and any possible implementation method of the first aspect.

[0021] In a third aspect, an embodiment of the present application provides a computer program product comprising instructions, which, when executed on a server, enables the server to execute the method described in the first aspect and any possible implementation of the first aspect.

[0022] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, comprising instructions, which, when executed on a server, enable the server to execute the method described in the first aspect and any possible implementation of the first aspect.

[0023] It is understandable that the server provided in the second aspect, the computer program product provided in the third aspect, and the computer storage medium provided in the fourth aspect are all used to execute the method provided in the embodiment of the present application. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding method, which will not be repeated here.

[0024] One or more technical solutions provided in the embodiments of the present application have at least the following technical effects or advantages: 1. Due to the use of a dynamic hash generation mechanism based on user information and current time, combined with a multi-level security review mechanism, even for the same original web page address, different secure and reliable short links can be generated, effectively solving the technical problems of high short link repetition rate, poor security and uncontrollable quality in related technologies, thereby realizing the personalization, security and reliability of the short link generation method.

[0025] 2. Due to the use of a preset index calculation formula and a quality assessment mechanism based on information entropy, combined with an intelligent correction strategy, the generated short links can be guaranteed to have good randomness and uniformity, effectively solving the technical problems of uneven distribution of short links, difficult quality quantification, and single optimization means in related technologies, thereby realizing the scientific, standardized and intelligent short link generation process.

[0026] 3. Due to the use of a distributed storage architecture and a complete data association mechanism, combined with standardized preset link generation parameters, it is possible to achieve reliable mapping and efficient management of short links and original information, effectively solving the technical problems of scattered data storage, poor correlation, and difficulty in unified management in related technologies, thereby achieving high availability, traceability and maintainability of short link services. BRIEF DESCRIPTION OF THE DRAWINGS

[0027] Figure 1 It is a flowchart of a method for generating a short link in an embodiment of the present application; Figure 2 It is another flowchart of the method for generating a short link in an embodiment of the present application; Figure 3 It is a schematic diagram of a physical device structure of a server in an embodiment of the present application. DETAILED DESCRIPTION

[0028] The terms used in the following embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to be used as limitations to the present application. As used in the specification of the present application, the singular expressions "one", "a kind of", "above", "the" and "this" are intended to also include plural expressions, unless there is a clear indication to the contrary in the context. It should also be understood that the term "and / or" used in the present application refers to any or all possible combinations comprising one or more of the listed items.

[0029] In the following, the terms "first" and "second" are used for descriptive purposes only and are not to be understood as suggesting or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features, and in the description of the embodiments of the present application, unless otherwise specified, "plurality" means two or more.

[0030] For ease of understanding, the application scenarios of the embodiments of the present application are introduced below.

[0031] Xiaolin is a food blogger who often publishes food review articles on social platforms. One day, she wanted to share an in-depth review of a Michelin restaurant. The original link was "https: / / www.weiliao.com / food / review / michelin / 2024 / shanghai / restaurant / 158764?author=xiaolin&content=full&photos=gallery&comments=true&rating=5&visit_date=20240315&meal_type=dinner". However, the social platform has a character limit of 280 characters for each dynamic, and Xiaolin also needs to add her own comment text, which makes it impossible to publish detailed food reviews and complete link addresses within the limited 280 characters. Therefore, social platforms are in urgent need of a solution that can shorten the connection length while ensuring security and reliability.

[0032] The following is a description of the process of the method provided by this implementation. Figure 1 , which is a flow chart of the short link generation method in an embodiment of the present application.

[0033] S101, obtaining user information, current time and original web page address; Among them, user information refers to a set of identification data generated when a user accesses a platform, application, or system, including the user's unique identifier (such as user ID, session ID), access credentials (such as Cookies, Tokens), terminal information (such as device type, operating system, browser version), and network characteristics (such as IP address, geographic location, operator information), etc.; the current time refers to the system time when the server receives the short link generation request, usually expressed in the form of a Unix timestamp, accurate to milliseconds, to ensure the timing and uniqueness of the short link generation process; the original web page address is used to represent the complete URL that needs to be converted into a short link, and its structure usually includes a protocol header (such as http: / / , https: / / ), a domain name (such as www.example.com), a path (such as / path / to / page), a query parameter (such as? key=value), and an anchor (such as #section).

[0034] The server executes this step when it receives a short link generation request initiated by a user. Specifically, first, the server verifies the legitimacy of the received short link generation request, including checking the request method (GET / POST), the integrity of the request header field, the correctness of the content type, etc.; then, the server extracts user information from the request header field, such as checking the Authorization header to obtain the access token, obtaining session information from the Cookie, obtaining client information from the User-Agent, and obtaining the IP address from the X-Forwarded-For or Remote-Address; then, the server calls the system clock to obtain the current time, and performs time zone conversion and format standardization processing; finally, the server parses the original web page address from the parameters of the short link generation request, and performs URL format verification, including checking the legitimacy of the URL (whether it complies with the RFC standard), accessibility (whether it can be parsed and accessed normally), security (whether it contains malicious code or redirection), etc. For short link generation requests that do not meet the requirements, the server will return the corresponding error message.

[0035] S102, inputting the original webpage address into a preset hash function to obtain a hash value of a first length; Among them, the preset hash function refers to a cryptographic hash algorithm that can map input data of any length to a fixed-length output. Commonly used ones include MD5 (output 128 bits), SHA-1 (output 160 bits), SHA-256 (output 256 bits), etc. It has the characteristics of unidirectionality (the input cannot be inferred from the output), collision resistance (the probability of different inputs producing the same output is extremely low) and avalanche effect (slight changes in the input lead to significantly different outputs); the first length refers to the character length of the hash value output by the preset hash function, such as MD5 outputs 32 hexadecimal characters and SHA-256 outputs 64 hexadecimal characters; the hash value is used to represent the fixed-length string obtained after calculation by the preset hash function, usually expressed in hexadecimal form, and used in the subsequent short link generation process.

[0036] The server performs this step after completing the acquisition and verification of the original web page address. Specifically, first, the server standardizes the original web page address, including removing extra spaces and special characters in the URL, unifying the case format, processing relative paths, normalizing the order of query parameters, etc.; then, the server converts the standardized URL string into a byte array as the input of the preset hash function; then, the server calls the preset hash function to calculate the input. During this process, the server may use salting (adding additional random data) to increase the uniqueness of the hash result; finally, the server converts the output result of the preset hash function into a hexadecimal string and verifies whether the output length meets the expectations (i.e., the first length).

[0037] S103, generating a pseudo-random number according to the user information and the current time; Among them, pseudo-random numbers refer to seemingly random but actually reproducible numerical sequences generated by deterministic algorithms, and their random properties are sufficient to meet the needs of most application scenarios; the process of generating pseudo-random numbers based on user information and current time refers to the calculation process of converting input data (seed) into pseudo-random numbers, usually using standard algorithms such as the linear congruential method and the Mersenne twister algorithm; seed refers to the initial data for initializing the pseudo-random number generator.

[0038] The server executes this step after obtaining valid user information and the current time. Specifically, first, the server performs bitwise operations on the numerical data in the user information (such as the numerical representation of the user ID and IP address) and the current time to generate a 64-bit initial seed; then, the server performs encrypted hashing on the initial seed to increase its entropy value; then, the server inputs the processed seed into a preset pseudo-random number generator for initialization; finally, multiple rounds of iterative calculations are performed to generate the required pseudo-random numbers.

[0039] S104, inputting the pseudo-random number into a preset index calculation formula to obtain a valid index; Among them, the preset index calculation formula refers to a mathematical expression that maps pseudo-random numbers to a specific range, which is used to optimize the distribution characteristics of the index; the valid index refers to the starting position identifier of the characters intercepted from the hash value, and its value range must be between 0 and "the first length minus the second length".

[0040] The server executes this step after obtaining the pseudo-random number. Specifically, first, the server limits the pseudo-random number to a reasonable range through modular operation. The server can use a larger preset prime number (such as 2^31-1) as the modulus to obtain better distribution characteristics; then, the server multiplies the result by the golden section constant (about 0.618034) and rounds it. This step can significantly improve the distribution uniformity of the index; then, the server performs a modular operation on the result again to make it fall within the valid index range, and the upper limit of the range is "the first length minus the second length"; finally, the server verifies the validity of the calculation result to ensure that the array does not cross the bounds. The entire calculation process needs to handle special cases such as numerical overflow and division by zero, and retry when necessary.

[0041] Optionally, in general, the preset index calculation formula is: Wherein, I represents the valid index, R represents the pseudo-random number, and p represents a preset prime number. represents the preset golden section constant, L represents the first length of the hash value, represents floor operation, and mod represents modulo operation.

[0042] S105. Based on the valid index, select consecutive characters of a second length from the hash value as a hash short code, where the first length is greater than the second length; Among them, the second length represents the expected number of characters in the identifier part of the final short link, which is usually 6 to 8. The second length must ensure that the encoding space is large enough and the short link is short enough; continuous characters refer to a continuous character sequence starting from the position corresponding to the valid index in the hash value, and the original relative position relationship between the characters is required to be maintained; the hash short code is used to represent a fixed-length character string extracted from the complete hash value.

[0043] The server performs this step after obtaining a valid index. Specifically, first, the server verifies whether the combination of the valid index and the second length will cause an out-of-bounds condition, that is, to ensure that the "valid index + second length" does not exceed the total length of the hash value (that is, the first length); then, the server uses a string interception function to continuously intercept characters of the second length starting from the position corresponding to the valid index of the hash value; then, the server normalizes the intercepted string, including unifying the case of characters, replacing special characters, removing ambiguous characters, etc.; finally, the server verifies the length of the intercepted result to ensure that the length of the obtained hash short code is consistent with the expected (second length). If an exception occurs during the interception process, the server will record the error information and handle it accordingly according to the preset error handling strategy.

[0044] S106. Perform a security review on the hash short code to ensure that the hash short code does not contain preset sensitive words, preset easily confusing characters, and / or preset known vulnerabilities; Among them, security review refers to a series of inspection processes used to evaluate the security of hash short codes, including sensitive word detection, easily confused character detection, known vulnerability detection, etc.; sensitive words refer to a set of phrases that are not allowed to appear in short links, including banned words, insulting words, violent words, etc.; easily confused characters refer to character combinations that are visually confusing, such as "0" and "O", "1" and "l", etc.; known vulnerabilities refer to short link generation patterns or character combinations that have been discovered or recorded and may be maliciously exploited.

[0045] The server executes this step immediately after generating the hash short code. Specifically, first, the server loads the preset security check rules, including the sensitive word library, the easily confused character table, and the known vulnerability knowledge base; then, the server uses a multi-pattern matching algorithm (such as AC automaton) to scan the hash short code for sensitive words to check whether it contains inappropriate content; then, the server uses a regular expression engine to check whether there are potential security vulnerability patterns in the hash short code; after that, the server checks whether the hash short code contains easily confused characters.

[0046] S107. If the result of the security review is safe, the hash short code is encoded according to preset link generation parameters to obtain a final short link. The preset link generation parameters are used to represent the structure and attributes of the short link generation.

[0047] Among them, the preset link generation parameters refer to the configuration information used to build a complete short link, including the domain name of the short link service (such as "t.cn"), protocol type (such as "https"), path prefix, separator, etc.; encoding refers to the standardized process of converting the hash short code into a legal URL format, which requires processing special characters and reserved characters; the final short link refers to the short URL generated by the server that can be directly accessed and complies with the URL specification standards.

[0048] The server performs this step after the hash short code passes the security review. Specifically, first, the server reads the various parameters required for short link generation from the configuration information, including the service domain name, protocol type, path structure, etc., which are not limited here; then, the server URL encodes the hash short code to ensure that all characters are URL-safe. If necessary, the server can also perform Base64 encoding or other custom encoding; then, the server splices the encoded hash short code with other parameters (such as service domain name, path prefix) according to the predefined format template to build a complete URL structure; then, the server normalizes the generated URL to ensure compliance with RFC standards; finally, the server performs availability verification, including checking whether the URL length is appropriate, whether it contains illegal characters, and whether it complies with DNS specifications. The entire generation process needs to consider the compatibility of the URL to ensure that it can be used normally in different clients and protocols. If the generated URL does not meet the requirements, the server will make appropriate adjustments or regenerate it.

[0049] Optionally, in general, if the result of the security review is safe, the hash short code is encoded according to the preset link generation parameters, and the final short link can be obtained in the following way: Based on the preset link generation parameters, a domain name prefix and a path separator are determined; the domain name prefix, the path separator and the hash short code are concatenated in a preset order; the concatenated string is URL-encoded; the encoded string is combined with a preset protocol identifier to obtain the final short link.

[0050] By adopting the above technical solution, firstly, the server introduces a pseudo-random number based on user information and current time, breaking the limitation of the traditional short link generation method that the same long URL always generates the same short link. Even for the same original web address, different short links can be generated when accessed at different times or by different users, effectively reducing the repetition rate of short links and improving security. Secondly, the server conducts a security review of the hash short code to ensure that the generated short link does not contain preset sensitive words, preset easily confused characters and / or preset known vulnerabilities, thereby improving the security and availability of the short link. Finally, the server standardizes the hash short code by using preset link generation parameters, ensuring that the generated short link has a unified structure and format, which is convenient for unified management and user use.

[0051] The following is a more detailed description of the process of the method provided by this implementation. Figure 2 , is another flow chart of the short link generation method in an embodiment of the present application.

[0052] S201, obtaining user information, current time and original web page address; For details, please refer to step S101, which will not be described in detail here.

[0053] S202, inputting the original webpage address into a preset hash function to obtain a hash value of a first length; For details, please refer to step S102, which will not be described in detail here.

[0054] S203, generating a pseudo-random number according to the user information and the current time; For details, please refer to step S103, which will not be described in detail here.

[0055] S204, input the pseudo-random number into a preset index calculation formula to obtain a valid index; For details, please refer to step S104, which will not be described in detail here.

[0056] S205. Based on the valid index, select consecutive characters of a second length from the hash value as a hash short code, where the first length is greater than the second length; For details, please refer to step S105, which will not be described in detail here.

[0057] S206: Match the hash short code with a preset sensitive word library to determine whether the preset sensitive word exists; Among them, the preset sensitive word library refers to a data set containing a variety of words that are not suitable to appear in short links, usually including politically sensitive words, violent words, pornographic words, discriminatory words and other categories; matching refers to the calculation process of using a string matching algorithm to check whether the hash short code contains preset sensitive words.

[0058] The server executes this step immediately after obtaining the hash short code. Specifically, first, the server loads the most recently updated preset sensitive word library to ensure the timeliness of the sensitive word data; then, the server preprocesses the preset sensitive word library, including establishing a dictionary tree (Trie tree) or AC automaton to optimize the matching efficiency; then, the server converts the hash short code into a unified format (such as all lowercase) to ensure the accuracy of the match; then, the server uses the optimized matching algorithm to scan the hash short code, while processing the matching of variant words (such as homophones and similar characters); finally, the server records the location and content of all matched preset sensitive words.

[0059] S207, checking whether the preset easily confusing character exists in the hash short code; Among them, easily confused characters refer to a set of characters that are visually easily mistaken for other characters, including confusion between numbers and letters (such as 0 and O, 1 and l, 5 and S), similar letter combinations (such as rn and m), etc.

[0060] The server executes this step immediately after obtaining the hash short code. Specifically, first, the server loads the preset easily confused character comparison table, which contains all easily confused character combinations that need to be checked; then, the server traverses the hash short code at the character level to check whether each character belongs to the easily confused character combination; then, the server analyzes whether the combination of adjacent characters constitutes a visual confusion risk, such as checking whether "rn" may be mistaken for "m"; then, the server calculates the easily confused risk score of the entire hash short code according to the preset easily confused risk scoring rules; finally, the server determines whether there are preset easily confused characters in the hash short code based on the easily confused risk score.

[0061] S208, input the hash short code into a preset vulnerability identification model to determine whether the preset known vulnerability exists; Among them, the preset vulnerability identification model is used to identify string patterns that may pose security risks; known vulnerabilities refer to security threat types that have been discovered and recorded, including SQL injection patterns, XSS attack patterns, command injection patterns, etc.

[0062] The server executes this step immediately after obtaining the hash short code. Specifically, first, the server loads the preset vulnerability identification model, which usually adopts deep learning or ensemble learning methods and is specially trained for various preset known vulnerabilities; then, the server extracts features from the hash short code, including character-level statistical features, n-gram features, semantic features, etc.; then, the server inputs the extracted features into the preset vulnerability identification model for reasoning to determine whether there are preset known vulnerabilities in the hash short code.

[0063] S209: If the preset sensitive words, the preset easily confusing characters and / or the preset known vulnerabilities do not exist in the hash short code, the result of the security review is safe; If it is determined through steps S206, S207, and S208 that there are no preset sensitive words, preset easily confused characters, and / or preset known vulnerabilities in the hash short code, then the result of the security review performed by the server on the hash short code is that it is safe.

[0064] S210. If the result of the security review is safe, the hash short code is encoded according to preset link generation parameters to obtain a final short link, where the preset link generation parameters are used to represent the structure and attributes of the short link generation; For details, please refer to step S107, which will not be described in detail here.

[0065] S211, calculating the information entropy of the final short link; Among them, information entropy is a mathematical indicator used to measure the complexity and randomness of information in short links, and is used to evaluate the difficulty of short links being guessed or brute-force cracked; the calculation method refers to the specific mathematical formula used to obtain information entropy, which is usually based on Shannon's information entropy theory.

[0066] The server executes this step immediately after obtaining the final short link. Specifically, first, the server decomposes the final short link by characters and counts the frequency of each character; then, the server calculates the amount of information of each character; then, the server accumulates the amount of information of all characters to obtain the overall information entropy.

[0067] Optionally, in general, the information entropy of the final short link can be calculated by the following method: counting the total number of characters in the final short link and the number of occurrences of each character; dividing the number of occurrences of each character by the total number of characters in the final short link to obtain the occurrence probability of each character; inputting the occurrence probability of each character into a preset information entropy calculation formula to obtain the information entropy of the final short link, and the preset information entropy calculation formula is: H=-∑[P(si)*log 2 (p(si))] Among them, H represents the information entropy, P(si) represents the occurrence probability of each character, and si represents each character.

[0068] S212: When the information entropy is greater than or equal to the preset information entropy threshold, the final short link, the original webpage address, the user information and the current time are stored in a distributed database; Among them, the preset information entropy threshold refers to the pre-set minimum information entropy value, which is used to ensure that the short link has sufficient randomness and security; the distributed database refers to a distributed storage system used to store short link related information, which has high availability and scalability.

[0069] The server performs this step after calculating the information entropy of the final short link. Specifically, first, the server determines the data records to be stored, including the final short link, the original web page address, user information, and the current time; then, the server selects the best data sharding strategy to determine which database node the data should be stored in; then, the server executes distributed transactions to ensure the consistency of data on all database nodes; at the same time, the server updates the relevant indexes and caches to optimize subsequent query performance.

[0070] S213: When the information entropy is less than the preset information entropy threshold, the final short link is processed according to a preset information enhancement algorithm to obtain an optimized short link; The server executes this step when it finds that the information entropy of the final short link is insufficient. Specifically, first, the server analyzes the reasons for the insufficient information entropy of the final short link, such as the characters are too concentrated or there are obvious patterns; then, the server selects the corresponding enhancement strategy according to different reasons, which may include: inserting random characters in specific positions, adjusting the frequency of character occurrence, disrupting the order of characters, etc.; then, the server performs the selected enhancement operation while ensuring that the basic usability of the final short link is not destroyed; then, the server recalculates the information entropy of the enhanced short link to verify whether it reaches the preset information entropy threshold; if it still does not reach the preset information entropy threshold, multiple rounds of optimization are required until the preset information entropy threshold is reached. The entire enhancement process needs to maintain the readability and ease of use of the short link while improving randomness, and avoid excessive complexity.

[0071] S214. If the preset sensitive words, the preset easily confusing characters and / or the preset known vulnerabilities exist in the hash short code, the result of the security review is unsafe; If it is determined through steps S206, S207, and S208 that preset sensitive words, preset easily confused characters, and / or preset known vulnerabilities exist in the hash short code, then the result of the security review performed by the server on the hash short code is that it is unsafe.

[0072] S215. If the result of the safety review is unsafe, determine the cause of the unsafety; The server executes this step immediately after determining that the result of the security review is unsafe. Specifically, the server analyzes the detailed log of the security review and extracts the reasons for the unsafeness, where the reasons for the unsafeness refer to the problem categories that cause the hash short code to be judged as unsafe, including sensitive word triggering, character confusion risks, security vulnerabilities, etc.

[0073] S216, based on the unsafe reason, selecting a corresponding correction strategy from a preset correction strategy library; Among them, the correction strategy library refers to a knowledge base that contains various solutions to security issues and provides corresponding processing methods for different problem categories; the correction strategy refers to the specific operation plan used to solve specific problem categories, including character replacement, regeneration, position adjustment and other methods.

[0074] The server performs this step after determining the cause of the insecurity. Specifically, first, the server queries the preset correction strategy library according to the problem category to obtain all possible applicable correction strategies; then, the server screens these correction strategies to exclude correction strategies that may cause new problems, such as avoiding the use of replacement solutions that will produce new easily confused characters; then, the server evaluates the success probability and implementation cost of each correction strategy and selects the optimal correction strategy; if there are multiple problem categories, a comprehensive correction plan needs to be formulated to ensure that the various correction actions do not interfere with each other.

[0075] S217: According to the correction strategy, the hash short code is corrected to obtain an optimized hash short code.

[0076] Among them, correction refers to the specific operational process of improving the hash short code according to the selected correction strategy; optimized hash short code refers to the new hash short code after correction, which needs to meet both security and availability requirements.

[0077] The server performs this step after selecting a correction strategy. Specifically, first, the server creates a copy of the original hash short code to ensure that the correction process can be rolled back; then, the server performs various correction operations in the order defined in the correction strategy, such as replacing characters in specific positions, adjusting the order of characters, regenerating partial sequences, etc.; then, the server verifies the results of each correction operation in real time to ensure that the correction does not introduce new problems; for complex correction operations, the server may need to perform multiple rounds of iterations; finally, the server performs a complete security review of the optimized hash short code to ensure that all problems are resolved.

[0078] Because it adopts a dynamic hash generation mechanism based on user information and current time, combined with a multi-level security review mechanism, even for the same original web page address, different secure and reliable short links can be generated, effectively solving the technical problems of high short link repetition rate, poor security and uncontrollable quality in related technologies, thereby realizing the personalization, security and reliability of the short link generation method.

[0079] Due to the use of a preset index calculation formula and a quality assessment mechanism based on information entropy, combined with an intelligent correction strategy, the generated short links can be guaranteed to have good randomness and uniformity, effectively solving the technical problems of uneven distribution of short links, difficult quality quantification, and single optimization means in related technologies, thereby realizing the scientific, standardized and intelligent short link generation process.

[0080] Due to the adoption of a distributed storage architecture and a complete data association mechanism, combined with standardized preset link generation parameters, it is possible to achieve reliable mapping and efficient management of short links and original information, effectively solving the technical problems of scattered data storage, poor correlation, and difficulty in unified management in related technologies, thereby achieving high availability, traceability and maintainability of short link services.

[0081] The following describes the server in the embodiment of the present invention from the perspective of hardware processing. Figure 3 , is a schematic diagram of a physical device structure of a server in an embodiment of the present application.

[0082] It should be noted that Figure 3 The structure of the server shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0083] like Figure 3 As shown, the server includes a central processing unit (CPU) 301, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 302 or the program loaded from the storage part 308 to the random access memory (RAM) 303, such as executing the method described in the above embodiment. In RAM 303, various programs and data required for system operation are also stored. CPU 301, ROM 302 and RAM 303 are connected to each other through bus 304. Input / output (I / O) interface 305 is also connected to bus 304.

[0084] The following components are connected to the I / O interface 305: an input section 306 including an audio input device, a button switch, etc.; an output section 307 including a liquid crystal display (LCD) and an audio output device, an indicator light, etc.; a storage section 308 including a hard disk, etc.; and a communication section 309 including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication section 309 performs communication processing via a network such as the Internet. A drive 310 is also connected to the I / O interface 305 as needed. A removable medium 311, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 310 as needed so that a computer program read therefrom is installed into the storage section 308 as needed.

[0085] In particular, according to an embodiment of the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present invention includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a computer program for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication section 309, and / or installed from a removable medium 311. When the computer program is executed by a central processing unit (CPU) 301, various functions defined in the present invention are performed.

[0086] It should be noted that specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in conjunction with an instruction execution system, apparatus, or device.

[0087] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present invention. Each box in the flowchart or block diagram may represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for implementing the specified logical functions. It should also be noted that in some alternative implementations, the functions marked in the box may also occur in an order different from that marked in the accompanying drawings.

[0088] Specifically, the server of this embodiment includes a processor and a memory. A computer program is stored in the memory. When the computer program is executed by the processor, the short link generation method provided in the above embodiment is implemented.

[0089] As another aspect, the present invention further provides a computer-readable storage medium, which may be included in the server described in the above embodiment; or may exist independently without being assembled into the server. The above storage medium carries one or more computer programs, and when the above one or more computer programs are executed by a processor of the server, the server implements the short link generation method provided in the above embodiment.

[0090] As described above, the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.

[0091] As used in the above embodiments, the term "when..." may be interpreted to mean "if..." or "after..." or "in response to determining..." or "in response to detecting...", depending on the context. Similarly, the phrases "upon determining..." or "if (the stated condition or event) is detected" may be interpreted to mean "if determining..." or "in response to determining..." or "upon detecting (the stated condition or event)" or "in response to detecting (the stated condition or event)", depending on the context.

[0092] Those skilled in the art can understand that to implement all or part of the processes in the above-mentioned embodiments, the processes can be completed by computer programs to instruct related hardware, and the programs can be stored in computer-readable storage media. When the programs are executed, they can include the processes of the above-mentioned method embodiments. The aforementioned storage media include: ROM or random access memory RAM, magnetic disk or optical disk and other media that can store program codes.

Claims

1. A short link generation method, characterized in that: Applied to a server, the method comprises: Get user information, current time and original web page address; Inputting the original webpage address into a preset hash function to obtain a hash value of a first length; Generate a pseudo-random number according to the user information and the current time; Input the pseudo-random number into a preset index calculation formula to obtain a valid index; Based on the valid index, selecting consecutive characters of a second length from the hash value as a hash short code, wherein the first length is greater than the second length; Performing a security review on the hash short code to ensure that the hash short code does not contain preset sensitive words, preset easily confused characters and / or preset known vulnerabilities; If the result of the security review is safe, the hash short code is encoded according to preset link generation parameters to obtain a final short link, and the preset link generation parameters are used to represent the structure and attributes of short link generation.

2. The method according to claim 1, characterized in that The preset index calculation formula is: Wherein, I represents the valid index, R represents the pseudo-random number, and p represents a preset prime number. represents a preset golden section constant, L represents the first length of the hash value, represents floor operation, and mod represents modulo operation.

3. The method according to claim 1, characterized in that The security review of the hash short code to ensure that the hash short code does not contain preset sensitive words, preset easily confused characters and / or preset known vulnerabilities specifically includes: Match the hash short code with a preset sensitive word library to determine whether the preset sensitive word exists; Checking whether the preset easily confusing character exists in the hash short code; Input the hash short code into a preset vulnerability identification model to determine whether the preset known vulnerability exists; If the preset sensitive words, the preset easily confused characters and / or the preset known vulnerabilities do not exist in the hash short code, the result of the security review is safe; If the preset sensitive words, the preset easily confused characters and / or the preset known vulnerabilities exist in the hash short code, the result of the security review is unsafe.

4. The method according to claim 1, characterized in that: If the result of the security review is safe, the hash short code is encoded according to the preset link generation parameters to obtain the final short link, which specifically includes: Determine a domain name prefix and a path separator based on the preset link generation parameters; Concatenate the domain name prefix, the path separator and the hash short code in a preset order; URL encode the concatenated string; The encoded character string is combined with the preset protocol identifier to obtain the final short link.

5. The method according to claim 4, characterized in that After the step of performing a security review on the hash short code to ensure that the hash short code does not contain preset sensitive words, preset easily confused characters and / or preset known vulnerabilities, the method further includes: If the result of the safety review is unsafe, determine the cause of the unsafety; Based on the unsafe cause, select a corresponding correction strategy from a preset correction strategy library; According to the correction strategy, the hash short code is corrected to obtain an optimized hash short code.

6. The method according to claim 1, characterized in that After the step of encoding the hash short code according to preset link generation parameters to obtain a final short link if the result of the security review is safe, the method further includes: Calculating the information entropy of the final short link; When the information entropy is greater than or equal to the preset information entropy threshold, storing the final short link, the original webpage address, the user information and the current time in a distributed database; When the information entropy is less than the preset information entropy threshold, the final short link is processed according to a preset information enhancement algorithm to obtain an optimized short link.

7. The method according to claim 6, characterized in that The calculating the information entropy of the final short link specifically includes: Counting the total number of characters in the final short link and the number of occurrences of each character; Divide the number of occurrences of each character by the total number of characters in the final short link to obtain the occurrence probability of each character; The occurrence probability of each character is input into a preset information entropy calculation formula to obtain the information entropy of the final short link. The preset information entropy calculation formula is: H=-∑[P(si)*log2(p(si))] Among them, H represents the information entropy, P(si) represents the occurrence probability of each character, and si represents each character.

8. A server, characterized in that: The server includes: one or more processors and a memory; the memory is coupled to the one or more processors, the memory is used to store computer program code, the computer program code includes computer instructions, and the one or more processors call the computer instructions to enable the server to execute the method described in any one of claims 1-7.

9. A computer-readable storage medium comprising instructions, characterized in that: When the instructions are executed on a server, the server is caused to execute the method according to any one of claims 1 to 7.

10. A computer program product, characterized in that When the computer program product is run on a server, the server is caused to execute the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Double random data confusion query method, device and system

    CN115544579A

  • Short link generation method and device, electronic equipment and storage medium

    CN116501997A

  • Short link generation method and device, equipment and storage medium

    CN117473176A

  • Method, device and system for intelligently switching safety system operation and medium

    CN118614106A

  • Method and system for HTTP session management using hash chains

    US20210176046A1