Short link generation method and device
By encrypting, splitting, looping bits and operations and character mapping of the original links, a high hashing short link is generated, which solves the problem of low security of short links in the existing technology, and achieves higher security and Recognition degree.
Patent Information
- Application Number
- CN202310980081.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-04
- Publication Date
- 2025-02-14
AI Technical Summary
The short links generated by the prior art have a low hashing degree and a high overlap rate, which is easy to be cracked, resulting in low security of short links.
By encrypting, splitting, looping bits and operations, character mapping and string splicing of the original link, short links with high hashing are generated to improve the security of short links.
The generated short link hashing degree and improves security, which reduces the probability of short links being cracked, and enhances recognition and retrieval efficiency.
Smart Images

Figure CN119442258A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method and device for generating a short link. Background Art
[0002] Network links often carry many parameters, which makes the network links very long. For example, when querying information, the parameters carried by the network link sent to the server include: business module, query conditions, user information, etc. In order to avoid the leakage of information such as parameters carried by the network link and improve the appearance of the network link, long network links are usually converted into short links. The current short link generation method mainly includes: data encryption, data interception, data conversion, data assembly and other steps, or using existing short link generation tools to convert long network links into short links.
[0003] In the process of implementing the present invention, the inventors found that the prior art has at least the following problems:
[0004] The short links generated by the prior art have a low hashing degree and a high overlap rate, and are easily cracked, resulting in low security of the short links. Summary of the invention
[0005] In view of this, an embodiment of the present invention provides a method and device for generating a short link, which can generate a short link with a high hash degree and improve the security of the short link.
[0006] To achieve the above object, according to a first aspect of an embodiment of the present invention, a method for generating a short link is provided, comprising:
[0007] In response to receiving the original link, encrypting the original link to obtain an encrypted string;
[0008] Splitting the encrypted string into multiple substrings, and performing base conversion on each substring to obtain multiple corresponding standard strings;
[0009] Performing a cyclic bitwise AND operation on each standard string according to a preset operand to obtain a corresponding plurality of bitwise AND data sets;
[0010] Perform character mapping on each bit and data set according to a preset character array to obtain corresponding multiple mapping strings;
[0011] The multiple mapping character strings are concatenated using a preset link identifier to obtain a short link corresponding to the original link.
[0012] Optionally, the original link is encrypted to obtain an encrypted string, including:
[0013] Preprocessing a preset random number, and concatenating the preprocessed random number and the original link to obtain a concatenated string;
[0014] The concatenated character string is encrypted using an information digest algorithm to obtain an encrypted character string.
[0015] Optionally, the preset random number is preprocessed, including:
[0016] Use a preset multiplier and addend to perform a product operation and a sum operation on the random number respectively;
[0017] According to the preset interception rules, data interception is performed on the random number after calculation.
[0018] Optionally, the preset operands include: a first operand and a second operand; performing a cyclic bitwise AND operation on each standard character string according to the preset operands to obtain corresponding multiple bitwise AND data sets includes:
[0019] Performing a bitwise AND operation on each standard character string according to the first operand to obtain a corresponding plurality of preprocessed data;
[0020] Performing a bitwise AND operation on each preprocessed data according to the second operand to obtain a plurality of corresponding first bit AND data;
[0021] Each preprocessed data is shifted multiple times according to the preset number of shifts and the shift amount. After each shift, a bitwise AND operation is performed on each shifted preprocessed data according to the second operand to obtain corresponding multiple second bitwise AND data. The first bitwise AND data and the second bitwise AND data corresponding to each standard character string are stored in the corresponding bitwise AND data set.
[0022] Optionally, character mapping is performed on each bit and the data set according to a preset character array to obtain a corresponding plurality of mapping strings, including:
[0023] Taking each bit and data in each bit and data set as an array subscript of the character array, and determining a mapping character corresponding to the array subscript in the character array;
[0024] The mapping characters corresponding to each bit and the data set are concatenated to obtain corresponding multiple mapping strings.
[0025] Optionally, after obtaining the short link corresponding to the original link, the method further includes:
[0026] Generate summary information corresponding to the original link;
[0027] The summary information, the original link, and the short link corresponding to the original link are stored in association, and the summary information is used as an index of the association storage.
[0028] Optionally, the summary information, the original link, and the short link corresponding to the original link are stored in a database; before encrypting the original link, the method further includes:
[0029] It is determined that the original link is not found in the database.
[0030] Optionally, the link identifier includes a fingerprint identifier; and the method further includes:
[0031] In response to receiving the access request, obtaining a corresponding target short link;
[0032] Determine whether the fingerprint identifier included in the target short link is valid;
[0033] If it is determined that the fingerprint identifier included in the target short link is valid, querying the corresponding target original link according to the target short link;
[0034] The access request is redirected according to the target original link.
[0035] Optionally, the method further comprises:
[0036] Performing data statistics on the access requests to obtain statistical results;
[0037] The statistical result, the target short link and the target original link are stored in association.
[0038] According to a second aspect of an embodiment of the present invention, a device for generating a short link is provided, including:
[0039] An encryption module, configured to encrypt the original link in response to receiving the original link to obtain an encrypted string;
[0040] A splitting module, used for splitting the encrypted string into multiple substrings, and performing base conversion on each substring to obtain corresponding multiple standard strings;
[0041] A bit AND module is used to perform a cyclic bit AND operation on each standard string according to a preset operand to obtain a corresponding plurality of bit AND data sets;
[0042] A mapping module, used for performing character mapping between each bit and the data set according to a preset character array to obtain a corresponding plurality of mapping strings;
[0043] The concatenation module is used to concatenate the multiple mapping character strings using a preset link identifier to obtain a short link corresponding to the original link.
[0044] Optionally, the original link is encrypted to obtain an encrypted string, including:
[0045] Preprocessing a preset random number, and concatenating the preprocessed random number and the original link to obtain a concatenated string;
[0046] The concatenated character string is encrypted using an information digest algorithm to obtain an encrypted character string.
[0047] Optionally, the preset random number is preprocessed, including:
[0048] Use a preset multiplier and addend to perform a product operation and a sum operation on the random number respectively;
[0049] According to the preset interception rules, data interception is performed on the random number after calculation.
[0050] Optionally, the preset operands include: a first operand and a second operand; performing a cyclic bitwise AND operation on each standard character string according to the preset operands to obtain corresponding multiple bitwise AND data sets includes:
[0051] Performing a bitwise AND operation on each standard character string according to the first operand to obtain a corresponding plurality of preprocessed data;
[0052] Performing a bitwise AND operation on each preprocessed data according to the second operand to obtain a plurality of corresponding first bit AND data;
[0053] Each preprocessed data is shifted multiple times according to the preset number of shifts and the shift amount. After each shift, a bitwise AND operation is performed on each shifted preprocessed data according to the second operand to obtain corresponding multiple second bitwise AND data. The first bitwise AND data and the second bitwise AND data corresponding to each standard character string are stored in the corresponding bitwise AND data set.
[0054] Optionally, character mapping is performed on each bit and the data set according to a preset character array to obtain a corresponding plurality of mapping strings, including:
[0055] Taking each bit and data in each bit and data set as an array subscript of the character array, and determining a mapping character corresponding to the array subscript in the character array;
[0056] The mapping characters corresponding to each bit and the data set are concatenated to obtain corresponding multiple mapping strings.
[0057] Optionally, the device further comprises:
[0058] A generating module, used for generating summary information corresponding to the original link;
[0059] The association module is used to associate and store the summary information, the original link and the short link corresponding to the original link, and use the summary information as an index of the associated storage.
[0060] Optionally, the summary information, the original link, and the short link corresponding to the original link are stored in a database; and the device further includes:
[0061] The first determination module is used to determine that the original link is not found in the database.
[0062] Optionally, the link identifier includes a fingerprint identifier; and the device further includes:
[0063] An acquisition module, configured to acquire a corresponding target short link in response to receiving an access request;
[0064] A second determination module is used to determine whether the fingerprint identifier included in the target short link is valid;
[0065] A query module, configured to query a corresponding target original link according to the target short link when it is determined that the fingerprint identifier included in the target short link is valid;
[0066] A redirection module is used to redirect the access request according to the target original link.
[0067] Optionally, the device further comprises:
[0068] A statistics module, used to perform data statistics on the access requests to obtain statistical results;
[0069] The storage module is used to associate and store the statistical results, the target short link and the target original link.
[0070] According to a third aspect of an embodiment of the present invention, there is provided an electronic device, including:
[0071] one or more processors;
[0072] a storage device for storing one or more programs,
[0073] When the one or more programs are executed by the one or more processors, the one or more processors implement the method described in any one of the above embodiments.
[0074] According to a fourth aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored, and when the program is executed by a processor, the method described in any one of the above embodiments is implemented.
[0075] One embodiment of the above invention has the following advantages or beneficial effects: encrypting, splitting, cyclic bitwise AND operation, character mapping and string concatenation of the original link can generate a short link with a high hash degree, thereby improving the security of the short link; concatenating and encrypting the preprocessed random number and the original link can improve the security of the encrypted string and reduce the probability of the encrypted string being cracked by brute force; performing product operation and sum operation and data interception on the random number can make the hash degree of the random number higher, which is convenient for improving the hash degree of the short link and avoiding a high overlap of the short link; performing multiple shifts on the preprocessed data and After each shift, the preprocessed data is subjected to a bitwise AND operation, which can evenly hash the preprocessed data and improve the recognition and retrieval efficiency of the short link; character mapping is performed on the bits and data sets according to the character array, which can improve the flexibility and efficiency of character mapping, facilitate the optimization of the mapping rules, and make the mapping process controllable; after receiving the access request, it is determined whether the fingerprint identifier included in the access request is valid, and the access request is redirected if the fingerprint identifier is valid, which can improve the security of accessing network resources through short links and prevent multiple access requests from violently acquiring the network resources indicated by the short link.
[0076] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with specific implementation examples. BRIEF DESCRIPTION OF THE DRAWINGS
[0077] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.
[0078] Figure 1 is a schematic diagram of the main process of the method for generating a short link according to an embodiment of the present invention;
[0079] Figure 2 It is a schematic diagram of the overall process of a method for generating a short link according to a reference embodiment of the present invention;
[0080] Figure 3 is a schematic diagram of using a short link to access a method for generating a short link according to a reference embodiment of the present invention;
[0081] Figure 4 It is a schematic diagram of the main process of a method for generating a short link according to a reference embodiment of the present invention;
[0082] Figure 5 is a schematic diagram of the main process of a method for generating a short link according to another reference embodiment of the present invention;
[0083] Figure 6 is a schematic diagram of the main process of a method for generating a short link according to yet another reference embodiment of the present invention;
[0084] Figure 7 is a schematic diagram of main modules of a device for generating a short link according to an embodiment of the present invention;
[0085] Figure 8 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;
[0086] Fig. 9 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION
[0087] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0088] It should be noted that in the technical solution of the present invention, the collection, use, storage, sharing and transfer of user personal information involved are in compliance with the provisions of relevant laws and regulations, and it is necessary to inform the user and obtain the user's consent or authorization. When applicable, the user's personal information is de-identified and / or anonymized and / or encrypted.
[0089] A network link includes information such as a domain name, port number, and interface method, and the network link often carries many parameters, which makes the network link very long. For example, when querying information, the parameters carried by the network link sent to the server include: business module, query conditions, query type, user information, etc. In order to avoid the leakage of information such as parameters carried by the network link, improve the appearance of the network link, and provide users with a better user experience, longer network links are usually converted into short links. The current short link generation method mainly includes: data encryption, data interception, data conversion, data assembly and other steps, or using existing short link generation tools to convert longer network links into short links.
[0090] The short links generated by the existing technology have a low hash degree and a high overlap rate, and are easily cracked, resulting in low security and low retrieval efficiency of the short links; short link generation tools often have shortcomings such as limited use times, difficulty in applying to various business scenarios, and unknown conversion principles.
[0091] In view of this, according to a first aspect of an embodiment of the present invention, a method for generating a short link is provided.
[0092] Figure 1 FIG. 1 is a schematic diagram of the main process of the method for generating a short link according to an embodiment of the present invention. Figure 1 As shown, the method for generating a short link according to an embodiment of the present invention mainly includes the following steps S101 to S105.
[0093] Step S101, in response to receiving the original link, encrypt the original link to obtain an encrypted string.
[0094] The original link is a complete network link, including: communication protocol, network domain name, port number, interface method, parameter information, etc. The original link is a network link that needs to be converted into a short link. After receiving the original link, the original link is encrypted as a whole according to a preset encryption algorithm. The encryption algorithms applicable to the embodiments of the present invention include: MD5, SHA1, SHA256, HMAC and other irreversible encryption algorithms, so that the encrypted string (i.e. the encrypted original link) is difficult to crack.
[0095] According to a reference embodiment of the present invention, the original link is split into multiple parts, for example, the original link is split into multiple parts of equal length, or the original link is split into multiple corresponding parts according to different components included in the original link, such as the communication protocol, network domain name, port number, etc.; then the multiple parts obtained by splitting are encrypted separately, and when the encryption is performed separately, the same encryption algorithm can be used, or different encryption algorithms can be used; according to the above steps, the multiple parts included in the original link are encrypted separately to obtain multiple partial encrypted strings, and the multiple partial encrypted strings are spliced to obtain the encrypted string corresponding to the original link. Exemplarily, the original link A is "https: / / aaaaa / a1 / a2:8080?a3=3&a4=4", which includes: communication protocol "https: / / ", network domain name "aaaaa", port number ":8080", interface method " / a1 / a2", parameter information "?a3=3&a4=4" and other parts. Each part is encrypted using the SHA1 encryption algorithm to obtain corresponding multiple partial encrypted strings, and then the multiple partial encrypted strings are spliced according to the arrangement order of the multiple parts in the original link to obtain an encrypted string.
[0096] According to another reference embodiment of the present invention, the original link is continuously encrypted, for example, after the original link is encrypted as a whole or after the multiple parts included in the original link are encrypted separately, the original link is encrypted as a whole again, thereby further improving the security of the encrypted string, and the encryption algorithm used in the second encryption can be the same as or different from the encryption algorithm used in the first encryption. Exemplarily, the original link is encrypted as a whole using SHA1 during the first encryption to obtain the initial encrypted string, and the initial encrypted string is encrypted as a whole using MD5 during the second encryption to obtain the encrypted string corresponding to the original link.
[0097] According to a reference embodiment of the present invention, a random number for original link encryption is pre-set, and the random number may be one or more, and the random number may be a positive number, a negative number, an integer, a decimal, etc. The random number is pre-processed, and the pre-processing includes: performing arithmetic operations such as addition, subtraction, multiplication, and division, exponentiation, square root operation, factorial operation, etc. on the random number, and the number of the above operations may be one or more times, or a plurality of operation modes may be combined, for example, after performing addition and subtraction operations on the random number, the result of the addition and subtraction operations is then subjected to exponentiation operation; in the case of pre-setting a plurality of random numbers, each random number is subjected to the same pre-processing or a different pre-processing, for example, the order of the plurality of operation steps included in the pre-processing B1 is adjusted, so as to obtain the pre-processing B2. Exemplarily, the pre-set random numbers are b3, b4 and b5; the preprocessing operation on the random number b3 includes: adding the random number b3 and the random number b5, and then multiplying the result of the addition by the random number b4; the preprocessing operation on the random number b4 includes: dividing the random number b4 and the random number b5, and then subtracting the result of the division from the random number b3; the preprocessing operation on the random number b5 includes: squaring the random number b5 and the random number b3, and then multiplying the squared result by the random number b4.
[0098] The preprocessed random number and the original link are spliced to obtain a spliced string, for example, the preprocessed random number is spliced to the beginning of the original link or the end of the original link; in the case of presetting multiple random numbers, the preprocessed multiple random numbers are spliced to multiple positions of the original link respectively, for example, different random numbers are spliced at the beginning of different components such as the communication protocol, network domain name, port number, etc. included in the original link or at the end of the above different components. Exemplarily, the preprocessed random numbers include: b6, b7, b8, b9, b10, the original link is "https: / / bbb / bb:8080?b=12", the above random number is spliced to the beginning of different components included in the original link, and the special symbol "#" is used at the splicing point to connect the random number and the components included in the original link, and the spliced string is "b6#https: / / #b7#bbb#b8# / bb#b9#:8080#b10#?b=12".
[0099] After obtaining the concatenated string, the concatenated string is encrypted using a message digest algorithm to obtain an encrypted string. The message digest algorithms applicable to the embodiments of the present invention include: MD5, MD4, SHA1, SHA256, CRC32, etc. Using random numbers and original links for concatenation can ensure that the encrypted string obtained will not be easily cracked by brute force, thereby improving the security of the encrypted string.
[0100] According to another reference embodiment of the present invention, a multiplier and an addend are preset, and the multiplier and the addend can be one or more respectively. The random number is multiplied by the preset multiplier, and the random number is summed by the preset addend; for example, the random number is continuously multiplied, and then the continuous product results are continuously summed; or, the product operation and the summation operation are performed alternately, for example, the random number is first multiplied, and then the product result is summed. After the product operation and the summation operation are performed, the random number after the operation is intercepted according to the preset interception rules, and the interception rules include: the starting interception position and the interception length, the starting interception position is the position corresponding to a certain number in the random number, the starting interception position indicates the position to start interception, and the interception length indicates how many numbers need to be intercepted, that is, the length of the preprocessed random number. Multiple numbers are intercepted backward from the starting interception position to obtain the preprocessed random number.
[0101] Exemplarily, the preset calculation formula is "(random*c1+c2)*c3", where "random" is the random number "0.135246", the preset multipliers of "c1" and "c3" are 9 and 100000, and the preset addend of "c2" is 1; the calculation result of the random number calculated using the above calculation formula is "221721.4"; the preset starting truncation position is "the position corresponding to the first digit from the left of the calculation result", and the truncation length is 5, then the preprocessed random number is "22172".
[0102] Performing product operations and sum operations on random numbers and then intercepting the random numbers can make the pre-processed random numbers more hashed and more random, making it easier to subsequently generate short links with good hashing degrees.
[0103] Step S102, splitting the encrypted string into multiple substrings, performing base conversion on each substring to obtain multiple corresponding standard strings.
[0104] The lengths of multiple substrings can be the same or different. For example, a minimum length of a substring is preset, and then the encrypted string is randomly split so that the lengths of the multiple substrings obtained by splitting are greater than or equal to the minimum length. Alternatively, a uniform length of a substring is preset, and then the encrypted string is split into equal lengths, so that the lengths of the multiple substrings obtained by splitting are equal, that is, equal to the preset uniform length. A preset base standard is used to convert each substring into a base, and base standards include: binary, octal, hexadecimal, etc. Multiple substrings are converted into the same base, and multiple substrings with the same base are used as standard strings.
[0105] Exemplarily, the encrypted string is "r6v56o5niq97pjw4g2f1", the length of the encrypted string is 20, and the encrypted string is split into 4 substrings of length 5 in character arrangement order, including: "r6v56", "o5niq", "97pjw", "4g2f1"; since the preset base standard is hexadecimal, the above substrings are converted into standard hexadecimal strings respectively, and "0x7236763536", "0x6f356e6971", "0x3937706a77", and "0x3467326631" are obtained.
[0106] Splitting the encrypted string is helpful to improve the hashing degree of the short link, reduce the overlap of the short link, and improve the recognition of the short link.
[0107] Step S103, performing a cyclic bitwise AND operation on each standard character string according to a preset operand to obtain a corresponding plurality of bitwise AND data sets.
[0108] After obtaining multiple standard strings, a preset operand is obtained. The operand and the standard string conform to the same base standard. For example, if the standard string is in hexadecimal, the operand is also in hexadecimal. If the standard string is in octal, the operand is also in octal. The operand is data used to perform a bitwise AND operation on each standard string.
[0109] When the length of the operand is equal to the standard string, the operand and the standard string are used to perform multiple bitwise AND operations, wherein after each bitwise AND operation, the standard string is shifted to the left by a certain distance or to the right by a certain distance until there is no intersection between the standard string and the operand after the shift. The displacement distance is preset and the displacement distance is the same each time. For the empty position obtained after each displacement, a preset number is used to fill it, for example, 0 or 1.
[0110] For example, the operand is "0x0000003d", the standard string D1 is "0x1796e653", and the preset displacement distance is 4. The first bitwise AND operation is "0x0000003d&0x1796e653", and the bitwise AND result is "0000002C". The result is converted to decimal to get "17", and "17" is added to the bitwise AND data set corresponding to the standard string D1; then the standard string D1 is shifted left by 4 bits, and the empty position is filled with 0, and the standard string after displacement is "0x00001 796", the second bitwise AND operation is "0x0000003d&0x00001796", and the bitwise AND result is "0014". The result is converted into decimal to get "20", and "20" is added to the bitwise AND data set corresponding to the standard string D1; since the standard string D1 is shifted left again, there will be no intersection between the standard string D1 and the operand in position, the cyclic bitwise AND operation on the standard string D1 is stopped, so that the bitwise AND data set corresponding to the standard string D1 includes the two numbers "17" and "20". The same cyclic bitwise AND operation is performed on other standard strings to obtain the bitwise AND data set corresponding to each standard string.
[0111] When the length of the operand is less than the standard string or the length of the operand is greater than the standard string, the operand is left-aligned or right-aligned with the standard string, and multiple bitwise AND operations are performed on the operand and the standard string, wherein after each bitwise AND operation, the smaller one is shifted a certain distance to the left (in the case of right alignment) or a certain distance to the right (in the case of left alignment) until there is no intersection between the standard string and the operand in position, the displacement distance is preset, and the displacement distance is the same each time, and the vacant position obtained after each displacement is filled with a preset number, for example, 0 or 1.
[0112] For example, the operand is "0x00002a", the standard string D2 is "0x7326", the operand and the standard string are left-aligned, and the remaining empty positions are filled with 0. The preset displacement distance is 2, then the first bitwise AND operation is "0x00002a&0x732600", and the bitwise AND result is "000000", and the decimal result is "0". "0" is added to the bitwise AND data set corresponding to the standard string D2. Since the operand and the standard string are left-aligned, the standard string (the smaller one) is shifted to the right by 2, and the second bitwise AND operation is "0x00002a&0x732600". a&0x007326", and the bitwise AND result is "000022", and the decimal result is "34". Add "34" to the bitwise AND data set corresponding to the standard string D2, and then shift the standard string (the smaller one) to the right by 2. The third bitwise AND operation is "0x00002a&0x000073", and the bitwise AND result is "000022", and the decimal result is "34". Add "34" to the bitwise AND data set corresponding to the standard string D2; perform the same cyclic bitwise AND operation on other standard strings to obtain the bitwise AND data set corresponding to each standard string.
[0113] By cyclically performing bitwise AND operations, the bitwise AND data set corresponding to each standard string is obtained, which can improve the recognition of short links and reduce the probability of generating the same short link.
[0114] According to a reference embodiment of the present invention, the preset operands include: a first operand and a second operand. First, a bitwise AND operation is performed on each standard string according to the first operand to obtain a corresponding plurality of preprocessed data. This step ensures that the lengths of the plurality of preprocessed data are the same. When the lengths of the preprocessed data are different, the lengths of the plurality of preprocessed data are made the same by adding 0 to the left end of the preprocessed data. The second operand is the same length as the plurality of preprocessed data. A bitwise AND operation is performed on each preprocessed data according to the second operand to obtain a corresponding plurality of first bitwise AND data. The first bitwise AND data is the bitwise AND result obtained by the first bitwise AND operation of the second operand with the preprocessed data. Multiple shifts are performed on each preprocessed data according to the preset number of shifts and the amount of shift. Since the second operand has the same length as the preprocessed data, the shift direction can be left shift or right shift. After each shift, a bitwise AND operation is performed on each preprocessed data after the shift according to the second operand to obtain a corresponding plurality of second bitwise AND data. The second bitwise AND data is the bitwise AND result of the second operand and the preprocessed data during the shift. Each shift operation corresponds to a second bitwise AND data. The first and second digits and data corresponding to each standard character string are converted into decimal, and the converted digits and data are stored in the digit and data set corresponding to each standard character string.
[0115] Exemplarily, there are three standard character strings, namely, standard character string E1 "0xd3fe2", standard character string E2 "0xcd724", and standard character string E3 "0xafe57"; the preset first operand is "0x3fffffff", the second operand is "0x0000005d", the standard character string E1 is bitwise ANDed with the first operand to obtain preprocessed data E4 "0x000d3fe2", the standard character string E2 is bitwise ANDed with the first operand to obtain preprocessed data E5 "0x000cd724", and the standard character string E3 is bitwise ANDed with the first operand to obtain preprocessed data E6 "0x000afe57". The preprocessed data E4 is bitwise ANDed with the second operation data to obtain the first bit data "00000040", which is converted into decimal data "64", and "64" is stored in the bitwise AND data set corresponding to the standard string E1; the preprocessed data E5 is bitwise ANDed with the second operation data to obtain the first bit data "00000004", which is converted into decimal data "4", and "4" is stored in the bitwise AND data set corresponding to the standard string E2; the preprocessed data E6 is bitwise ANDed with the second operation data to obtain the first bit data "00000055", which is converted into decimal data "85", and "85" is stored in the bitwise AND data set corresponding to the standard string E3. Then, according to the preset displacement times of 3 times, displacement amount of 4 each time, and displacement direction of left shift, the preprocessed data E4 is shifted multiple times. After each displacement, the preprocessed data E4 and the second operand are bitwise ANDed to obtain three second bitwise ANDed data, which are "005C", "001D", and "51", respectively. They are converted into decimal system "92", "29", and "81", respectively. "92", "29", and "81" are stored in the bitwise ANDed data set corresponding to the standard string E1. The processing process of the preprocessed data E5 and the preprocessed data E6 is the same as that of the preprocessed data E4. After converting the obtained multiple second bitwise ANDed data into decimal system, they are stored in the bitwise ANDed data sets corresponding to the standard string E1 and the standard string E2 respectively. The bitwise ANDed operation is first performed with the first operand to make the length of the obtained preprocessed data the same, which is convenient for the subsequent multiple displacements and bitwise ANDed operations, and can improve the efficiency of the bitwise ANDed operation, improve the recognition of short links, and reduce the probability of generating the same short links.
[0116] Step S104, character mapping is performed on each bit and the data set according to a preset character array to obtain a plurality of corresponding mapping character strings.
[0117] The character array includes a plurality of non-repeating characters, for example, the characters in the character array include "a" to "z", "A" to "Z", "0" to "9", etc. There is a mapping relationship between the characters and bits included in the character array and the data included in the data set, for example, each character included in the character data corresponds to a data segment, each data included in the data set is traversed, the data segment where each data is located is determined, and the character corresponding to each data is determined according to the determined data segment. Exemplarily, the character data includes 6 characters such as "{'f','F','g','G','h','H'}", among which the data segment corresponding to "f" is "0-10", the data segment corresponding to "F" is "11-20", the data segment corresponding to "g" is "21-30", the data segment corresponding to "G" is "31-40", the data segment corresponding to "h" is "41-50", and the data segment corresponding to "H" is "51-60", and the data included in the bit and data set is "{'15','26','37'}". According to the correspondence between the above data segments and characters, the mapping character corresponding to "15" is "F", the mapping character corresponding to "26" is "g", and the mapping character corresponding to "37" is "G", so that the mapping string corresponding to the bit and data set is "FgG", and according to the above mapping rules, the mapping string corresponding to each bit and data set is obtained.
[0118] For another example, each character corresponds to one or more digital combinations, and each digital combination indicates what the highest and lowest bits of the data corresponding to the character are respectively; traverse each data set included in the data set, determine whether each data conforms to a certain digital combination, and determine the character corresponding to each data based on the determined data segment. Exemplarily, the character data includes 6 characters such as "{'i','j','k'}", among which the number combination corresponding to "i" is "1...1", that is, the highest digit is 1 and the lowest digit is also 1, the number combination corresponding to "j" is "1...2", that is, the highest digit is 1 and the lowest digit is also 2, and the number combination corresponding to "k" is "1...3", that is, the highest digit is 1 and the lowest digit is also 3; the data included in the bit and data set is "{'11','122','1243'}", and according to the above mapping rules, the mapping character corresponding to "11" is "i", the mapping character corresponding to "122" is "j", and the mapping character corresponding to "1243" is "k", so that the mapping string corresponding to the bit and data set is "ijk"; according to the above mapping rules, the mapping string corresponding to each bit and data set is obtained.
[0119] Mapping each data included in the bit and data set to a character in the character array can improve the hashing degree of the mapped string and improve the flexibility of character mapping.
[0120] According to a reference embodiment of the present invention, each bit and each data in each bit and data set is used as an array subscript of a character array, the mapping character corresponding to the array subscript is determined in the character array, and the mapping characters corresponding to each data in the bit and data set are concatenated to obtain corresponding multiple mapping strings. For example, the character array is "{'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V',' W', 'X', 'Y', 'Z'}", the data in the bit and data set include "{'12', '34', '6', '9', '25', '17'}", use the data in the bit and data set as the array subscript, determine that the character corresponding to the array subscript "12" is "m", the character corresponding to the array subscript "34" is "8", the character corresponding to the array subscript "6" is "g", the character corresponding to the array subscript "9" is "j", the character corresponding to the array subscript "25" is "z", and the character corresponding to the array subscript "17" is "r", and concatenate the obtained mapping characters to obtain the response mapping string "m8gjzr". According to the above mapping rules, obtain the mapping string corresponding to each bit and data set.
[0121] When the data included in the bit and data set exceeds the maximum array subscript corresponding to the character array, the character data is repeatedly concatenated so that the length of the concatenated character array is greater than the data included in the bit and data set. For example, the character array is "{'q','w','e'}" with a length of 3, and the data included in the bit and data set is "4", then the character array is repeatedly concatenated to obtain "{'q','w','e','q','w','e'}", thereby determining that the character corresponding to "4" is "w". It should be noted that in this embodiment, the array subscript starts at 0.
[0122] Using the data in the bit and data set as the data subscript to determine the corresponding character in the character array can improve the efficiency of character mapping and further improve the hashing degree of the obtained mapping string.
[0123] Step S105: Use a preset link identifier to concatenate the multiple mapping character strings to obtain a short link corresponding to the original link.
[0124] The mapping string is converted from the standard string. After obtaining multiple mapping strings, the mapping strings are spliced according to the arrangement order of the corresponding standard strings, or the multiple mapping strings are spliced according to a pre-set splicing order, or the mapping strings are spliced according to a random splicing order. In the case of pre-set splicing characters, the multiple mapping characters are spliced using the splicing characters, and the splicing characters are characters outside the character array, for example, the splicing characters include special characters such as "#", "%, "&", "*", etc.
[0125] The parameter part of the short link is obtained by concatenating multiple mapping strings. The link identifier includes: the interface method, communication protocol, domain name and other information of the short link. The link identifier can also be encrypted. The link identifier is concatenated with the concatenated mapping string to obtain the short link corresponding to the original link. Short link generation requests from different business modules correspond to different link identifiers. For example, if the original link belongs to business module P1, the corresponding link identifier is "p1", and if the original link belongs to business module P2, the corresponding link identifier is "p2".
[0126] Exemplarily, multiple mapping strings include: "dhfaus", "ywtho", "vjkdf", and the multiple mapping strings are spliced in the above order without using splicing characters to obtain "dhfausywthovjkdf", and the pre-set link identifier "m.cn / kurl?k=" is obtained. The link identifier and the spliced mapping string are spliced to obtain a short link "m.cn / kurl?k=dhfausywthovjkdf", and "m.cn / kurl?k=dhfausywthovjkdf" is used as the short link corresponding to the original link.
[0127] According to a reference embodiment of the present invention, after obtaining the short link corresponding to the original link, the summary information corresponding to the original link is generated. The summary information is an encrypted string obtained by symmetric encryption or asymmetric encryption. The summary information, the original link, and the short link corresponding to the original link are stored in association, and the summary information is used as an index of the associated storage, so that the corresponding original link and the short link corresponding to the original link can be quickly determined according to the summary information. Exemplarily, the original link M1 is encrypted using the symmetric encryption algorithm AES to obtain summary information M2, and the summary information M2, the original link M1, and the short link corresponding to the original link M1 are stored in Redis, and the summary information M2 is used as the key, and the original link M1 and the short link corresponding to the original link M1 are used as the value.
[0128] Summary information is generated and stored in association with the original link and the short link corresponding to the original link, so that it is possible to quickly query whether the original link and the short link corresponding to the original link are stored.
[0129] According to another reference embodiment of the present invention, summary information, original link and short link corresponding to the original link are stored in a database, and the summary information is the index of the database table. Before receiving the original link and encrypting the original link, first determine whether the corresponding original link is stored in the database. For example, first symmetrically encrypt or asymmetrically encrypt the original link to obtain the summary information corresponding to the original link, and then search the database for the corresponding original link according to the summary information. If the original link is stored in the database, it means that the short link corresponding to the original link has been generated before, and the short link corresponding to the original link is directly obtained from the data; if the original link is not stored in the database, it means that the short link corresponding to the original link has not been generated before, and it is necessary to encrypt, split, bitwise AND operation, character map and other steps according to the aforementioned steps to generate the short link corresponding to the original link, and then store the original link and the corresponding short link in the database.
[0130] Exemplarily, after receiving the original link N1, the summary information N2 corresponding to the original link is generated according to the symmetric encryption algorithm DES, and the data record with the summary information N2 as the summary information is searched in the database to obtain the data record "{'digest':'N2'; 'originalLink':'N1'; 'shortLink':'N3'}", wherein "'digest':'N2'" indicates that the summary information is "N2", "'originalLink':'N1'" indicates that the original link is "N1", and "'shortLink':'N3'" indicates that the short link is "N3". It is determined that the short link corresponding to the original link, that is, the short link N3, has been generated before; there is no need to generate a short link for the original link N2, and the short link N3 can be directly returned.
[0131] Before generating a short link, first generate summary information based on the original link, and then query the original link stored in the database based on the summary information, so as to quickly determine whether the short link corresponding to the original link has been generated, avoid generating short links corresponding to the original link multiple times, and save system resources.
[0132] According to another reference embodiment of the present invention, the link identifier includes a fingerprint identifier, which is an encrypted string obtained by symmetric encryption or asymmetric encryption; for example, the short link and the random hash code machine are spliced; the splicing result is encrypted by symmetric encryption to generate a fingerprint identifier. The fingerprint identifier is added to the end of the short link as a parameter of the short link. When an access request is received, the corresponding target short link is obtained; it is determined whether the target short link includes the fingerprint identifier, and if the fingerprint identifier is included, it is determined whether the fingerprint identifier is valid; specifically, the corresponding real fingerprint identifier is generated according to the target short link, and the fingerprint identifier carried by the target short link is compared with the real fingerprint identifier. If the fingerprint identifier carried by the target short link is the same as the real fingerprint identifier, the fingerprint identifier carried by the target short link is determined to be valid. If it is determined that the fingerprint identifier included in the target short link is valid, the corresponding target original link is queried according to the target short link; and the access request is redirected according to the target original link.
[0133] Exemplarily, the method "hashCode()" is used to generate a random hash code, the obtained random hash code is concatenated to the end of the short link, and then the symmetric encryption algorithm 3DES is used to generate a corresponding fingerprint identifier, the fingerprint identifier is added as a parameter to the end of the short link, and the short link is returned to the user, allowing the user to initiate an access request based on the short link, and the execution subject of the embodiment of the present invention stores the generated random hash code, so that when an access request is received, a fingerprint identifier corresponding to the short link is generated according to the stored random hash code, and then it is determined whether the fingerprint identifier carried by the short link is valid.
[0134] After receiving an access request, it is determined whether the fingerprint identifier included in the access request is valid. If the fingerprint identifier is valid, the access request is redirected. This can improve the security of accessing network resources through short links and prevent multiple access requests from brute-force acquisition of network resources indicated by short links.
[0135] According to another reference embodiment of the present invention, data statistics are performed on access requests to obtain statistical results, which include: the number of clicks on the short link within a preset time, the click frequency of the short link within a preset time, the cumulative number of valid and / or invalid fingerprint identifiers carried by the short link, etc.; the statistical results, the target short link, and the target original link are associated and stored, so that R&D personnel can query the statistical results and generate corresponding statistical information charts (line charts, bar charts, pie charts, etc.), so that R&D personnel can troubleshoot and optimize the performance of the short link generation method and related steps. For example, if multiple access requests initiated by a certain network address are received, and the fingerprint information carried by the multiple access requests is invalid, it is determined that the network address is at risk, and a prompt message is sent to the R&D personnel, asking the R&D personnel to make a manual judgment; after the R&D personnel determine that the network address is definitely at risk, a shielding request sent by the R&D personnel is received, and the access request sent by the network address is shielded.
[0136] Figure 2 FIG. 1 is a schematic diagram of the overall process of a method for generating a short link according to a reference embodiment of the present invention. Figure 2As shown, the method for generating a short link includes: an original link sending module, a summary information generating module, an information association storage module, a short link generating module and the like. The original link sending module includes the original links of multiple business modules, and the original link sending module sends the original links of each business module to the summary information generating module. The summary information generating module includes a variety of encryption algorithms, such as MD5 encryption algorithm, SHA encryption algorithm, etc. The summary information generating module encrypts the received original link, generates summary information corresponding to the original link, and then sends the generated summary information to the information association storage module to query whether the original link is stored. The information association storage module stores multiple groups of association information, each group of association information includes: summary information, original link and short link corresponding to the original link. The information association storage module queries whether there is a corresponding original link according to the received summary information; if the information association storage module stores the corresponding original link, the corresponding association information "summary information-original link-short link corresponding to the original link" is returned to the summary information generating module; if the information association storage module does not store the corresponding original link, the query result of "no association information found" is returned to the summary information generating module. After the summary information generation module receives the associated information returned by the information association storage module, the short link corresponding to the original link included in the associated information is returned to the original link sending module, thereby completing the short link request process; after the summary information generation module receives the query result indicating that "no associated information was found" returned by the information association storage module, the summary information generation module sends the original link and the summary information of the original link to the short link generation module. The short link generation module performs multiple steps such as encryption, splitting, bitwise AND operation, mapping, and splicing on the received original link, thereby generating a short link corresponding to the original link; then the short link generation module sends the original link, the short link corresponding to the original link, and the summary information corresponding to the original link to the information association storage module for associated storage, so as to directly obtain the corresponding short link from the information association storage module when requesting to generate a short link next time; then the short link generation module returns the short link corresponding to the original link to the original link sending module, thereby completing the short link request process.
[0137] Figure 3 FIG. 1 is a schematic diagram of a method for generating a short link using a short link access according to a reference embodiment of the present invention. Figure 3As shown, the process of using short link access involves: front-end page, fingerprint identification verification module, information association storage module, link redirection module, business processing module and other modules. First, the user initiates an access request based on the target short link on the front-end page, and the front-end page sends the target short link to the fingerprint identification verification module. The fingerprint identification verification module parses the target short link to obtain the corresponding target fingerprint identification, and determines whether it is the same as the original fingerprint identification stored in advance. If the target fingerprint identification is the same as the original fingerprint identification, it is determined that the fingerprint identification verification is passed, and the short link is sent to the information association storage module to query the original link corresponding to the short link; if the target fingerprint identification is different from the original fingerprint identification, it is determined that the fingerprint identification verification is not passed, and the prompt message of "access request abnormality" is returned to the front-end page. The information association storage module queries the corresponding original link according to the received target short link, and sends the queried original link to the link redirection module. The link redirection module redirects the access request according to the received original link, and sends the access request to the business processing method corresponding to the original link in the business processing module. The business processing module performs corresponding business processing operations according to the received original link, for example, obtaining network resources (pictures, videos, documents, etc.), and then returns the obtained network resources to the front-end page, thereby completing the processing of the access request.
[0138] Figure 4 FIG. 1 is a schematic diagram of the main process of a method for generating a short link according to a reference embodiment of the present invention. Figure 4 As shown, the method for generating a short link may include:
[0139] Step S401, pre-processing the preset random number;
[0140] Step S402, in response to receiving the original link, concatenate the preprocessed random number and the original link to obtain a concatenated string;
[0141] Step S403, encrypting the concatenated string using a message digest algorithm to obtain an encrypted string;
[0142] Step S404, splitting the encrypted string into multiple substrings, performing base conversion on each substring to obtain multiple corresponding standard strings;
[0143] Step S405, performing a bitwise AND operation on each standard character string according to the first operand to obtain a corresponding plurality of pre-processed data;
[0144] Step S406, performing a bitwise AND operation on each preprocessed data according to the second operand to obtain a plurality of corresponding first bit AND data;
[0145] Step S407, performing multiple shifts on each preprocessed data according to a preset number of shifts and a shift amount, and after each shift, performing a bitwise AND operation on each shifted preprocessed data according to a second operand to obtain a corresponding plurality of second bitwise AND data;
[0146] Step S408, storing the first and second bit and data corresponding to each standard character string into the corresponding bit and data set;
[0147] Step S409, character mapping is performed on each bit and the data set according to a preset character array to obtain a plurality of corresponding mapping strings;
[0148] Step S410: Use a preset link identifier to concatenate multiple mapping character strings to obtain a short link corresponding to the original link.
[0149] The specific implementation content of the method for generating a short link according to a reference embodiment of the present invention has been described in detail in the method for generating a short link described above, so the repeated content will not be described here.
[0150] Figure 5 FIG. 1 is a schematic diagram of the main process of a method for generating a short link according to another reference embodiment of the present invention. Figure 5 As shown, the method for generating a short link may include:
[0151] Step S501, using a preset multiplier and addend to perform a product operation and a sum operation on a preset random number respectively;
[0152] Step S502, data interception is performed on the calculated random number according to a preset interception rule;
[0153] Step S503, in response to receiving the original link, generating summary information corresponding to the original link, and searching the database for the original link according to the summary information;
[0154] Step S504, determine whether the original link is found, if yes, jump to step S505, otherwise, jump to step S506;
[0155] Step S505, obtaining a short link corresponding to the original link in the database, and returning the short link to the sender of the original link;
[0156] Step S506, concatenating the intercepted random number and the original link to obtain a concatenated string;
[0157] Step S507, encrypting the concatenated string using a message digest algorithm to obtain an encrypted string;
[0158] Step S508, splitting the encrypted string into multiple substrings, performing base conversion on each substring to obtain multiple corresponding standard strings;
[0159] Step S509, performing a bitwise AND operation on each standard character string according to the first operand to obtain a corresponding plurality of pre-processed data;
[0160] Step S510, performing a bitwise AND operation on each preprocessed data according to the second operand to obtain a plurality of corresponding first bit AND data;
[0161] Step S511, performing multiple shifts on each preprocessed data according to a preset number of shifts and a shift amount, and after each shift, performing a bitwise AND operation on each shifted preprocessed data according to a second operand to obtain a corresponding plurality of second bitwise AND data;
[0162] Step S512, storing the first and second bit and data corresponding to each standard character string into the corresponding bit and data set;
[0163] Step S513, taking each bit and data in each bit and data set as an array subscript of a character array, and determining a mapping character corresponding to the array subscript in the character array;
[0164] Step S514, concatenating the mapping characters corresponding to each bit and the data set to obtain a plurality of corresponding mapping character strings;
[0165] Step S515, concatenating multiple mapping strings using a preset link identifier to obtain a short link corresponding to the original link;
[0166] Step S516, generating summary information corresponding to the original link;
[0167] Step S517: associate and store the summary information, the original link, and the short link corresponding to the original link, and use the summary information as an index for the associated storage.
[0168] The specific implementation content of the method for generating a short link according to another reference embodiment of the present invention has been described in detail in the method for generating a short link described above, so the repeated content will not be described here.
[0169] Figure 6 FIG. 1 is a schematic diagram of the main process of a method for generating a short link according to another reference embodiment of the present invention. Figure 6 As shown, the method for generating a short link may include:
[0170] Step S601, in response to receiving an access request, obtaining a corresponding target short link;
[0171] Step S602, parsing the target short link to obtain the fingerprint identifier included in the target short link;
[0172] Step S603, determine whether the fingerprint identification is valid, if so, jump to step S605, otherwise, jump to step S604;
[0173] Step S604, sending a prompt message to the initiator of the access request, prompting that the access request does not meet the requirements;
[0174] Step S605, querying the corresponding target original link according to the target short link;
[0175] Step S606, redirecting the access request according to the target original link;
[0176] Step S607, performing data statistics on the access requests to obtain statistical results;
[0177] Step S608: associate and store the statistical results, the target short link, and the target original link.
[0178] The specific implementation content of the method for generating a short link in another reference embodiment of the present invention has been described in detail in the method for generating a short link described above, so the repeated content will not be described here.
[0179] According to a second aspect of an embodiment of the present invention, a device for generating a short link is provided.
[0180] Figure 7 is a schematic diagram of main modules of a device for generating a short link according to an embodiment of the present invention, such as Figure 7 As shown, the device 700 for generating a short link mainly includes:
[0181] The encryption module 701 is used for encrypting the original link in response to receiving the original link to obtain an encrypted string;
[0182] A splitting module 702 is used to split the encrypted string into multiple substrings, and perform base conversion on each substring to obtain corresponding multiple standard strings;
[0183] The bitwise AND module 703 is used to perform a cyclic bitwise AND operation on each standard character string according to a preset operand to obtain a corresponding plurality of bitwise AND data sets;
[0184] A mapping module 704 is used to perform character mapping on each bit and the data set according to a preset character array to obtain a corresponding plurality of mapping strings;
[0185] The concatenation module 705 is used to concatenate the multiple mapping character strings using a preset link identifier to obtain a short link corresponding to the original link.
[0186] According to a reference embodiment of the present invention, the original link is encrypted to obtain an encrypted string, including:
[0187] Preprocessing a preset random number, and concatenating the preprocessed random number and the original link to obtain a concatenated string;
[0188] The concatenated character string is encrypted using an information digest algorithm to obtain an encrypted character string.
[0189] According to another reference embodiment of the present invention, preprocessing the preset random number includes:
[0190] Use a preset multiplier and addend to perform a product operation and a sum operation on the random number respectively;
[0191] According to the preset interception rules, data interception is performed on the random number after calculation.
[0192] According to another reference embodiment of the present invention, the preset operands include: a first operand and a second operand; a cyclic bitwise AND operation is performed on each standard string according to the preset operands to obtain corresponding multiple bitwise AND data sets, including:
[0193] Performing a bitwise AND operation on each standard character string according to the first operand to obtain a corresponding plurality of preprocessed data;
[0194] Performing a bitwise AND operation on each preprocessed data according to the second operand to obtain a plurality of corresponding first bit AND data;
[0195] Each preprocessed data is shifted multiple times according to the preset number of shifts and the shift amount. After each shift, a bitwise AND operation is performed on each shifted preprocessed data according to the second operand to obtain corresponding multiple second bitwise AND data. The first bitwise AND data and the second bitwise AND data corresponding to each standard character string are stored in the corresponding bitwise AND data set.
[0196] According to another reference embodiment of the present invention, character mapping is performed on each bit and data set according to a preset character array to obtain a corresponding plurality of mapping strings, including:
[0197] Taking each bit and data in each bit and data set as an array subscript of the character array, and determining a mapping character corresponding to the array subscript in the character array;
[0198] The mapping characters corresponding to each bit and the data set are concatenated to obtain corresponding multiple mapping strings.
[0199] According to another reference embodiment of the present invention, the device 700 for generating a short link further includes:
[0200] A generating module, used for generating summary information corresponding to the original link;
[0201] The association module is used to associate and store the summary information, the original link and the short link corresponding to the original link, and use the summary information as an index of the associated storage.
[0202] According to a reference embodiment of the present invention, the summary information, the original link and the short link corresponding to the original link are stored in a database; the short link generating device 700 further includes:
[0203] The first determination module is used to determine that the original link is not found in the database.
[0204] According to another reference embodiment of the present invention, the link identifier includes a fingerprint identifier; the short link generation device 700 further includes:
[0205] An acquisition module, configured to acquire a corresponding target short link in response to receiving an access request;
[0206] A second determination module is used to determine whether the fingerprint identifier included in the target short link is valid;
[0207] A query module, configured to query a corresponding target original link according to the target short link when it is determined that the fingerprint identifier included in the target short link is valid;
[0208] A redirection module is used to redirect the access request according to the target original link.
[0209] According to another reference embodiment of the present invention, the device 700 for generating a short link further includes:
[0210] A statistics module, used to perform data statistics on the access requests to obtain statistical results;
[0211] The storage module is used to associate and store the statistical results, the target short link and the target original link.
[0212] It should be noted that the specific implementation content of the device for generating a short link in the embodiment of the present invention has been described in detail in the method for generating a short link described above, so the repeated content will not be described again here.
[0213] According to the technical solution of the embodiment of the present invention, the original link is encrypted, split, cyclically bitwise ANDed, character mapped and string concatenated, so that a short link with a high hashing degree can be generated, thereby improving the security of the short link; the preprocessed random number and the original link are concatenated and encrypted, so that the security of the encrypted string can be improved and the probability of the encrypted string being cracked by brute force can be reduced; the random number is multiplied and summed, and the data is intercepted, so that the hashing degree of the random number can be higher, which is convenient for improving the hashing degree of the short link and avoiding a high overlap of the short link; the preprocessed data is shifted multiple times and the preprocessed data is bitwise ANDed after each shift, so that the preprocessed data can be evenly hashed, thereby improving the recognition and retrieval efficiency of the short link; the character mapping of the bit and the data set according to the character array can improve the flexibility and mapping efficiency of the character mapping, facilitate the optimization of the mapping rules, and make the mapping process controllable; after receiving the access request, it is judged whether the fingerprint identifier corresponding to the access request is valid, and the access request is redirected when the fingerprint identifier is valid, so as to improve the security of accessing network resources through the short link and prevent multiple access requests from violently acquiring the network resources indicated by the short link.
[0214] According to a third aspect of an embodiment of the present invention, there is provided an electronic device, comprising: one or more processors; a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the method provided by the first aspect of the embodiment of the present invention.
[0215] According to a fourth aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored, and when the program is executed by a processor, the method provided by the first aspect of the embodiment of the present invention is implemented.
[0216] Figure 8 An exemplary system architecture 800 is shown to which the method or apparatus for generating a short link according to an embodiment of the present invention may be applied.
[0217] like Figure 8 As shown, system architecture 800 may include terminal devices 801, 802, 803, a network 804, and a server 805. Network 804 is used to provide a medium for communication links between terminal devices 801, 802, 803 and server 805. Network 804 may include various connection types, such as wired, wireless communication links, or optical fiber cables, etc.
[0218] The user can use the terminal devices 801, 802, 803 to interact with the server 805 through the network 804 to receive or send messages, etc. Various communication client applications can be installed on the terminal devices 801, 802, 803, such as short link generation applications, short link duplicate checking applications, search applications, instant messaging tools, email clients, social platform software, etc. (only as examples).
[0219] The terminal devices 801 , 802 , and 803 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.
[0220] Server 805 can be a server that provides various services, such as a background management server that provides support for the request for short link generation sent by the upstream terminal devices 801, 802, and 803 (for example only). In response to receiving the original link, the background management server can encrypt the original link to obtain an encrypted string; split the encrypted string into multiple substrings, and perform base conversion on each substring to obtain multiple corresponding standard strings; perform cyclic bitwise AND operations on each standard string according to preset operands to obtain multiple corresponding bitwise and data sets; perform character mapping on each bitwise and data set according to a preset character array to obtain multiple corresponding mapping strings; use a preset link identifier to splice the multiple mapping strings to obtain a short link corresponding to the original link; and feedback the short link generation situation (for example only) to the terminal device.
[0221] It should be noted that the method for generating a short link provided in the embodiment of the present invention is generally executed by the server 805, and accordingly, the device for generating a short link is generally set in the server 805. The method for generating a short link provided in the embodiment of the present invention can also be executed by the terminal devices 801, 802, and 803, and accordingly, the device for generating a short link can be set in the terminal devices 801, 802, and 803.
[0222] It should be understood that Figure 8 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0223] Reference below Fig. 9 , which shows a schematic diagram of the structure of a computer system 900 of a terminal device suitable for implementing an embodiment of the present invention. Fig. 9 The terminal device 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.
[0224] like Fig. 9As shown, the computer system 900 includes a central processing unit (CPU) 901, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 902 or a program loaded from a storage part 908 into a random access memory (RAM) 903. In the RAM 903, various programs and data required for the operation of the system 900 are also stored. The CPU 901, the ROM 902, and the RAM 903 are connected to each other via a bus 904. An input / output (I / O) interface 905 is also connected to the bus 904.
[0225] The following components are connected to the I / O interface 905: an input section 906 including a keyboard, a mouse, etc.; an output section 907 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 908 including a hard disk, etc.; and a communication section 909 including a network interface card such as a LAN card, a modem, etc. The communication section 909 performs communication processing via a network such as the Internet. A drive 910 is also connected to the I / O interface 905 as needed. A removable medium 911, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 910 as needed, so that a computer program read therefrom is installed into the storage section 908 as needed.
[0226] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 909, and / or installed from the removable medium 911. When the computer program is executed by the central processing unit (CPU) 901, the above-mentioned functions defined in the system of the embodiment of the present invention are executed.
[0227] It should be noted that the computer-readable medium shown in the embodiment of the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More 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 or 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 of the above. In an embodiment of the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In an embodiment of the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0228] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, functions and operations of the system, method and computer program according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can 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 realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0229] The modules involved in the embodiments of the present invention may be implemented by software or hardware. The modules described may also be set in a processor, for example, it may be described as: a processor includes an encryption module, a splitting module, a bit and module, a mapping module, and a splicing module, wherein the names of these modules do not constitute a limitation on the modules themselves under certain circumstances, for example, the encryption module may also be described as a "module for encrypting the original link".
[0230] As another aspect, an embodiment of the present invention further provides a computer-readable medium, which may be included in the device described in the above embodiment; or it may exist independently and not be assembled into the device. The above computer-readable medium carries one or more programs. When the above one or more programs are executed by a device, the device implements the following method: in response to receiving an original link, encrypt the original link to obtain an encrypted string; split the encrypted string into multiple substrings, perform base conversion on each substring to obtain multiple corresponding standard strings; perform cyclic bitwise AND operation on each standard string according to a preset operand to obtain multiple corresponding bitwise data sets; perform character mapping on each bitwise data set according to a preset character array to obtain multiple corresponding mapping strings; use a preset link identifier to splice the multiple mapping strings to obtain a short link corresponding to the original link.
[0231] According to the technical solution of the embodiment of the present invention, the original link is encrypted, split, cyclically bitwise ANDed, character mapped and string concatenated, so that a short link with a high hashing degree can be generated, thereby improving the security of the short link; the preprocessed random number and the original link are concatenated and encrypted, so that the security of the encrypted string can be improved and the probability of the encrypted string being cracked by brute force can be reduced; the random number is multiplied and summed, and the data is intercepted, so that the hashing degree of the random number can be higher, which is convenient for improving the hashing degree of the short link and avoiding a high overlap of the short link; the preprocessed data is shifted multiple times and the preprocessed data is bitwise ANDed after each shift, so that the preprocessed data can be evenly hashed, thereby improving the recognition and retrieval efficiency of the short link; the character mapping of the bit and the data set according to the character array can improve the flexibility and mapping efficiency of the character mapping, facilitate the optimization of the mapping rules, and make the mapping process controllable; after receiving the access request, it is judged whether the fingerprint identifier corresponding to the access request is valid, and the access request is redirected when the fingerprint identifier is valid, so as to improve the security of accessing network resources through the short link and prevent multiple access requests from violently acquiring the network resources indicated by the short link.
[0232] The above specific implementations do not constitute a limitation on the protection scope of the embodiments of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the embodiments of the present invention should be included in the protection scope of the embodiments of the present invention.
Claims
1. A method for generating a short link, characterized in that: include: In response to receiving the original link, encrypting the original link to obtain an encrypted string; Splitting the encrypted string into multiple substrings, and performing base conversion on each substring to obtain multiple corresponding standard strings; Performing a cyclic bitwise AND operation on each standard string according to a preset operand to obtain a corresponding plurality of bitwise AND data sets; Perform character mapping on each bit and data set according to a preset character array to obtain corresponding multiple mapping strings; The multiple mapping character strings are concatenated using a preset link identifier to obtain a short link corresponding to the original link.
2. The method according to claim 1, characterized in that The original link is encrypted to obtain an encrypted string, including: Preprocessing a preset random number, and concatenating the preprocessed random number and the original link to obtain a concatenated string; The concatenated character string is encrypted using an information digest algorithm to obtain an encrypted character string.
3. The method according to claim 2, characterized in that Preprocess the preset random numbers, including: Use a preset multiplier and addend to perform a product operation and a sum operation on the random number respectively; According to the preset interception rules, data interception is performed on the random number after calculation.
4. The method according to claim 1, characterized in that: The preset operands include: a first operand and a second operand; performing a cyclic bitwise AND operation on each standard character string according to the preset operands to obtain corresponding multiple bitwise AND data sets, including: Performing a bitwise AND operation on each standard character string according to the first operand to obtain a corresponding plurality of preprocessed data; Performing a bitwise AND operation on each preprocessed data according to the second operand to obtain a plurality of corresponding first bit AND data; Each preprocessed data is shifted multiple times according to the preset number of shifts and the shift amount. After each shift, a bitwise AND operation is performed on each shifted preprocessed data according to the second operand to obtain corresponding multiple second bitwise AND data. The first bitwise AND data and the second bitwise AND data corresponding to each standard character string are stored in the corresponding bitwise AND data set.
5. The method according to claim 4, characterized in that Perform character mapping on each bit and data set according to the preset character array to obtain multiple corresponding mapping strings, including: Taking each bit and data in each bit and data set as an array subscript of the character array, and determining a mapping character corresponding to the array subscript in the character array; The mapping characters corresponding to each bit and the data set are concatenated to obtain corresponding multiple mapping strings.
6. The method according to claim 1, characterized in that After obtaining the short link corresponding to the original link, the method further includes: Generate summary information corresponding to the original link; The summary information, the original link, and the short link corresponding to the original link are stored in association, and the summary information is used as an index of the association storage.
7. The method according to claim 6, characterized in that The summary information, the original link, and the short link corresponding to the original link are stored in a database; before encrypting the original link, the method further includes: It is determined that the original link is not found in the database.
8. The method according to claim 1, characterized in that The link identifier includes a fingerprint identifier; the method further includes: In response to receiving the access request, obtaining a corresponding target short link; Determine whether the fingerprint identifier included in the target short link is valid; If it is determined that the fingerprint identifier included in the target short link is valid, querying the corresponding target original link according to the target short link; The access request is redirected according to the target original link.
9. The method according to claim 8, characterized in that The method further comprises: Performing data statistics on the access requests to obtain statistical results; The statistical result, the target short link and the target original link are stored in association.
10. A device for generating a short link, characterized in that: include: An encryption module, configured to encrypt the original link in response to receiving the original link to obtain an encrypted string; A splitting module, used for splitting the encrypted string into multiple substrings, and performing base conversion on each substring to obtain multiple corresponding standard strings; A bit AND module is used to perform a cyclic bit AND operation on each standard string according to a preset operand to obtain a corresponding plurality of bit AND data sets; A mapping module, used for performing character mapping between each bit and the data set according to a preset character array to obtain a corresponding plurality of mapping strings; The concatenation module is used to concatenate the multiple mapping character strings using a preset link identifier to obtain a short link corresponding to the original link.
11. An electronic device, characterized in that: include: One or more processors; A storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 9.
12. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 9 is implemented.