Character sequence generation method and device, electronic equipment, chip and storage medium
By constructing a character set and using a preset step size to generate a new character sequence, the problem of low efficiency in character sequence uniqueness verification in the existing technology is solved, efficient and stable character sequence generation is achieved, and duplication caused by high concurrency is avoided. Sequence issues.
Patent Information
- Application Number
- CN202311587601.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-24
- Publication Date
- 2024-10-22
AI Technical Summary
When the existing technology generates character sequences, as the number of character sequences increases, all sequences need to be traversed to ensure uniqueness, resulting in a reduction in system operating efficiency, which may lead to repeated sequence problems, especially in high concurrency situations.
By constructing a character set, and based on the current maximum character sequence and preset step size in the system, a new character sequence is generated to ensure that sequence elements are not repeated, and the distributed lock mechanism is used to avoid repeated sequence problems caused by high concurrency.
It improves the operating efficiency of the system, ensures the uniqueness of the generated character sequence, avoids the occurrence of repeated sequences under high concurrency conditions, and improves the stability of character sequence generation.
Smart Images

Figure CN118819635A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method, device, electronic device, chip and storage medium for generating a character sequence. Background Art
[0002] In the existing technical solutions, the uniqueness of the character sequence is generally controlled by verification. A character sequence is generated by an algorithm, such as a random algorithm or a non-random algorithm, and the generated character sequence is compared with the existing character sequence one by one. If there is a repetition, the character sequence is discarded and a new sequence is generated again until the sequence is no longer repeated. However, when the number of existing character sequences continues to grow, this method requires traversing all character sequences, which will reduce the efficiency of system operation. Summary of the invention
[0003] Embodiments of the present application provide a character sequence generation method, a character sequence generation device, an electronic device, a chip, and a computer-readable storage medium.
[0004] The technical solution of the embodiment of the present application is implemented as follows:
[0005] In a first aspect, an embodiment of the present application provides a method for generating a character sequence, comprising:
[0006] Constructing a character set; the elements in the character set correspond to the indexes one by one;
[0007] Obtain a first character sequence; the first character sequence is the largest character sequence currently existing in the system;
[0008] A second character sequence is generated based on at least one of the character set, the first character sequence, and a preset step size.
[0009] The character sequence generation method provided in the embodiment of the present application, generating the second character sequence based on the character set, the first character sequence and at least one of the preset step length, includes:
[0010] If there are elements in the first character sequence that do not belong to the character set, the second character sequence is initialized and generated based on the character set, and the number of sequence bits of the second character sequence is the same as the number of sequence bits of the first character sequence.
[0011] The character sequence generation method provided in the embodiment of the present application, generating the second character sequence based on the character set, the first character sequence and at least one of the preset step length, includes:
[0012] If all elements in the first character sequence belong to the character set, the second character sequence is generated by performing carry-over according to the preset step size on the basis of the first character sequence.
[0013] The character sequence generation method provided in the embodiment of the present application, generating the second character sequence by carrying the first character sequence according to the preset step length, comprises:
[0014] Determine a first sequence bit starting from the lowest bit of the first character sequence and ending with the highest bit of the first character sequence; the first sequence bit is a sequence bit that complies with a preset rule after a carry;
[0015] The elements of the first sequence position in the first character sequence are carried forward according to a preset step length, and the sequence positions in the first character sequence that are lower than the first sequence position are initialized to generate the second character sequence;
[0016] If all sequence bits from the lowest bit to the highest bit of the first character sequence do not conform to the preset rule after being carried, the number of sequence bits of the first character sequence is increased by 1, and the second character sequence is initialized and generated based on the character set.
[0017] In the character sequence generation method provided in the embodiment of the present application, the preset rule includes: each element in the character sequence is not repeated.
[0018] In the character sequence generation method provided in the embodiment of the present application, the element types in the character set include at least one of the following: letters, numbers and special characters.
[0019] The character sequence generation method provided in the embodiment of the present application further includes:
[0020] Lock the unique identifier of the user in the received request;
[0021] When the preset time length is reached and / or the second character sequence corresponding to the user in the request is generated, the lock is released.
[0022] In a second aspect, an embodiment of the present application provides a character sequence generating device, comprising:
[0023] Construction unit: used to construct a character set; the elements in the character set correspond to the indexes one by one;
[0024] An acquisition unit: used for acquiring a first character sequence; the first character sequence is the largest character sequence currently existing in the system;
[0025] A generating unit is configured to generate a second character sequence based on the character set, the first character sequence and at least one of a preset step size.
[0026] In an embodiment of the present application, the generating unit is specifically used to initialize and generate the second character sequence based on the character set if there are elements in the first character sequence that do not belong to the character set, and the number of sequence bits of the second character sequence is the same as the number of sequence bits of the first character sequence.
[0027] In the embodiment of the present application, the generating unit is specifically configured to generate the second character sequence by performing carry-over according to the preset step size on the basis of the first character sequence if all elements in the first character sequence belong to the character set.
[0028] In an embodiment of the present application, the generating unit is specifically used to determine a first sequence bit starting from the lowest bit of the first character sequence to the highest bit of the first character sequence; the first sequence bit is a sequence bit that complies with a preset rule after a carry; the elements of the first sequence bit in the first character sequence are carried according to a preset step size, and the sequence bits in the first character sequence that are lower than the first sequence bit are initialized to generate the second character sequence; if all sequence bits from the lowest bit of the first character sequence to the highest bit of the first character sequence do not comply with the preset rule after a carry, the number of sequence bits of the first character sequence is increased by 1, and the second character sequence is initialized and generated based on the character set.
[0029] In the embodiment of the present application, the preset rule includes: each element in the character sequence is not repeated.
[0030] In the embodiment of the present application, the element types in the character set include at least one of the following: letters, numbers and special characters.
[0031] In an embodiment of the present application, the acquisition unit is further used to lock the unique identifier of the user in the received request; when a preset time is reached and / or a second character sequence corresponding to the user in the request is generated, the lock is released.
[0032] In a third aspect, the present application provides an electronic device, comprising: a processor and a memory, the memory being used to store a computer program, the processor being used to call and run the computer program stored in the memory, and executing any one of the character sequence generation methods provided in the embodiments of the present application.
[0033] In a fourth aspect, the present application provides a chip, comprising: a processor, configured to call and run a computer program from a memory, so that a device equipped with the chip executes any one of the character sequence generation methods provided in the embodiments of the present application.
[0034] In a fifth aspect, the present application provides a computer-readable storage medium for storing a computer program, wherein the computer program enables a computer to execute any one of the character sequence generation methods provided in the embodiments of the present application.
[0035] The character sequence generation method provided in the embodiment of the present application generates a new character sequence by constructing a character set, defining the index of each character element in the character set, and combining the maximum character sequence currently existing in the system and the preset step size. The uniqueness of the generated new character sequence can be guaranteed without traversing all data, thereby improving the operating efficiency of the system. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Figure 1 Schematic diagram of the implementation process of the character sequence generation method provided in the embodiment of the present application Figure 1 ;
[0037] Figure 2 A schematic diagram of a character sequence generation process provided in an embodiment of the present application;
[0038] Figure 3 Schematic diagram of the implementation process of the character sequence generation method provided in the embodiment of the present application Figure 2 ;
[0039] Figure 4 A schematic diagram of the structure of a character sequence generating device provided in an embodiment of the present application;
[0040] Figure 5 A schematic structural diagram of an electronic device provided in an embodiment of the present application;
[0041] Figure 6 A schematic structural diagram of a chip provided in an embodiment of the present application. DETAILED DESCRIPTION
[0042] The following will describe the technical solutions in the embodiments of the present application in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0043] It should be noted that in the embodiments of the present application, the term "and / or" is only a description of the association relationship of the associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the embodiments of the present application, the character " / " generally indicates that the associated objects before and after are in an "or" relationship.
[0044] In the description of the embodiments of the present application, the term "corresponding" may indicate a direct or indirect correspondence between two items, or an association relationship between the two items, or a relationship between indication and being indicated, configuration and being configured, and the like.
[0045] To facilitate understanding of the technical solutions of the embodiments of the present application, the relevant technologies of the embodiments of the present application are described below. The following related technologies can be arbitrarily combined with the technical solutions of the embodiments of the present application as optional solutions, and they all belong to the protection scope of the embodiments of the present application.
[0046] In the related art, the uniqueness of a character sequence is generally controlled by verification. A character sequence is generated by an algorithm, such as a random algorithm or a non-random algorithm, and the sequence is compared with an existing character sequence one by one. If there is a duplicate, the character sequence is discarded and a new sequence is generated again until the sequence is no longer repeated.
[0047] However, as the number of existing character sequences continues to grow, the uniqueness check of the character sequences still needs to traverse all the results. Regardless of whether a database or cache is used at this time, it is impossible to fundamentally solve the problem of reduced operating efficiency due to traversing all the data.
[0048] In addition, if a non-random algorithm is used to generate a character sequence, the generated character sequence may be repeated in high concurrency. When multiple requests arrive at the same time, different threads generate the same sequence using the same algorithm, but the repeated sequence has not been saved at this time, which will cause the repeated sequence to pass the uniqueness check, and the uniqueness of the sequence will be destroyed.
[0049] Figure 1 Schematic diagram of the implementation process of the character sequence generation method provided in the embodiment of the present application Figure 1 ,like Figure 1 As shown, the embodiment of the present application provides a method for generating a character sequence, the method comprising the following steps:
[0050] Step 101: construct a character set; the elements in the character set correspond to the indexes one by one.
[0051] In an optional implementation manner of the present application, the types of elements in the character set include at least one of the following: letters, numbers, and special characters.
[0052] Exemplarily, a character set is constructed using 26 lowercase letters. Refer to Table 1, which shows the correspondence between the 26 lowercase letters and indexes provided in an embodiment of the present application.
[0053]
[0054]
[0055] Table 1
[0056] The distance between each element in the character set can be defined by the index; as shown in Table 1, the index is an Arabic numeral, the index of the element a in the character set is 0, the index of b is 1, the index of c is 2, the index of d is 3, the index of e is 4, the index of f is 5, the index of g is 6, the index of h is 7, the index of i is 8, the index of j is 9, the index of k is 10, the index of l is 11, the index of m is 12, the index of n is 13, the index of o is 14, the index of p is 15, the index of q is 16, the index of r is 17, the index of s is 18, the index of t is 19, the index of u is 20, the index of v is 21, the index of w is 22, the index of x is 23, the index of y is 24, and the index of z is 25. Schematically, the step length between a and b is 1, and the step length between a and c is 2. Of course, the index can also be ASICC code or other methods, which is not limited in this application.
[0057] Step 102: Acquire a first character sequence; the first character sequence is the largest character sequence currently existing in the system.
[0058] In an optional implementation of the present application, a query statement may be used to query and obtain the maximum character sequence currently existing in the system. In actual application, other methods may also be used to obtain the maximum character sequence currently existing in the system, which is not limited in the present application.
[0059] Step 103: Generate a second character sequence based on the character set, the first character sequence and at least one of a preset step size.
[0060] In an optional implementation manner of the present application, generating the second character sequence based on at least one of the character set, the first character sequence, and a preset step size includes:
[0061] If there are elements in the first character sequence that do not belong to the character set, the second character sequence is initialized and generated based on the character set, and the number of sequence bits of the second character sequence is the same as the number of sequence bits of the first character sequence.
[0062] Exemplarily, the elements in the character set are 26 lowercase letters, and the index corresponding to each element is shown in Table 1. If the largest character sequence in the current system is abcdE, since E does not belong to the character set, then a new character sequence aaaaa can be generated based on the character set, that is, the second character sequence. Of course, if a rule is set, such as: the elements in the character sequence are not repeated, then a new character sequence abcde can be generated based on the character set, that is, the second character sequence.
[0063] In an optional implementation manner of the present application, generating the second character sequence based on at least one of the character set, the first character sequence, and a preset step size includes:
[0064] If all elements in the first character sequence belong to the character set, the second character sequence is generated by performing carry-over according to the preset step size on the basis of the first character sequence.
[0065] Exemplary, reference Figure 2 , Figure 2 This is a schematic diagram of the character sequence generation process provided in the embodiment of the present application. Figure 2 As shown, the elements in the character sequence are defined to be non-repetitive, and the largest character sequence is obtained, that is, the first character sequence is obtained. The input largest character sequence contains N elements, which is recorded as The character elements are arranged from high to low, and are recorded as a0, a1, a2...a N-1 Assuming that the preset step size is 1, since the character sequence generation method in the embodiment of the present application is to increase the character sequence based on the current largest character sequence, It is also the latest character sequence, judging Do all the elements in belong to the character set? If If there is an element that does not belong to the character set, then according to the character set Based on the character set, initialize and generate a new character sequence. The number of bits in the new character sequence is the same as The number of digits in the sequence is the same as The character sequences of All elements in belong to the character set, so keep The length of the character sequence remains unchanged, and the lowest element a N-1 Carry according to the preset step size to generate For example, as shown in Table 1, the elements in the character set are 26 lowercase letters, and the distance between adjacent letters is 1. For abcd, when the preset step size is 1, the lowest element a N-1 is d, d is e after one step, generating abce, that is judge Is it empty? If If it is empty, then increase the length of the character sequence to N+1. Initialize and generate a new character sequence; if If it is not empty, a N-1 If a N-1 If the carry does not meet the non-repetition rule, the a that is one digit higher will be N-2 Carry and change a N-1 Initialization, if a N-2 If the carry does not meet the non-repetition rule, then continue to carry the a that is one digit higher N-3 Carry and change aN-2 、a N-1 Initialize, and so on, until a new character sequence can be generated.
[0066] For example, it is defined that the elements in the character sequence are not repeated, the preset step size is 1, and the input character sequence contains N elements, which are recorded as The character elements are arranged from high to low, and are recorded as a0, a1, a2...a N-1 The character set consists of 26 lowercase letters. The indexes corresponding to each element are shown in Table 1. Get the current maximum character combination in the system like If there are elements that do not belong to the character set, it is initialized to generate the same The smallest character sequence with the same length as the character sequence. For example, the character set consists of 26 lowercase letters, and the elements in the character sequence are defined to be non-repeating. When N=4, the initialization character sequence is "abcd"; when N=5, the initialization character sequence is "abcde", and so on. If all elements in the sequence belong to the character set, keep the number of sequence bits N unchanged, and the lowest bit a N-1 Take the next character. If there is no optional character, the high bit a N-2 Perform carry operation, such as the first character sequence The lowest bit is z, and there is no character larger than it, that is, the lowest bit is a N-1 There are no optional characters, so the high bit a needs to be N-2 Perform a carry operation. The next character of d is e, so the high bit a N-2 Take e, sequence number a N-2 After the carry, the preset rule that the elements in the character sequence are not repeated is met, and the sequence is a N-2 The first sequence bit; the lowest bit a N-1 Need to be initialized and take the minimum value, because the elements in the defined character sequence are not repeated, a N-4 、a N-3 and a N-2 They are a, b, and e respectively, so the lowest bit is a N-1 The optional characters are c, d, f, g...x, y, z, the lowest digit is a N-1 Take the minimum value c, then output the second character sequence If the high position a N-2 There is still no optional character, so the high bit a is reset again. N-3 Do carry until a N-j-2 (j=0,1,2...) (corresponding to the first sequence bit) generates a character combination that conforms to the rules Finally, all lower sequence bits below the first sequence bit are initialized. For example, if you enter the first character sequence The lowest sequence bit a3 is x, but y and z already exist in the sequence, so sequence bit a3 cannot be carried. Sequence bit a2 is y, but z already exists in the sequence, so sequence bit a2 cannot be carried. Sequence bit a1 is z, which is the largest character and cannot be carried. Sequence bit a0 is a, and it is carried forward to get b, which meets the preset rules. Then sequence bit a0 corresponds to the first sequence bit, and then the sequence bits a1, a2 and a3 lower than sequence bit a0 are initialized, and the output sequence is If the first character sequence cannot generate a new combination in the current N sequence bits, then start from the lowest bit a N-1 If there is no optional character until the highest bit a0, the character sequence will increase to N+1, and initialize based on the new bit to generate a new character combination. For example, At this time, the highest bit a0=z has no optional characters, so the number of bits increases to 5, and the output
[0067] The embodiment of the present application uses the current largest sequence as an input parameter, increases a fixed step size, and uses a method equivalent to character carry to generate a new sequence in which elements in the sequence are not repeated, thereby ensuring the uniqueness of the character sequence.
[0068] Refer to Table 2, which shows some input character sequences and corresponding output character sequences with a minimum number of digits Nmin=4, a maximum number of digits Nmax=8, and a preset step length step=1.
[0069]
[0070] Table 2
[0071] Based on this, in an optional implementation manner of the present application, the step of generating the second character sequence based on the first character sequence and carrying the characters according to the preset step length includes:
[0072] Determine a first sequence bit starting from the lowest bit of the first character sequence and ending with the highest bit of the first character sequence; the first sequence bit is a sequence bit that complies with a preset rule after a carry;
[0073] The elements of the first sequence position in the first character sequence are carried forward according to a preset step length, and the sequence positions in the first character sequence that are lower than the first sequence position are initialized to generate the second character sequence;
[0074] If all sequence bits from the lowest bit to the highest bit of the first character sequence do not conform to the preset rule after being carried, the number of sequence bits of the first character sequence is increased by 1, and the second character sequence is initialized and generated based on the character set.
[0075] In an optional implementation manner of the present application, the preset rule includes: each element in the character sequence is not repeated.
[0076] In an optional implementation manner of the present application, it is determined whether the character sequence after the carry meets the preset rule;
[0077] If the character sequence after the carry does not meet the preset rule, the character length of the first character sequence is increased by 1 bit, and the second character sequence is initialized and generated based on the character set;
[0078] If the character sequence after the carry meets the preset rule, determine whether the first sequence bit is the lowest sequence bit of the first character sequence; the first sequence bit is the sequence bit of the carry;
[0079] If the first sequence bit is the lowest sequence bit of the first character sequence, the first sequence bit of the first character sequence is incremented according to the preset step size to generate the second character sequence;
[0080] If the first sequence bit is not the lowest sequence bit of the first character sequence, the first sequence bit of the first character sequence is carried forward according to the preset step size, and the sequence bits lower than the first sequence bit are initialized to generate the second character sequence.
[0081] Refer to Table 3, which shows the total number of digits N and their corresponding character sequences when the character set is 26 lowercase letters and the step length step=1, under the condition that the elements in the character sequence are not repeated.
[0082]
[0083]
[0084] Table 3
[0085] It should be noted that whether the character elements in the character sequence are repeated can be set according to actual conditions, and this application does not limit this.
[0086] In an optional implementation manner of the present application, the method further includes:
[0087] Lock the unique identifier of the user in the received request;
[0088] When the preset time length is reached and / or the second character sequence corresponding to the user in the request is generated, the lock is released.
[0089] Under high concurrency conditions, multiple requests may arrive at the system at the same time and generate the same character sequence, but the new sequence has not been saved at this time, which eventually leads to multiple identical character sequences in the system.
[0090] For example, since the character sequence is a unique identifier of a customer in the system, the customer id, that is, the account_id variable, can be used as a basis for determining whether a request is repeated. When the first request carrying the account_id variable U1 arrives, the system uses U1 as the identifier of the distributed lock and starts the next step. If there are still requests carrying U1, the request will be rejected.
[0091] The maximum time for holding the lock is pre-set. If the program generates a character sequence corresponding to the user in the request within the preset maximum time for holding the lock, the program will automatically release the lock; or, if the program continues to run until the preset maximum time for holding the lock and still fails to successfully generate a character sequence corresponding to the user, the program will automatically release the lock.
[0092] Exemplary, reference Figure 3 , Figure 3 Schematic diagram of the implementation process of the character sequence generation method provided in the embodiment of the present application Figure 2 ,like Figure 3 As shown, after receiving the request, a distributed lock is acquired, a character set is constructed, a unique index of the character elements in the character set is defined, the current largest character sequence in the system is acquired, a fixed step size is increased based on the current largest character sequence, a new character sequence with non-repeating elements is obtained, and finally the lock is released.
[0093] The character sequence generation method provided in the embodiment of the present application uses the current largest sequence as the input parameter of the method, increases a fixed step length, and uses a method equivalent to character carry to generate a new sequence in which the elements in the sequence are not repeated, thereby ensuring the uniqueness of the character sequence; the method provided in the embodiment of the present application is compatible with a variety of character elements, including letters, numbers, special characters, etc. A sufficient number of sequences can be generated under a limited number of character bits; at the same time, the algorithm has low complexity and has no special requirements for computing resources; in addition, the embodiment of the present application introduces a distributed lock, and by locking the customer id, that is, the account_id variable, it can effectively avoid multiple requests from generating repeated character sequences under high concurrency conditions, thereby preventing the uniqueness of the sequence from being destroyed.
[0094] The present application embodiment also provides a character sequence generating device 400, referring to Figure 4 The character sequence generating device 400 in this embodiment includes:
[0095] Construction unit 410: used to construct a character set; the elements in the character set correspond to the indexes one by one;
[0096] Acquisition unit 420: used to acquire a first character sequence; the first character sequence is the largest character sequence currently existing in the system;
[0097] Generating unit 430: used to generate a second character sequence based on the character set, the first character sequence and at least one of a preset step size.
[0098] In the embodiment of the present application, the generating unit 430 is specifically used to initialize and generate the second character sequence based on the character set if there are elements in the first character sequence that do not belong to the character set, and the number of sequence bits of the second character sequence is the same as the number of sequence bits of the first character sequence.
[0099] In the embodiment of the present application, the generating unit 430 is specifically configured to generate the second character sequence by performing carry-over according to the preset step size on the basis of the first character sequence if all elements in the first character sequence belong to the character set.
[0100] In an embodiment of the present application, the generating unit 430 is specifically used to determine a first sequence bit starting from the lowest bit of the first character sequence to the highest bit of the first character sequence; the first sequence bit is a sequence bit that complies with a preset rule after a carry; the elements of the first sequence bit in the first character sequence are carried according to a preset step size, and the sequence bits in the first character sequence that are lower than the first sequence bit are initialized to generate the second character sequence; if all sequence bits from the lowest bit of the first character sequence to the highest bit of the first character sequence do not comply with the preset rule after a carry, the number of sequence bits of the first character sequence is increased by 1, and the second character sequence is initialized and generated based on the character set.
[0101] In the embodiment of the present application, the preset rule includes: each element in the character sequence is not repeated.
[0102] In the embodiment of the present application, the element types in the character set include at least one of the following: letters, numbers and special characters.
[0103] In the embodiment of the present application, the acquisition unit 420 is further used to lock the unique identifier of the user in the received request; when a preset time is reached and / or a second character sequence corresponding to the user in the request is generated, the lock is released.
[0104] Those skilled in the art should understand that Figure 4 The implementation functions of each unit in the character sequence generating device 400 shown can be understood by referring to the relevant description of the aforementioned method. Figure 4 The functions of the various units in the character sequence generating device 400 shown may be implemented by a program running on a processor, or may be implemented by a specific logic circuit.
[0105] Figure 5 It is a schematic structural diagram of an electronic device 500 provided in an embodiment of the present application. Figure 5The electronic device 500 shown includes a processor 510, which can call and run a computer program from a memory to implement the method in the embodiment of the present application.
[0106] Alternatively, if Figure 5 As shown, the electronic device 500 may further include a memory 520. The processor 510 may call and run a computer program from the memory 520 to implement the method in the embodiment of the present application.
[0107] The memory 520 may be a separate device independent of the processor 510 , or may be integrated into the processor 510 .
[0108] Alternatively, if Figure 5 As shown, the electronic device 500 may further include a transceiver 530, and the processor 510 may control the transceiver 530 to communicate with other devices, specifically, may send information or data to other devices, or receive information or data sent by other devices.
[0109] The transceiver 530 may include a transmitter and a receiver. The transceiver 530 may further include an antenna, and the number of the antennas may be one or more.
[0110] The electronic device 500 may specifically be a character sequence generating device according to an embodiment of the present application, and the electronic device 500 may implement the corresponding processes implemented by the character sequence generating device in each method according to an embodiment of the present application, which will not be described in detail for the sake of brevity.
[0111] Figure 6 It is a schematic structural diagram of the chip of an embodiment of the present application. Figure 6 The chip 600 shown includes a processor 610, which can call and run a computer program from a memory to implement the method in the embodiment of the present application.
[0112] Alternatively, if Figure 6 As shown, the chip 600 may further include a memory 620. The processor 610 may call and run a computer program from the memory 620 to implement the method in the embodiment of the present application.
[0113] The memory 620 may be a separate device independent of the processor 610 , or may be integrated into the processor 610 .
[0114] Optionally, the chip 600 may further include an input interface 630. The processor 610 may control the input interface 630 to communicate with other devices or chips, and specifically, may obtain information or data sent by other devices or chips.
[0115] Optionally, the chip 600 may further include an output interface 640. The processor 610 may control the output interface 640 to communicate with other devices or chips, and specifically, may output information or data to other devices or chips.
[0116] The chip can be applied to the character sequence generating device in the embodiment of the present application, and the chip can implement the corresponding processes implemented by the character sequence generating device in each method of the embodiment of the present application, which will not be described in detail here for the sake of brevity.
[0117] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.
[0118] It should be understood that the processor of the embodiment of the present application may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method embodiment can be completed by the hardware integrated logic circuit or software instructions in the processor. The above processor can be a general processor, a digital signal processor (Digital Signal Processor, DSP), an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), a field programmable gate array (Field Programmable Gate Array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general processor can be a microprocessor or the processor can also be any conventional processor. The steps of the method disclosed in the embodiment of the present application can be directly embodied as a hardware decoding processor to perform, or the hardware and software modules in the decoding processor are combined and performed. The software module can be located in a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, and other mature storage media in the art. The storage medium is located in the memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware.
[0119] It can be understood that the memory in the embodiments of the present application can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), and direct RAM bus random access memory (DR RAM). It should be noted that the memory of the systems and methods described herein is intended to include, but is not limited to, these and any other suitable types of memory.
[0120] It should be understood that the above-mentioned memory is exemplary but not restrictive. For example, the memory in the embodiments of the present application may also be static random access memory (static RAM, SRAM), dynamic random access memory (dynamic RAM, DRAM), synchronous dynamic random access memory (synchronous DRAM, SDRAM), double data rate synchronous dynamic random access memory (double data rate SDRAM, DDR SDRAM), enhanced synchronous dynamic random access memory (enhanced SDRAM, ESDRAM), synchronous link dynamic random access memory (synch link DRAM, SLDRAM) and direct memory bus random access memory (Direct Rambus RAM, DR RAM), etc. That is to say, the memory in the embodiments of the present application is intended to include but not limited to these and any other suitable types of memory.
[0121] The embodiment of the present application also provides a computer-readable storage medium for storing a computer program. The computer-readable storage medium can be applied to the character sequence generation device in the embodiment of the present application, and the computer program enables a computer to execute the corresponding processes implemented by the character sequence generation device in each method of the embodiment of the present application, which will not be described in detail here for the sake of brevity.
[0122] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0123] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0124] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0125] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0126] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0127] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a character sequence generation device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0128] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A method for generating a character sequence, characterized in that: include: Build character set; The elements in the character set correspond to the indexes one by one; Get the first character sequence; The first character sequence is the largest character sequence currently existing in the system; A second character sequence is generated based on at least one of the character set, the first character sequence, and a preset step size.
2. The character sequence generation method according to claim 1, characterized in that: The step of generating a second character sequence based on at least one of the character set, the first character sequence, and a preset step size includes: If there are elements in the first character sequence that do not belong to the character set, the second character sequence is initialized and generated based on the character set, and the number of sequence bits of the second character sequence is the same as the number of sequence bits of the first character sequence.
3. The character sequence generation method according to claim 1, characterized in that: The step of generating a second character sequence based on at least one of the character set, the first character sequence, and a preset step size includes: If all elements in the first character sequence belong to the character set, the second character sequence is generated by performing carry-over according to the preset step size on the basis of the first character sequence.
4. The character sequence generation method according to claim 3, characterized in that: The step of generating the second character sequence by carrying the first character sequence according to the preset step length comprises: Determine a first sequence bit starting from the lowest bit of the first character sequence and ending with the highest bit of the first character sequence; the first sequence bit is a sequence bit that complies with a preset rule after a carry; The elements of the first sequence position in the first character sequence are carried forward according to a preset step length, and the sequence positions in the first character sequence that are lower than the first sequence position are initialized to generate the second character sequence; If all sequence bits from the lowest bit to the highest bit of the first character sequence do not conform to the preset rule after being carried, the number of sequence bits of the first character sequence is increased by 1, and the second character sequence is initialized and generated based on the character set.
5. The character sequence generation method according to claim 1, characterized in that: The preset rule includes: each element in the character sequence is not repeated.
6. The character sequence generation method according to claim 1, characterized in that: The element types in the character set include at least one of the following: letters, numbers and special characters.
7. The character sequence generation method according to any one of claims 1 to 6, characterized in that: Also includes: Lock the unique identifier of the user in the received request; When the preset time length is reached and / or the second character sequence corresponding to the user in the request is generated, the lock is released.
8. A character sequence generating device, characterized in that: include: Construction unit: used to construct a character set; the elements in the character set correspond to the indexes one by one; Acquisition unit: used for acquiring the first character sequence; The first character sequence is the largest character sequence currently existing in the system; A generating unit is configured to generate a second character sequence based on the character set, the first character sequence and at least one of a preset step size.
9. An electronic device, characterized in that: include: A processor and a memory, the memory being used to store a computer program, the processor being used to call and run the computer program stored in the memory to execute the character sequence generation method as described in any one of claims 1 to 7.
10. A chip, characterized in that: include: A processor is used to call and run a computer program from a memory so that a device equipped with the chip executes the character sequence generation method as described in any one of claims 1 to 7.
11. A computer-readable storage medium, characterized in that: Used to store a computer program, wherein the computer program enables a computer to execute the character sequence generation method according to any one of claims 1 to 7.
