String generation method, device, computer readable medium and electronic device
By mapping the self-increment data to a unique numerical value in the preset space, a unique character string to be generated is solved, and the problem of innate strings generated by the current time in the prior art is solved, and a more efficient and safe character string is achieved generate.
Patent Information
- Application Number
- CN202010219805.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-03-25
- Publication Date
- 2025-02-21
- Estimated Expiration
- 2040-03-25
AI Technical Summary
In the prior art, there are indiscriminate problems with character strings generated through current time, which makes it impossible to guarantee the uniqueness of user sharing operations.
By reading the pre-stored self-increment data, determine the string length of the character string to be generated, and map the self-increment data to a unique value in the preset space to generate a unique character string to be generated.
Ensure that the generated string is unique, improves the response efficiency of string generation requests, and reduces the risk of forgery of string to be generated.
Smart Images

Figure CN113449156B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a character string generation method, a character string generation device, a computer readable medium, and an electronic device. Background Art
[0002] Generally speaking, the terminal needs to generate a corresponding string based on the user's needs, such as the need to share a web page or a URL, to respond to the user's sharing request. The string is usually generated based on the current time recorded in real time in the terminal. The string generated in this way can represent the user's sharing operation this time. However, the current time will have the same problem. For example, there is a time point of 20:00 on February 2 in the whole year of this year and last year. It can be seen that the string generated in this way will have the problem of being non-unique.
[0003] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present application, and therefore may include information that does not constitute the prior art known to ordinary technicians in the field. Summary of the invention
[0004] The purpose of the present application is to provide a string generation method, a string generation device, a computer-readable medium and an electronic device, which can map self-increment data to a unique value in a preset space, further generate a unique string to be generated, and thus ensure the uniqueness of the string to be generated.
[0005] Other features and advantages of the present application will become apparent from the following detailed description, or may be learned in part by the practice of the present application.
[0006] The first aspect of the present application provides a method for generating a character string, which may include the following steps:
[0007] When a string generation request is detected, the pre-stored auto-increment data is read and the string length of the string to be generated is determined;
[0008] Determine a target value mapped by the self-incrementing data in a preset space according to the length of the character string; wherein the preset space includes a plurality of subspaces connected by a curve, and the plurality of subspaces are represented by different values;
[0009] Generate a string to be generated according to a target value, and respond to a string generation request according to the string to be generated.
[0010] In an exemplary embodiment of the present application, generating a character string to be generated according to a target value includes:
[0011] The target value is converted into a base, a target character string corresponding to the target value is obtained, and the target character string is determined as the character string to be generated.
[0012] In an exemplary embodiment of the present application, after reading the pre-stored self-increment data, the above method may further include the following steps:
[0013] The auto-increment data is updated and stored; wherein the updated auto-increment data is greater than the auto-increment data before the update.
[0014] In an exemplary embodiment of the present application, the target value of the self-increment data mapped in the preset space is determined according to the length of the string, including
[0015] The data range represented by the preset space is calculated according to the length of the character string, and the starting value mapped by the starting point of the curve in the preset space is calculated according to the data range;
[0016] Calculate the horizontal axis length and vertical axis length of the preset space according to the starting value and the data range, and calculate the horizontal coordinate and vertical coordinate of the auto-increment data in the preset space according to the horizontal axis length and the vertical axis length;
[0017] The target value of the auto-increment data mapped in the preset space is determined according to the horizontal coordinate, the vertical coordinate, the starting value and the horizontal axis length.
[0018] In an exemplary embodiment of the present application, before reading the pre-stored self-increment data, the above method may further include the following steps:
[0019] When a page sharing operation is detected, whether the to-be-shared page corresponding to the page sharing operation has corresponding sharing permissions;
[0020] If the sharing permission is granted, a string generation request is generated and the number of shares corresponding to the sharing permission is updated.
[0021] In an exemplary embodiment of the present application, before reading the pre-stored self-increment data, the above method may further include the following steps:
[0022] When a link sharing operation is detected, it is detected whether there is a corresponding string for the link sharing operation, and if there is no corresponding string, a string generation request is generated.
[0023] In an exemplary embodiment of the present application, after responding to the character string generation request according to the character string to be generated, the above method may further include the following steps:
[0024] Determine and store the mapping relationship between the character string to be generated and the character string address corresponding to the character string generation request;
[0025] When a user access request is detected, an address query character is generated according to a preset address generation rule and a character string to be generated;
[0026] Determine the string address and output it based on the address query character and mapping relationship.
[0027] According to a second aspect of the present application, a string generating device is provided, comprising a data reading unit, a value determining unit and a string generating unit, wherein:
[0028] A data reading unit, for reading pre-stored auto-increment data and determining the string length of the string to be generated when a string generation request is detected;
[0029] A value determination unit, used to determine a target value mapped by the self-incrementing data in a preset space according to the length of the character string; wherein the preset space includes a plurality of subspaces connected by a curve, and the plurality of subspaces are represented by different values;
[0030] The character string generation unit is used to generate a character string to be generated according to a target value, and respond to a character string generation request according to the character string to be generated.
[0031] In an exemplary embodiment of the present application, the character string generation unit generates a character string to be generated according to a target value, including:
[0032] The character string generating unit performs base conversion on the target numerical value to obtain a target character string corresponding to the target numerical value, and determines the target character string as the character string to be generated.
[0033] In an exemplary embodiment of the present application, the above-mentioned device may further include a data updating unit, wherein:
[0034] The data updating unit is used to update and store the self-incrementing data after the data reading unit reads the pre-stored self-incrementing data; wherein the updated self-incrementing data is greater than the self-incrementing data before the update.
[0035] In an exemplary embodiment of the present application, the value determination unit determines the target value mapped by the auto-increment data in the preset space according to the length of the character string, including:
[0036] The value determination unit calculates the data range represented by the preset space according to the length of the character string, and calculates the starting value mapped by the starting point of the curve in the preset space according to the data range;
[0037] The value determination unit calculates the horizontal axis length and the vertical axis length of the preset space according to the starting value and the data range, and calculates the horizontal coordinate and the vertical coordinate of the self-increment data in the preset space according to the horizontal axis length and the vertical axis length;
[0038] The value determination unit determines a target value mapped by the self-incrementing data in a preset space according to the horizontal coordinate, the vertical coordinate, the starting value and the horizontal axis length.
[0039] In an exemplary embodiment of the present application, the above-mentioned device may further include a sharing permission detection unit and a character string generation request generation unit, wherein:
[0040] A sharing permission detection unit, used for detecting whether the to-be-shared page corresponding to the page sharing operation has corresponding sharing permission before the data reading unit reads the pre-stored self-increment data and when a page sharing operation is detected;
[0041] The character string generation request generation unit is used to generate a character string generation request and update the number of sharing times corresponding to the sharing permission when the sharing permission detection unit detects that the to-be-shared page corresponding to the page sharing operation has the corresponding sharing permission.
[0042] In an exemplary embodiment of the present application, the above-mentioned device may further include a character string detection unit, wherein:
[0043] A character string detection unit, used for detecting whether there is a corresponding character string for the link sharing operation before the data reading unit reads the pre-stored self-increment data and when the link sharing operation is detected;
[0044] The character string generation request generating unit is further configured to generate a character string generation request when the character string detecting unit detects that there is no corresponding character string for the link sharing operation.
[0045] In an exemplary embodiment of the present application, the above-mentioned device may further include a mapping relationship determination unit, an address query character generation unit, and a character string address determination unit, wherein:
[0046] A mapping relationship determination unit, configured to determine and store a mapping relationship between the string to be generated and the string address corresponding to the string generation request after the string generation unit responds to the string generation request according to the string to be generated;
[0047] An address query character generating unit, for generating an address query character according to a preset address generating rule and a character string to be generated when a user access request is detected;
[0048] The character string address determination unit is used to determine the character string address according to the address query character and the mapping relationship and output it.
[0049] According to a third aspect of the present application, a computer-readable medium is provided, on which a computer program is stored. When the program is executed by a processor, the character string generation method described in the first aspect of the above embodiment is implemented.
[0050] According to a fourth aspect of the present application, an electronic device is provided, 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 character string generation method as described in the first aspect of the above embodiment.
[0051] The technical solution provided by this application may have the following beneficial effects:
[0052] In the technical solution provided in the embodiment of the present application, when a string generation request is detected, the pre-stored self-increment data (such as 10) can be read and the string length of the string to be generated can be determined. Furthermore, the target value (such as 255) mapped by the self-increment data in the preset space can be determined according to the string length; wherein the preset space includes multiple subspaces connected by curves, and the multiple subspaces are represented by different values. Furthermore, the string to be generated can also be generated according to the target value, and the string generation request can be responded to according to the string to be generated. According to the above scheme description, on the one hand, the present application can map the self-increment data to a unique value in the preset space, further generate a unique string to be generated, and thus ensure the uniqueness of the string to be generated; on the other hand, since the string length is limited, when the string length is limited to a shorter length, the response efficiency to the string generation request can be improved, and when the string length is limited to a longer length, the risk of the string to be generated being forged can be reduced.
[0053] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] The drawings herein are incorporated into the specification and constitute a part of the specification, showing embodiments consistent with the present application, and together with the specification, are used to explain the principles of the present application. Obviously, the drawings described below are only some embodiments of the present application, and for ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. In the drawings:
[0055] Figure 1 A schematic diagram of a flow chart of a method for generating a character string according to an exemplary embodiment of the present application is shown;
[0056] Figure 2 A schematic diagram of a preset space according to an exemplary embodiment of the present application is shown;
[0057] Figure 3 A schematic flow chart of another character string generation method according to an exemplary embodiment of the present application is shown;
[0058] Figure 4A schematic flow chart of another method for generating a character string according to an exemplary embodiment of the present application is shown;
[0059] Figure 5 A schematic flow chart of another method for generating a character string according to an exemplary embodiment of the present application is shown;
[0060] Figure 6 A structural block diagram of a string generating device according to an exemplary embodiment of the present application is shown;
[0061] Figure 7 A schematic diagram of the structure of a computer system of an electronic device suitable for implementing an exemplary embodiment of the present application is shown. DETAILED DESCRIPTION
[0062] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this application will be more comprehensive and complete and fully convey the concept of the example embodiments to those skilled in the art.
[0063] In addition, described feature, structure or characteristic can be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present application. However, those skilled in the art will appreciate that the technical scheme of the present application can be put into practice without one or more of the specific details, or other methods, components, devices, steps, etc. can be adopted. In other cases, known methods, devices, realizations or operations are not shown or described in detail to avoid blurring the various aspects of the application.
[0064] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities may be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.
[0065] The flowcharts shown in the accompanying drawings are only exemplary and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps can be decomposed, and some operations / steps can be combined or partially combined, so the actual execution order may change according to actual conditions.
[0066] See also Figure 1 , Figure 1 A flow chart of a method for generating a character string according to an exemplary embodiment of the present application is shown. The method for generating a character string can be implemented by a server or a terminal device.
[0067] like Figure 1 As shown, according to an embodiment of the present application, the method for generating a character string includes the following steps S110 to S130, wherein:
[0068] Step S110: when a character string generation request is detected, the pre-stored auto-increment data is read and the character string length of the character string to be generated is determined.
[0069] Step S120: determining a target value to be mapped to the self-incrementing data in a preset space according to the length of the character string; wherein the preset space includes a plurality of subspaces connected by curves, and the plurality of subspaces are represented by different values.
[0070] Step S130: Generate a character string to be generated according to the target value, and respond to the character string generation request according to the character string to be generated.
[0071] Implementation Figure 1 The string generation method shown can map the self-increment data to a unique value in a preset space, further generate a unique string to be generated, and thus ensure the uniqueness of the string to be generated. In addition, since the string length is limited, when the string length is limited to a shorter length, the response efficiency to the string generation request can be improved, and when the string length is limited to a longer length, the risk of the string to be generated being forged can be reduced.
[0072] The following is a detailed description of each step:
[0073] In step S110 , when a character string generation request is detected, pre-stored auto-increment data is read and the character string length of the character string to be generated is determined.
[0074] The string generation request is used to request the generation of the above-mentioned string to be generated, the pre-stored auto-increment data may be a value (eg, 10), and the string length of the string to be generated corresponds to the string generation request, wherein, for example, the string length may be 10 bits.
[0075] In the embodiment of the present application, optionally, after reading the pre-stored self-increment data, the above method may further include the following steps:
[0076] The auto-increment data is updated and stored; wherein the updated auto-increment data is greater than the auto-increment data before the update.
[0077] Among them, the specific method of updating the self-increment data can be: adding one to the self-increment data according to the self-increment algorithm, and replacing the original self-increment data with the self-increment data after the addition, so as to realize the update of the self-increment data; wherein, the updated self-increment data (such as 11) is greater than the self-increment data before the update (such as 10).
[0078] It can be seen that by implementing this optional embodiment, the self-increment data can be updated after reading the self-increment data, so that the self-increment data read each time a string generation request is detected is different, thereby ensuring the uniqueness of the determined string to be generated.
[0079] In step S120, a target value to which the self-incrementing data is mapped in a preset space is determined according to the length of the character string; wherein the preset space includes a plurality of subspaces connected by curves, and the plurality of subspaces are represented by different values.
[0080] The preset space is composed of multiple subspaces, each subspace corresponds to a unique value, and all subspaces are connected by a unique curve.
[0081] In the embodiment of the present application, optionally, the target value of the self-increment data mapped in the preset space is determined according to the length of the string, including
[0082] The data range represented by the preset space is calculated according to the length of the character string, and the starting value mapped by the starting point of the curve in the preset space is calculated according to the data range;
[0083] Calculate the horizontal axis length and vertical axis length of the preset space according to the starting value and the data range, and calculate the horizontal coordinate and vertical coordinate of the auto-increment data in the preset space according to the horizontal axis length and the vertical axis length;
[0084] The target value of the auto-increment data mapped in the preset space is determined according to the horizontal coordinate, the vertical coordinate, the starting value and the horizontal axis length.
[0085] The method of calculating the data range represented by the preset space according to the length of the character string may be as follows: n =c calculates the data range represented by the preset space, where n is the length of the string, c is the data range represented by the preset space, and n and c are positive integers.
[0086] Furthermore, the method of calculating the starting value mapped by the starting point of the curve in the preset space according to the data range may specifically be: according to expression 62 n-1 =s determines the starting value mapped by the starting point of the curve in the preset space, where s is the starting value.
[0087] Furthermore, the method of calculating the horizontal axis length and the vertical axis length of the preset space according to the starting value and the data range can be specifically: according to the expression c-s+1=c 1 Calculate the data range c of the string to be generated 1 According to c 1 Calculate less than The largest factor y max , where y maxis the length of the vertical axis; according to the expression Calculate the length of the horizontal axis, where x max is the length of the horizontal axis.
[0088] Furthermore, the method of calculating the horizontal coordinate and the vertical coordinate of the self-incrementing data in the preset space according to the horizontal axis length and the vertical axis length can be specifically: according to the modulo operation i%y max =y i Calculate the vertical coordinate y of the self-incrementing data i in the preset space i ; According to the modulo operation i%x max =x 1 Calculate reference data x 1 , and according to the expression Calculate reference data x 2 ; if x 2 Greater than or equal to x max , then according to the expression x 2 -x max =x i Calculate the horizontal coordinate x of the auto-increment data i in the preset space i , if x 2 Not greater than x max , then x 2 Determine the horizontal coordinate x of the self-incrementing data i in the preset space i .
[0089] Further, the method of determining the target value of the auto-increment data mapped in the preset space according to the horizontal coordinate, the vertical coordinate, the starting value and the horizontal axis length can be specifically: according to the expression y i *x max +s+x i =z calculates the target value z mapped by the self-increment data in the preset space.
[0090] See also Figure 2 , Figure 2 FIG. 1 shows a schematic diagram of a preset space according to an exemplary embodiment of the present application. Figure 2 As shown, the preset space can be composed of subspaces numbered 0 to 255, wherein the subspaces numbered 0 to 255 can be connected by a unique curve, and the horizontal axis and vertical axis of the preset space can be extended from the upper left corner of the preset space as the starting point.
[0091] It can be seen that by implementing this optional embodiment, the target value of the unique mapping of the self-increment data can be determined by determining the coordinates of the self-increment data in the preset space, which can ensure the uniqueness and pseudo-randomness of the strings to be generated corresponding to different string generation requests.
[0092] In step S130, a character string to be generated is generated according to the target value, and a character string generation request is responded to according to the character string to be generated.
[0093] The character string to be generated may include at least one of numbers, symbols, English letters, Chinese characters, etc., and the character string to be generated satisfies the above-mentioned character string length.
[0094] In the embodiment of the present application, optionally, generating a character string to be generated according to a target value includes:
[0095] The target value is converted into a base, a target character string corresponding to the target value is obtained, and the target character string is determined as the character string to be generated.
[0096] Specifically, the method of performing base conversion on the target value to obtain the target character string corresponding to the target value may be: converting the target value from base 10 to base 62 to obtain the target character string corresponding to the target value.
[0097] The target value can be converted from decimal to 62-base according to the following table:
[0098]
[0099]
[0100] It can be seen that by implementing this optional embodiment, a numerical value can be converted into a character string through base conversion to obtain a character string to be generated corresponding to the character string generation request.
[0101] In the embodiment of the present application, optionally, before reading the pre-stored self-increment data, the method may further include the following steps:
[0102] When a page sharing operation is detected, whether the to-be-shared page corresponding to the page sharing operation has corresponding sharing permissions;
[0103] If the sharing permission is granted, a string generation request is generated and the number of shares corresponding to the sharing permission is updated.
[0104] See also Figure 3 , Figure 3 A flowchart of another string generation method according to an exemplary embodiment of the present application is shown. The flowchart of another string generation method includes: steps S310 to S390, wherein:
[0105] Step S310: When a page sharing operation is detected, it is detected whether the page to be shared corresponding to the page sharing operation has the corresponding sharing permission. If yes, step S320 is executed; if not, the process ends.
[0106] Step S320: Generate a character string generation request and update the number of sharing times corresponding to the sharing authority.
[0107] Step S330: when a character string generation request is detected, the pre-stored auto-increment data is read, the auto-increment data is updated and stored; wherein the updated auto-increment data is greater than the auto-increment data before the update.
[0108] Step S340: Determine the string length of the string to be generated.
[0109] Step S350: Calculate the data range represented by the preset space according to the character string length, and calculate the starting value mapped by the starting point of the curve in the preset space according to the data range; wherein the preset space includes multiple subspaces connected by curves, and the multiple subspaces are represented by different values.
[0110] Step S360: Calculate the horizontal axis length and vertical axis length of the preset space according to the starting value and the data range, and calculate the horizontal coordinate and vertical coordinate of the self-increment data in the preset space according to the horizontal axis length and the vertical axis length.
[0111] Step S370: Determine the target value of the self-increment data mapped in the preset space according to the horizontal coordinate, the vertical coordinate, the starting value and the horizontal axis length.
[0112] Step S380: performing base conversion on the target numerical value to obtain a target character string corresponding to the target numerical value, and determining the target character string as the character string to be generated.
[0113] Step S390: respond to the string generation request according to the string to be generated.
[0114] Specifically, the page sharing operation can be a user operation. For example, the present application can be applied to the page promotion field of an e-commerce platform. Users can click to receive the activity red envelope in the third-party promotion page. The activity red envelope can enable users to obtain certain discounts when placing orders to purchase goods through virtual values. In addition, the activity red envelope can be output in the form of a page, and users can share the page of the activity red envelope with other users. When it is detected that the virtual function key used to indicate page sharing is triggered, it can be determined that the page sharing operation is detected.
[0115] Furthermore, the specific method for detecting whether the page to be shared (such as the page of the activity red envelope) corresponding to the page sharing operation has the corresponding sharing authority can be: detecting whether the page to be shared corresponding to the page sharing operation has a corresponding sharing id, and if so, determining that the page to be shared has the corresponding sharing authority; wherein, the page to be shared can correspond to one or more sharing ids to be generated, and the number of sharing ids can be used to indicate the number of times the page to be shared can be shared, and the sharing id can be generated by the string generation method in the embodiment of the present application. Further, the specific method for detecting whether the page to be shared corresponding to the page sharing operation has a corresponding sharing id can be: detecting the number of shares of the page to be shared corresponding to the page sharing operation and the total number of sharing ids that can be generated, if the number of shares is less than the total number of sharing ids that can be generated, then determining that the page to be shared corresponding to the page sharing operation has a corresponding sharing id; wherein, the total number of sharing ids that can be generated includes the number of sharing ids that have been generated and the number of sharing ids that have not been generated, and the number of shares can be pre-set, such as 5 times. Furthermore, a string generation request can be generated and the number of shares corresponding to the sharing permission can be updated: wherein, the method of updating the number of shares corresponding to the sharing permission can specifically be: adding one to the current number of shares, and storing the result of the addition as the new number of shares. In addition, if the page to be shared corresponding to the detected page sharing operation does not have the corresponding sharing permission, it means that the page has reached the sharing number, and further, a prompt message indicating that the page to be shared cannot be shared can be output to prompt the user that the page to be shared cannot be shared. Furthermore, the string to be generated can be generated according to steps S330 to S390 and the string generation request can be responded to according to the string to be generated.
[0116] It should be noted that steps S330 to S390 are Figure 1 For the specific implementation of steps S330 to S390, please refer to Figure 1 The steps and embodiments thereof will not be repeated here.
[0117] It can be seen that by implementing this optional embodiment, a character string to be generated that satisfies the number of times the page to be shared is shared can be generated, and the uniqueness of the character string to be generated can be ensured, thereby realizing sharing control over the page to be shared.
[0118] In the embodiment of the present application, optionally, before reading the pre-stored self-increment data, the method may further include the following steps:
[0119] When a link sharing operation is detected, it is detected whether there is a corresponding string for the link sharing operation, and if there is no corresponding string, a string generation request is generated.
[0120] See also Figure 4 , Figure 4 A flowchart of another method for generating a character string according to an exemplary embodiment of the present application is shown. The flowchart of another method for generating a character string includes: steps S410 to S490, wherein:
[0121] Step S410: When a link sharing operation is detected, check whether there is a corresponding character string for the link sharing operation. If not, execute step S420. If yes, end this process.
[0122] Step S420: Generate a character string generation request.
[0123] Step S430: when a character string generation request is detected, the pre-stored auto-increment data is read, the auto-increment data is updated and stored; wherein the updated auto-increment data is greater than the auto-increment data before the update.
[0124] Step S440: Determine the string length of the string to be generated.
[0125] Step S450: Calculate the data range represented by the preset space according to the character string length, and calculate the starting value mapped by the starting point of the curve in the preset space according to the data range; wherein the preset space includes multiple subspaces connected by curves, and the multiple subspaces are represented by different values.
[0126] Step S460: Calculate the horizontal axis length and vertical axis length of the preset space according to the starting value and the data range, and calculate the horizontal coordinate and vertical coordinate of the self-increment data in the preset space according to the horizontal axis length and the vertical axis length.
[0127] Step S470: Determine the target value of the self-increment data mapped in the preset space according to the horizontal coordinate, the vertical coordinate, the starting value and the horizontal axis length.
[0128] Step S480: performing base conversion on the target numerical value to obtain a target character string corresponding to the target numerical value, and determining the target character string as the character string to be generated.
[0129] Step S490: respond to the character string generation request according to the character string to be generated.
[0130] Specifically, the embodiment of the present application can also be applied to the field of obtaining electronic codes of e-commerce platforms. Users can obtain activity links on e-commerce platforms. The activity links are related to the promotion activities of commodities. Users can share the activity links and obtain an electronic code (such as a prize code). If the prize code is the same as the winning code, the user can obtain the corresponding discount or prize. When it is detected that the virtual key of the sharing function used to represent the activity link is triggered, it can be determined that the link sharing operation is detected. Then, it can be detected whether there is a corresponding string for the link sharing operation, specifically including: determining the user account corresponding to the link sharing operation, detecting whether there is a corresponding string for the user account, and the string can be an electronic code (such as a prize code); if there is, it is determined that there is a corresponding string for the link sharing operation, and further it can also include: outputting a prompt information for indicating that the user has obtained the electronic code; if there is no, generating a string generation request. Further, the string to be generated can be generated according to steps S330 to S390 and the string generation request can be responded to according to the string to be generated. In addition, after the string to be generated is generated, it can also include: storing the string to be generated and the user account in correspondence for calling.
[0131] It should be noted that steps S430 to S490 are Figure 1 For the specific implementation of steps S430 to S490, please refer to Figure 1 The steps and embodiments thereof will not be repeated here.
[0132] It can be seen that the implementation of this optional embodiment can generate unique corresponding character strings to be generated for different user accounts, wherein the character strings to be generated are also pseudo-random, which improves the efficiency of character string generation compared to the method of generating character strings in the prior art.
[0133] In the embodiment of the present application, optionally, after responding to the character string generation request according to the character string to be generated, the method may further include the following steps:
[0134] Determine and store the mapping relationship between the character string to be generated and the character string address corresponding to the character string generation request;
[0135] When a user access request is detected, an address query character is generated according to a preset address generation rule and a character string to be generated;
[0136] Determine the string address and output it based on the address query character and mapping relationship.
[0137] See also Figure 5 , Figure 5A flowchart of another method for generating a character string according to an exemplary embodiment of the present application is shown. The flowchart of another method for generating a character string includes: steps S510 to S580, wherein:
[0138] Step S510: when a character string generation request is detected, the pre-stored auto-increment data is read, the auto-increment data is updated and stored; wherein the updated auto-increment data is greater than the auto-increment data before the update.
[0139] Step S520: Determine the string length of the string to be generated.
[0140] Step S530: Calculate the data range represented by the preset space according to the character string length, and calculate the starting value mapped by the starting point of the curve in the preset space according to the data range; wherein the preset space includes multiple subspaces connected by curves, and the multiple subspaces are represented by different values.
[0141] Step S540: Calculate the horizontal axis length and vertical axis length of the preset space according to the starting value and the data range, and calculate the horizontal coordinate and vertical coordinate of the self-increment data in the preset space according to the horizontal axis length and the vertical axis length.
[0142] Step S550: determining the target value of the self-increment data mapped in the preset space according to the horizontal coordinate, the vertical coordinate, the starting value and the horizontal axis length.
[0143] Step S560: performing base conversion on the target numerical value to obtain a target character string corresponding to the target numerical value, and determining the target character string as the character string to be generated.
[0144] Step S570: responding to the string generation request according to the string to be generated, determining and storing a mapping relationship between the string to be generated and the string address corresponding to the string generation request.
[0145] Step S580: when a user access request is detected, an address query character is generated according to a preset address generation rule and a character string to be generated, and a character string address is determined and output according to the address query character and a mapping relationship.
[0146] Specifically, the embodiments of the present application can also be applied to the field of URL generation. Through steps S510 to S560, a character string to be generated corresponding to the URL to be shared can be generated. The character string length of the character string to be generated (e.g., IJx6lz) is less than the character string length of the URL to be shared (e.g., https: / / h5.m.jd.com / babelDiy / Zeus / 4ETmRNb8Jexxx9oXRbfGgiUYA / index.html). When a user access request is detected, an address query character can be generated according to a preset address generation rule and the character string to be generated; wherein the preset address generation rule can be scheme+host+path, path is the character string to be generated, and the address query character can be https: / / u.jd.com / IJx6lz. Furthermore, the character string address can be determined and output according to the address query character and the mapping relationship.
[0147] It should be noted that steps S510 to S560 are Figure 1 For the specific implementation of steps S510 to S560, please refer to Figure 1 The steps and embodiments thereof will not be repeated here.
[0148] It can be seen that the implementation of this optional embodiment can improve the response speed when the user shares the URL by generating a shorter character string to be generated corresponding to the URL to be shared.
[0149] See also Figure 6 , Figure 6 The structure block diagram of a string generation device according to an exemplary embodiment of the present application is shown. The string generation device includes a data reading unit 601, a value determination unit 602 and a string generation unit 603, wherein:
[0150] The data reading unit 601 is used to read the pre-stored auto-increment data and determine the string length of the string to be generated when a string generation request is detected;
[0151] A value determination unit 602 is used to determine a target value mapped by the self-incrementing data in a preset space according to the length of the character string; wherein the preset space includes a plurality of subspaces connected by a curve, and the plurality of subspaces are represented by different values;
[0152] The character string generating unit 603 is used to generate a character string to be generated according to a target value, and respond to a character string generation request according to the character string to be generated.
[0153] It can be seen that the implementation Figure 6The string generation device shown can map the self-increment data to a unique value in a preset space, further generate a unique string to be generated, and thus ensure the uniqueness of the string to be generated. In addition, since the string length is limited, when the string length is limited to a shorter length, the response efficiency to the string generation request can be improved, and when the string length is limited to a longer length, the risk of the string to be generated being forged can be reduced.
[0154] In an exemplary embodiment of the present application, the character string generating unit 603 generates a character string to be generated according to a target value, including:
[0155] The character string generating unit 603 performs base conversion on the target numerical value to obtain a target character string corresponding to the target numerical value, and determines the target character string as the character string to be generated.
[0156] It can be seen that by implementing this optional embodiment, a numerical value can be converted into a character string through base conversion to obtain a character string to be generated corresponding to the character string generation request.
[0157] In an exemplary embodiment of the present application, the above-mentioned device may further include a data updating unit (not shown), wherein:
[0158] The data updating unit is used to update and store the self-incrementing data after the data reading unit 601 reads the pre-stored self-incrementing data; wherein the updated self-incrementing data is greater than the self-incrementing data before the update.
[0159] It can be seen that by implementing this optional embodiment, the self-increment data can be updated after reading the self-increment data, so that the self-increment data read each time a string generation request is detected is different, thereby ensuring the uniqueness of the determined string to be generated.
[0160] In an exemplary embodiment of the present application, the value determination unit 602 determines the target value mapped by the self-increment data in the preset space according to the length of the string, including
[0161] The value determination unit 602 calculates the data range represented by the preset space according to the character string length, and calculates the starting value mapped by the starting point of the curve in the preset space according to the data range;
[0162] The value determination unit 602 calculates the horizontal axis length and the vertical axis length of the preset space according to the starting value and the data range, and calculates the horizontal coordinate and the vertical coordinate of the self-increment data in the preset space according to the horizontal axis length and the vertical axis length;
[0163] The value determination unit 602 determines the target value of the self-increment data mapped in the preset space according to the horizontal coordinate, the vertical coordinate, the starting value and the horizontal axis length.
[0164] It can be seen that by implementing this optional embodiment, the target value of the unique mapping of the self-increment data can be determined by determining the coordinates of the self-increment data in the preset space, which can ensure the uniqueness and pseudo-randomness of the strings to be generated corresponding to different string generation requests.
[0165] In an exemplary embodiment of the present application, the above-mentioned device may further include a sharing permission detection unit (not shown) and a character string generation request generation unit (not shown), wherein:
[0166] A sharing permission detection unit, used for detecting whether the to-be-shared page corresponding to the page sharing operation has corresponding sharing permission before the data reading unit 601 reads the pre-stored self-increment data and when a page sharing operation is detected;
[0167] The character string generation request generation unit is used to generate a character string generation request and update the number of sharing times corresponding to the sharing permission when the sharing permission detection unit detects that the to-be-shared page corresponding to the page sharing operation has the corresponding sharing permission.
[0168] It can be seen that by implementing this optional embodiment, a character string to be generated that satisfies the number of times the page to be shared is shared can be generated, and the uniqueness of the character string to be generated can be ensured, thereby realizing sharing control over the page to be shared.
[0169] In an exemplary embodiment of the present application, the above-mentioned device may further include a character string detection unit (not shown), wherein:
[0170] A character string detection unit, used for detecting whether there is a corresponding character string for the link sharing operation before the data reading unit 601 reads the pre-stored self-increment data and when a link sharing operation is detected;
[0171] The character string generation request generating unit is further configured to generate a character string generation request when the character string detecting unit detects that there is no corresponding character string for the link sharing operation.
[0172] It can be seen that the implementation of this optional embodiment can generate unique corresponding character strings to be generated for different user accounts, wherein the character strings to be generated are also pseudo-random, which improves the efficiency of character string generation compared to the method of generating character strings in the prior art.
[0173] In an exemplary embodiment of the present application, the above-mentioned device may further include a mapping relationship determination unit (not shown), an address query character generation unit (not shown), and a character string address determination unit (not shown), wherein:
[0174] A mapping relationship determining unit, configured to determine and store a mapping relationship between the string to be generated and the string address corresponding to the string generation request after the string generation unit 603 responds to the string generation request according to the string to be generated;
[0175] An address query character generating unit, for generating an address query character according to a preset address generating rule and a character string to be generated when a user access request is detected;
[0176] The character string address determination unit is used to determine the character string address according to the address query character and the mapping relationship and output it.
[0177] It can be seen that the implementation of this optional embodiment can improve the response speed when the user shares the URL by generating a shorter character string to be generated corresponding to the URL to be shared.
[0178] Since the functional modules of the string generation device of the exemplary embodiment of the present application correspond to the steps of the exemplary embodiment of the string generation method described above, for details not disclosed in the embodiment of the device of the present application, please refer to the embodiment of the string generation method described above in the present application.
[0179] See also Figure 7 , Figure 7 A schematic diagram of the structure of a computer system 700 suitable for implementing an electronic device according to an exemplary embodiment of the present application is shown. Figure 7 The computer system 700 of the electronic 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 application.
[0180] like Figure 7 As shown, computer system 700 includes a central processing unit (CPU) 701, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 702 or a program loaded from a storage part 708 into a random access memory (RAM) 703. Various programs and data required for system operation are also stored in RAM 703. CPU 701, ROM 702 and RAM 703 are connected to each other via a bus 704. An input / output (I / O) interface 705 is also connected to bus 704.
[0181] The following components are connected to the I / O interface 705: an input section 706 including a keyboard, a mouse, etc.; an output section 707 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 708 including a hard disk, etc.; and a communication section 709 including a network interface card such as a LAN card, a modem, etc. The communication section 709 performs communication processing via a network such as the Internet. A drive 710 is also connected to the I / O interface 705 as needed. A removable medium 711, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 710 as needed, so that a computer program read therefrom is installed into the storage section 708 as needed.
[0182] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, 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 709, and / or installed from the removable medium 711. When the computer program is executed by the central processing unit (CPU) 701, the above-mentioned functions defined in the system of the present application are executed.
[0183] It should be noted that the computer-readable medium shown in the present application 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 the present application, 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 the present application, 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.
[0184] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. 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.
[0185] The units involved in the embodiments described in this application may be implemented by software or hardware, and the units described may also be set in a processor. The names of these units do not constitute limitations on the units themselves in some cases.
[0186] As another aspect, the present application also provides a computer-readable medium, which may be included in the electronic device described in the above embodiment; or may exist independently without being assembled into the electronic device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by an electronic device, the electronic device implements the string generation method described in the above embodiment.
[0187] For example, the electronic device can implement Figure 1 As shown in: Step S110: when a string generation request is detected, read the pre-stored self-increment data and determine the string length of the string to be generated; Step S120: determine the target value mapped by the self-increment data in the preset space according to the string length; wherein the preset space includes multiple subspaces connected by curves, and the multiple subspaces are represented by different values; Step S130: generate the string to be generated according to the target value, and respond to the string generation request according to the string to be generated.
[0188] It should be noted that, although several modules or units of the equipment for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present application, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into being embodied by multiple modules or units.
[0189] Through the description of the above implementation methods, it is easy for those skilled in the art to understand that the example implementation methods described here can be implemented by software, or by combining software with necessary hardware. Therefore, the technical solution according to the implementation methods of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which can be a personal computer, a server, a touch terminal, or a network device, etc.) to execute the method according to the implementation methods of the present application.
[0190] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that are not disclosed in the present application. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the following claims.
[0191] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.
Claims
1. A method for generating a character string, characterized in that: include: When a string generation request is detected, the pre-stored auto-increment data is read and the string length of the string to be generated is determined; Determining a target value mapped by the self-incrementing data in a preset space according to the length of the character string; wherein the preset space includes a plurality of subspaces connected by a curve, and the plurality of subspaces are represented by different values; generating the character string to be generated according to the target value, and responding to the character string generation request according to the character string to be generated; Wherein, determining the target value of the self-increment data mapped in the preset space according to the length of the string includes: Calculating a data range represented by the preset space according to the length of the character string, and calculating a starting value mapped to the starting point of the curve in the preset space according to the data range; Calculating the horizontal axis length and the vertical axis length of the preset space according to the starting value and the data range, and calculating the horizontal coordinate and the vertical coordinate of the self-increment data in the preset space according to the horizontal axis length and the vertical axis length; A target value mapped by the self-incrementing data in the preset space is determined according to the horizontal coordinate, the vertical coordinate, the starting value and the horizontal axis length.
2. The method according to claim 1, characterized in that Generating the to-be-generated character string according to the target value includes: The target numerical value is converted into a base, a target character string corresponding to the target numerical value is obtained, and the target character string is determined as the character string to be generated.
3. The method according to claim 1, characterized in that After reading the pre-stored auto-increment data, the method further includes: The self-increment data is updated and stored; wherein the updated self-increment data is greater than the self-increment data before the update.
4. The method according to claim 1, characterized in that: Before reading the pre-stored auto-increment data, the method further includes: When a page sharing operation is detected, detecting whether the to-be-shared page corresponding to the page sharing operation has corresponding sharing permissions; If the sharing authority is granted, the character string generation request is generated and the number of sharing times corresponding to the sharing authority is updated.
5. The method according to claim 1, characterized in that Before reading the pre-stored auto-increment data, the method further includes: When a link sharing operation is detected, it is detected whether there is a corresponding character string for the link sharing operation, and if there is no corresponding character string, the character string generation request is generated.
6. The method according to claim 1, characterized in that After responding to the character string generation request according to the character string to be generated, the method further includes: Determine and store a mapping relationship between the character string to be generated and the character string address corresponding to the character string generation request; When a user access request is detected, an address query character is generated according to a preset address generation rule and the character string to be generated; The character string address is determined and output according to the address query character and the mapping relationship.
7. A character string generating device, characterized in that: include: A data reading unit, for reading pre-stored auto-increment data and determining the string length of the string to be generated when a string generation request is detected; A value determination unit, configured to determine a target value mapped by the self-incrementing data in a preset space according to the length of the character string; wherein the preset space includes a plurality of subspaces connected by a curve, and the plurality of subspaces are represented by different values; a character string generating unit, configured to generate the character string to be generated according to the target value, and respond to the character string generation request according to the character string to be generated; Wherein, determining the target value of the self-increment data mapped in the preset space according to the length of the string includes: Calculating a data range represented by the preset space according to the length of the character string, and calculating a starting value mapped to the starting point of the curve in the preset space according to the data range; Calculating the horizontal axis length and the vertical axis length of the preset space according to the starting value and the data range, and calculating the horizontal coordinate and the vertical coordinate of the self-increment data in the preset space according to the horizontal axis length and the vertical axis length; A target value mapped by the self-incrementing data in the preset space is determined according to the horizontal coordinate, the vertical coordinate, the starting value and the horizontal axis length.
8. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the character string generation method according to any one of claims 1 to 6 is implemented.
9. 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 character string generation method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Short link generation method and system
CN106210161A