Code generation method and device, electronic equipment and computer readable storage medium
By dynamically generating a new identifier code, in response to the use of the original standard code, the problem of low security of digital resource identification codes in existing technologies has been solved, and dynamic changes and high security of the identifier code are realized.
Patent Information
- Application Number
- CN202411169169.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-23
- Publication Date
- 2025-01-24
AI Technical Summary
In the prior art, the identification code of digital resources cannot effectively improve its security, resulting in the identification code being maliciously intercepted or utilized, causing losses.
By obtaining the usage status of the first identification code of the target resource, in response to the usage meeting the invalidation conditions, it is determined that the first identification code is invalid, and a new valid second identification code is generated for the target resource, so that the identification code changes dynamically and improves security. sex.
The dynamic changes of the target resource identification code have been achieved, and the failure in a short period of time has improved the security of the identifier code, and unnecessary losses caused by malicious use have been avoided.
Smart Images

Figure CN119358582A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a code generation method, device, electronic device and computer-readable storage medium. Background Art
[0002] At present, it is impossible to effectively manage digital resources in a unified manner, it is impossible to effectively track the use of digital resources, and there is no unified entrance to view and use resources. Among them, most of them use a fixed QR code as the identification code of a single resource, and resource information can be obtained by scanning the identification code of the resource. However, the use of a fixed static QR code has low security. Summary of the invention
[0003] The main technical problem solved by the present application is to provide a code generation method, device, electronic device and computer-readable storage medium, which can improve the security of the identification code of the target resource.
[0004] To solve the above technical problems, a technical solution adopted in the present application is: to provide a code generation method, the method comprising: obtaining the usage of a first identification code of a target resource; in response to the usage of the first identification code meeting an expiration condition, determining that the first identification code is invalid; generating a valid second identification code for the target resource; wherein, the first identification code and the second identification code, when in a valid state, can be scanned by a terminal device to obtain resource information of the target resource.
[0005] To solve the above technical problems, another technical solution adopted in the present application is: providing a code generating device, which includes an acquisition module, a determination module and a generation module; the acquisition module is used to obtain the usage of a first identification code of a target resource; the determination module is used to determine that the first identification code is invalid in response to the usage of the first identification code meeting the expiration condition; the generation module is used to generate a valid second identification code for the target resource; wherein, the first identification code and the second identification code can be scanned by a terminal device in a valid state to obtain resource information of the target resource.
[0006] In order to solve the above technical problems, another technical solution adopted by the present application is: to provide an electronic device, the electronic device includes a processor and a memory, the memory stores program instructions, and the program instructions can be executed to implement the above code generation method.
[0007] In order to solve the above technical problem, another technical solution adopted by the present application is: providing a computer-readable storage medium, which is used to store program instructions, and the program instructions can be executed to implement the above code generation method.
[0008] According to the above technical scheme, after determining that the original identification code (first identification code) of the target resource is invalid, the terminal device can no longer obtain the resource information of the target resource through the original identification code of the target resource, and will generate a new valid identification code (second identification code) for the target resource. That is, the identification code of the target resource is dynamic and changing, rather than fixed; therefore, even if the identification code of the target resource is maliciously intercepted / obtained, it will become invalid in a short time, thereby improving the security of the identification code of the target resource and avoiding unnecessary losses caused by the malicious use of the identification code of the target resource. BRIEF DESCRIPTION OF THE DRAWINGS
[0009] Figure 1 It is a flowchart of an embodiment of a code generation method provided by the present application;
[0010] Figure 2 It is a flowchart of an embodiment of updating a first identification code to obtain a second identification code provided by the present application;
[0011] Figure 3 yes Figure 2 The flowchart of step S21 of an embodiment is shown;
[0012] Figure 4 This is a flowchart of an embodiment of determining whether a terminal device has abnormal scanning behavior provided by the present application;
[0013] Figure 5 It is a structural diagram of an embodiment of a code generating device provided by the present application;
[0014] Figure 6 It is a structural schematic diagram of an embodiment of an electronic device provided by the present application;
[0015] Figure 7 It is a structural schematic diagram of an embodiment of a computer-readable storage medium provided by the present application. DETAILED DESCRIPTION
[0016] The scheme of the embodiment of the present application is described in detail below in conjunction with the accompanying drawings of the specification. In the following description, for the purpose of explanation rather than limitation, specific details such as specific system structures, interfaces, and technologies are proposed so as to thoroughly understand the present application. The term "and / or" herein is merely a description of the association relationship of associated objects, indicating that three relationships may exist, for example, A and / or B, which may represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " herein generally indicates that the associated objects before and after are in an "or" relationship. In addition, "many" herein means two or more than two. In addition, the term "at least one" herein represents any combination of at least two of any one or more of a plurality of, for example, including at least one of A, B, and C, which may represent any one or more elements selected from the set consisting of A, B, and C.
[0017] See also Figure 1 , Figure 1 It is a flow chart of an embodiment of the code generation method provided by the present application. It should be noted that if there are substantially the same results, the embodiments of the present application are not based on Figure 1 The process sequence shown is limited. Figure 1 As shown, this embodiment includes:
[0018] Step S11: Acquire usage of the first identification code of the target resource.
[0019] In this implementation, usage of the first identification code of the target resource is obtained.
[0020] Digital resources refer to resources that exist in digital form and can be stored, processed, transmitted and displayed through computers and other devices. The types of digital resources can be diverse. In the construction of government information platforms, digital resources can be government data (such as tax data, financial data, traffic data, etc.), knowledge database data, programmatic trading service system data, and other types of data (such as industry website data, personal homepage data, etc.). Alternatively, digital resources can also be cloud resources, data resources, component resources, etc. It should be noted that the target resource is a digital resource, and the target resource can be any type of digital resource.
[0021] The identification code of the target resource provides a fast and easy way to access the resource information of the target resource; users only need to use the identification code scanning application on the terminal device to scan the identification code to obtain the resource information of the target resource, which greatly improves the efficiency and convenience of information acquisition. In addition, by transmitting the resource information of the target resource through the identification code, security measures such as encryption and verification can be added to ensure the authenticity and security of the resource information of the target resource. Furthermore, embedding specific parameters or links in the identification code can realize the tracking and analysis of user scanning behavior.
[0022] The resource information of the target resource includes basic information, status information, and associated information of the target resource.
[0023] In one embodiment, the usage of the first identification code of the target resource includes that the first identification code has been used, the first identification code has not been used, the duration of the first identification code not being used reaches a preset duration, etc. It should be noted that after the identification code of the target resource becomes the first identification code (after the previous identification code of the target resource becomes invalid, the identification code of the target resource will become the first identification code), if a terminal device successfully obtains the resource information of the target resource by scanning the first identification code of the target resource, or if a terminal device fails to obtain the resource information of the target resource by scanning the first identification code of the target resource (for example, the information acquisition failure may be caused by the terminal device not having the authority to obtain the resource information of the target resource), then the first identification code of the target resource is considered to be used. After the identification code of the target resource becomes the first identification code, if no terminal device obtains the resource information of the target resource by scanning the first identification code of the target resource, then the first identification code of the target resource is considered to be unused. The moment when the identification code of the target resource becomes the first identification code is the starting moment of the duration of the unused duration of the first identification code of the target resource.
[0024] In addition, it should be noted that the scanning data of the target resource's identification code will be recorded, such as the scanning time, scanning location, scanning device, scanning frequency, etc.; therefore, the scanning data of the target resource's identification code can determine whether the target resource's identification code has been used.
[0025] Step S12: In response to the usage of the first identification code meeting the expiration condition, determining that the first identification code is invalid.
[0026] In this embodiment, in response to the usage of the first identification code meeting the expiration condition, the first identification code is determined to be invalid. That is, whether the first identification code of the target resource meets the expiration condition is determined by the usage of the first identification code of the target resource, and when the usage of the first identification code of the target resource meets the expiration condition, the first identification code of the target resource is considered to be invalid.
[0027] In one embodiment, the expiration condition may be that the first identification code of the target resource has been used. That is, after the first identification code of the target resource has been used, the first identification code of the target resource is considered to be invalid. After the identification code of the target resource becomes the first identification code (after the previous identification code of the target resource is invalid, the identification code of the target resource will become the first identification code), if a terminal device successfully obtains the resource information of the target resource by scanning the first identification code of the target resource, or if a terminal device fails to obtain the resource information of the target resource by scanning the first identification code of the target resource (for example, the information acquisition failure may be caused by the terminal device not having the authority to obtain the resource information of the target resource), then the first identification code of the target resource is considered to have been used, and the first identification code of the target resource is invalid.
[0028] In other embodiments, the expiration condition may also be that the continuous length of time that the first identification code of the target resource has not been used reaches a preset length of time. If the first identification code of the target resource has not been used for a long time, the first identification code of the target resource is also considered to be invalid. After the identification code of the target resource changes to the first identification code, if no terminal device obtains the resource information of the target resource by scanning the first identification code of the target resource, the first identification code of the target resource is considered to be unused, wherein the moment when the identification code of the target resource changes to the first identification code is used as the starting moment of the continuous length of time that the first identification code of the target resource has not been used, and if it has not been used for the preset length of time since the starting moment, the first identification code of the target resource is considered to be invalid.
[0029] Step S13: Generate a valid second identification code for the target resource.
[0030] In this embodiment, a valid second identification code is generated for the target resource, wherein the first identification code and the second identification code, when valid, can be scanned by the terminal device to obtain the resource information of the target resource. After determining that the original identification code (first identification code) of the target resource is invalid, the terminal device can no longer obtain the resource information of the target resource through the original identification code of the target resource, and a new valid identification code (second identification code) will be generated for the target resource, that is, the identification code of the target resource is dynamic and changing, rather than fixed; therefore, even if the identification code of the target resource is maliciously intercepted / obtained, it will become invalid in a short time, thereby improving the security of the identification code of the target resource and preventing the identification code of the target resource from being maliciously used to cause unnecessary losses.
[0031] In one embodiment, generating a valid second identification code for a target resource specifically includes: updating the first identification code to obtain the second identification code. That is, the identification code obtained by updating the first identification code of the target resource is used as a new valid identification code of the target resource, and the terminal device can obtain resource information of the target resource by scanning the new valid identification code of the target resource.
[0032] In a specific embodiment, Figure 2 As shown, Figure 2 This is a flow chart of an embodiment of updating a first identification code to obtain a second identification code provided by the present application, wherein the first identification code is obtained based on the first character string encoding, and the first identification code is updated to obtain the second identification code, specifically including the following sub-steps:
[0033] Step S21: Generate a second character string.
[0034] In this implementation, a second string is generated, wherein there is at least one different character between the second string and the first string. There is at least one different character between the first string and the second string, that is, there are different characters between the first string and the second string, so the first string and the second string are different. Then, the second identification code obtained based on the encoding of the second string is different from the first identification code obtained based on the encoding of the first string, and the generated second identification code can be used as a new valid identification code for the target resource.
[0035] It should be noted that the selection of characters for generating the second character string is random, as long as the characters of the selected second character string are different from at least one of the characters constituting the first character string. The generated second character string is random, so the second identification code obtained based on the encoding of the second character string is also random, that is, the generation of the dynamic identification code of the target resource is random. This randomness makes it impossible for an attacker who maliciously intercepts / obtains the identification code of the target resource to predict the next new valid identification code to be generated, so that it becomes almost impossible to forge the identification code, thereby improving the security of the identification code of the target resource and avoiding unnecessary losses caused by malicious use of the identification code of the target resource.
[0036] In one embodiment, the first character string and the second character string contain the same number of characters. Of course, in other embodiments, the first character string and the second character string may also contain different numbers of character strings, which is not limited here.
[0037] In one embodiment, the second string and the first string may not have the same characters, that is, the second string and the first string are two completely non-repeating strings. Of course, in other embodiments, the second string and the first string may also have at least some characters that are different.
[0038] It should be noted that there is no restriction on the character types contained in the string, for example, the character types may be numbers, symbols, uppercase letters, lowercase letters, etc.
[0039] In one embodiment, if Figure 3 As shown, Figure 3 yes Figure 2 The flowchart of step S21 of an embodiment shown in FIG. 1 is to generate a second character string, which specifically includes the following sub-steps:
[0040] Step S31: Select at least two characters from a character set.
[0041] In this implementation, at least two characters are selected from the character set; wherein the first character string is generated by at least two characters in the character set, and at least one character in the first character string is removed from the character set.
[0042] The first string is composed of some characters in the character set. Since at least one character in the first string is removed from the character set after the first string is formed in the early stage, no matter how characters are selected from the character set, all characters in the first string cannot be selected, and the generated second string will not be the same as the first string. Then, the second identification code obtained based on the encoding of the second string is different from the first identification code obtained based on the encoding of the first string, and the generated second identification code is a new valid identification code for the target resource.
[0043] It should be noted that after the first character string is generated, some characters in the first character string may be removed from the character set, or all characters in the first character string may be removed from the character set, which is not limited here.
[0044] In one embodiment, at least two characters may be randomly selected from the character set. Of course, at least two characters may also be selected from the character set according to a certain rule or sequence, which is not limited here.
[0045] Step S32: Generate a second character string based on at least two characters selected from the character set.
[0046] In this embodiment, a second character string is generated based on at least two characters selected from a character set. Since the at least two characters selected from the character set are not completely identical to the characters constituting the first character string, the second character string generated based on the at least two characters selected from the character set is different from the first character string. Then, the second identification code obtained by encoding the second character string is different from the first identification code obtained by encoding the first character string, and the generated second identification code can be used as a new valid identification code for the target resource.
[0047] In one embodiment, at least one character in the second string is removed from the character set. That is, after the second string is generated, at least one character in the second string is removed from the character set, so that when other strings need to be generated later, a string identical to the second string will not be generated, and the same identification code will not be generated later.
[0048] After the second character string is generated, some characters (such as 1, 2, 3, etc.) in the second character string may be removed from the character set, or all characters in the second character string may be removed from the character set, which is not limited here.
[0049] Step S22: Encode the second character string to obtain a second identification code.
[0050] In this implementation, the second string is encoded to obtain a second identification code. Since there are different characters between the first string and the second string, the first string and the second string are different. Then, the second identification code obtained by encoding the second string is different from the first identification code obtained by encoding the first string, and the generated second identification code can be used as a new valid identification code for the target resource.
[0051] The process of scanning the first identification code of the target resource by the terminal device to obtain the resource information of the target resource is as follows: splicing the resource information such as the type and source of the target resource in a certain format to obtain the splicing information. Encrypting the splicing information to obtain the resource identification code; generating a first character string, establishing a mapping relationship between the first character string and the resource identification code, and storing the mapping relationship between the first character string and the resource identification code. Generate a first identification code of the target resource that can be accessed by a page based on the first character string. When the user uses the terminal device to scan the first identification code of the target resource, the first identification code of the target resource will be decoded to obtain the first character string corresponding to the target resource; then, based on the mapping relationship between the first character string and the resource identification code, determine the resource identification code corresponding to the target resource; decrypting the resource identification code to obtain the resource information of the target resource, and feeding it back to the terminal device, the user can obtain the resource information of the target resource through the terminal device.
[0052] Therefore, in one embodiment, after the second character string is generated for the target resource, a mapping relationship between the second character string and the resource information of the target resource is established. After the terminal device subsequently scans the second identification code of the target resource, the processor decodes the second identification code to obtain the second character string. Since the mapping relationship between the second character string and the resource information of the target resource has been established, after the second character string is decoded, the resource information of the target resource can be determined through the mapping relationship between the second character string and the resource information of the target resource, thereby obtaining the resource information of the target resource.
[0053] It should be noted that the identification code of the target resource is independent of the total amount, type, and management rules of the resource, and can be expanded infinitely to meet the needs of large and extra-large resource management applications and the continued growth in resource usage.
[0054] In one embodiment, if Figure 4 As shown, Figure 4 The present application provides a flow chart of an embodiment of determining whether a terminal device has abnormal code scanning behavior, and determining whether a terminal device has abnormal code scanning behavior specifically includes the following sub-steps:
[0055] Step S41: Obtain code scanning behavior data.
[0056] In this implementation, code scanning behavior data is obtained.
[0057] The scanning behavior and related behavior data of all terminal devices will be recorded. For example, the scanning behavior data includes IP, account, scanning time, terminal information, scanning frequency, scanning location, etc.
[0058] Step S42: Perform anomaly detection on the code scanning behavior data to determine whether the terminal device has abnormal code scanning behavior.
[0059] In this embodiment, anomaly detection is performed on the scanning behavior data to determine whether the terminal device has abnormal scanning behavior. In one embodiment, the isolation forest model is used to detect anomalies in the scanning behavior data to determine whether the terminal device has abnormal scanning behavior. Isolation Forest is an unsupervised learning algorithm for anomaly detection. Its basic idea is that abnormal points are more likely to be "isolated" than normal points. The isolation forest model implements this idea by constructing multiple decision trees (called isolation trees). In each isolation tree, data points are segmented by randomly selected features and feature values until they are "isolated" (i.e., they can no longer be segmented). The depth of the isolation tree (i.e., the path length from the root node to the isolated point) can be used as an anomaly score: points with smaller depth are more likely to be abnormal points. Since it does not require labeled data for training, the isolation forest model is very suitable for anomaly detection tasks.
[0060] In one embodiment, the abnormal code scanning behavior includes that the terminal device scans the code in an uncommon area. That is, if the terminal device scans the code in an uncommon area, it can be considered that the terminal device has abnormal code scanning behavior.
[0061] In one embodiment, the target resources include at least two, and the abnormal code scanning behavior includes that the first code scanning quantity of the terminal device meets the first quantity threshold, and the first code scanning quantity is the number of identification codes of different target resources scanned. In other words, if the terminal device frequently scans the identification codes of different target resources, it can be considered that the terminal device scanning the code has abnormal code scanning behavior.
[0062] There is no limitation on the first quantity threshold, and it can be set according to actual use needs.
[0063] In one embodiment, the abnormal code scanning behavior includes the number of times the identification code of the target resource is scanned meeting the second quantity threshold. In other words, if the identification code of the target resource is scanned frequently or repeatedly, it can be considered that the terminal scanning the code has abnormal code scanning behavior.
[0064] The second quantity threshold is not limited and can be set according to actual use needs.
[0065] In one implementation, when it is determined that a terminal device has abnormal code scanning behavior, warning information will be fed back to the target resource administrator to inform the terminal device of the abnormal code scanning behavior.
[0066] In one embodiment, the identification code of the target resource can be a two-dimensional code, which has high storage density, fast reading capability and wide device compatibility. After the dynamic two-dimensional code of the target resource is generated, the various resource information behind the dynamic two-dimensional code can be changed at any time without regenerating the dynamic two-dimensional code. As long as the change is made and saved, the dynamic two-dimensional code can be automatically updated, and the new resource information can be obtained by scanning again.
[0067] The structure of the QR code includes version information, format information, codeword, position detection pattern, position detection pattern separator, positioning pattern and correction pattern. Version information: including version1 (21*21), version2, ..., version40, a total of 40 versions; the version represents how many modules there are in each row, each version adds 4 code elements compared to the previous version, the calculation formula is (n-1)*4+21, each code element stores a binary 0 or 1, 1 represents black, 0 represents white; for example, version1 means that there are 21 code elements in each row. Format information: storage fault tolerance level L (7%), M (15%), Q (25%), R (35%); fault tolerance: allows the stored QR code information to have repeated parts, the higher the level, the higher the proportion of repeated information; purpose: even if the QR code is partially covered by the icon, the entire QR code content can still be obtained; for QR codes with pictures, the picture is not considered part of the QR code, it covers part of the code element, but all the content can still be scanned. Codeword: The actual saved QR code information and error correction codeword (used to correct errors caused by QR code damage, that is, when the code element is covered by the image, it can be retrieved through the error correction codeword). Position detection pattern, position detection pattern separator, positioning pattern and correction pattern: used to locate the QR code; the position detection pattern is used to mark the size of the rectangle, and 3 patterns determine a rectangle; the positioning symbol is because the QR code has 40 versions of size, and when the size is too large, a standard line is required, otherwise it may be scanned crookedly.
[0068] Generation of QR code: The resource information of the target resource is converted into binary according to certain coding rules, and a rectangle is formed by black and white. Among them, the generation of QR code includes data analysis, data coding, error correction coding, construction of final data information, construction matrix, mask and format version information. Data analysis: Determine the type of encoded characters and convert them into symbol characters according to the corresponding character set; select the error correction level. Under certain specifications, the higher the error correction level, the smaller the capacity of the real data. Data coding: Convert data characters into bit streams, one code word for every 8 bits, and the whole constitutes a data code word sequence. In fact, knowing this data code word sequence will know the data content of the QR code. Error correction coding: Divide the above code word sequence into blocks as needed, and generate error correction code words according to the error correction level and the divided code words, and add the error correction code words to the end of the data code word sequence to form a new sequence. Among them, when the specification and error correction level of the two-dimensional code are determined, the total number of code words and the number of error correction code words it can accommodate are also determined. For example: when the version 10 and the error correction level are H, a total of 346 code words can be accommodated, of which 224 are error correction code words; that is, about 1 / 3 of the code words in the two-dimensional code area are redundant; for these 224 error correction code words, it can correct 112 substitution errors (such as black and white inversion) or 224 data reading errors (unable to read or decode), so the error correction capacity is: 112 / 346=32.4%. Construct the final data information: under the condition of the specification being determined, put the sequence generated above into blocks in order; divide the data into blocks according to the regulations, and then calculate each block to obtain the corresponding error correction code word block, and form a sequence of the error correction code word blocks in order, and add them to the original data code word sequence. Construct the matrix: put the detection pattern, separator, positioning pattern, correction pattern and code word module into the matrix. Mask: Apply the mask pattern to the coding area of the symbol so that the dark and light (black and white) areas in the QR code pattern can be distributed in the best ratio. Format and version information: Generate format and version information and put it in the corresponding area.
[0069] QR code recognition includes positioning graphics, graying QR code information pixels, removing noise from QR code information pixels, binarizing QR code information pixels, QR code decoding, and error correction. Positioning graphics: First, find the detection graphics, which are the three squares on the QR code; the function of these three squares is to scan the graphics no matter which direction they are scanned; then determine the image of the QR code information through the positioning graphics and separators on the QR code; the positioning graphics determine the coordinates of the modules in the QR code symbol. The modules in the QR code are fixed, including correction graphics, version information, data, and error correction codes; the separator is to separate the detection graphics from the QR code information image. Graying QR code information pixels: The images captured by the terminal device are all in color, so the QR code is no exception. It is also in color, but except for black and white, other colors are very light; graying refers to identifying the QR code by the depth of color, that is, dark colors are treated as dark gray, light colors are treated as light gray, and other colors are removed. Remove the noise of the QR code information pixels: The camera sensor generates rough pixels when it receives light as a signal and outputs it. These rough pixels are interference factors that should not appear in the photo; noise refers to these rough pixels. Binarize the QR code information pixels: Binarization means setting the grayscale value of the pixels on the image to 0 or 255, that is, turning it into only black and white colors; the first step has been grayscaled to only dark gray and light gray. Now binarization is to turn dark gray into black and light gray into white. The QR code image is actually composed of binary 0 or 1, 0 represents white, and 1 represents black; when the QR code is binarized, the QR code image will be turned into a barcode with only black and white, and then converted into binary information according to an analytical formula or something (because the pixels are between 0-255, to convert them all to 0 or 255, it is estimated that some calculations are required, and then 0 is 0, and 255 becomes 1). QR code decoding and error correction: decode and correct the obtained binary information; the obtained binary information is generated by a certain encoding method of version format information, data and error correction code, so decoding is to decode and compare the version format information, data and error correction code; error correction is carried out at the same time as decoding, and the data is corrected.
[0070] Of course, in other implementations, the identification code of the target resource may also be a barcode, a one-dimensional code, a data matrix code, a PDF417 code, a color code, or a URL short link, etc., which is not limited here.
[0071] The following describes the process of the terminal device scanning the identification code of the target resource to obtain the resource information of the target resource. For example, when the current valid identification code of the target resource is the first identification code, the terminal device can obtain the resource information of the target resource by scanning the first identification code of the target resource.
[0072] The following takes cloud resource A as the target resource as an example.
[0073] Step 1: Splice the resource information of cloud resource A such as type and source in a certain format to obtain splicing information.
[0074] Step 2: Encrypt the splicing information to obtain a resource identification code.
[0075] It should be noted that the splicing information can be encrypted using the SM4 national secret algorithm. The SM4 national secret algorithm is a block cipher algorithm with a block length of 128 bits (i.e. 16 bytes, 4 words) and a key length of 128 bits (i.e. 16 bytes, 4 words). The encryption and decryption process of the SM4 national secret algorithm adopts a 32-round iterative mechanism (similar to DES and AES), and each round requires a round key (similar to DES and AES).
[0076] Among them, the SM4 national secret algorithm uses modulo 2 addition and cyclic shift as basic operations. The SM4 national secret algorithm uses the basic cryptographic components of S-box, nonlinear transformation τ, linear transformation component L, and synthetic transformation T. The SM4 national secret algorithm adopts a structure that iterates the basic round function; using the above basic cryptographic components, a round function can be constructed; the round function of the SM4 national secret algorithm is a cryptographic function that uses words as processing units. The SM4 national secret algorithm is a grouping algorithm; the data group length is 128 bits, and the key length is 128 bits; the encryption algorithm adopts a 32-round iterative structure, and each round uses a round key. The SM4 national secret algorithm is a concatenated operation, so the decryption algorithm has the same structure as the encryption algorithm, except that the order of using the round keys is reversed, and the decryption round key is the reverse order of the encryption round key. The SM4 national secret algorithm uses a 128-bit encryption key and a 32-round generation encryption structure. Each round of encryption uses a 32-bit round key, and a total of 32 round keys are used; therefore, a key expansion algorithm is required to generate 32 round keys from the encryption key. The SM4 national secret algorithm has been fully analyzed and tested by professional cryptographic organizations and can resist existing attacks such as differential attacks and linear attacks, so it is safe.
[0077] Step three: Generate a first character string, establish a mapping relationship between the first character string and the resource identification code, and store the mapping relationship between the first character string and the resource identification code.
[0078] Step 4: Generate a web-accessible identification code of cloud resource A based on the first character string.
[0079] Step 5: When the user uses the terminal device to scan the first identification code of cloud resource A, the first identification code of cloud resource A will be decoded to obtain the first character string corresponding to cloud resource A; then, based on the mapping relationship between the first character string and the resource identification code, the resource identification code corresponding to cloud resource A is determined; the resource identification code is decrypted to obtain the resource information of cloud resource A, and fed back to the terminal device, so that the user can obtain the resource information of cloud resource A through the terminal device.
[0080] Considering the security of resource information, after the user scans the code with the terminal device, the user's identity information and permission information will be verified. The authorized user can normally view the resource information of the target resource (such as detailed information, related information, etc.), and the unauthorized user cannot access the corresponding resource information. In addition, after the user scans the code with the terminal device, the current scanning user, scanning time, scanning location and other scanning behavior data will be automatically sensed and recorded.
[0081] When the target resource is created, a resource code with a unified format and uniqueness is generated according to the resource type, department and other information of the target resource. The resource code can be regarded as the unique identifier of the target resource. After the resource code is generated, the target resource is bound to the corresponding resource code for use, and the usage status of the resource code is recorded (such as unused, disabled, etc.). When the target resource is audited, disabled, deleted, or verified and parsed, the relevant update operations will be recorded according to the corresponding resource code, and the changes of the target resource can be easily tracked according to the corresponding resource code. The user can perform a reconciliation analysis on the use of the resource code and create a corresponding reconciliation plan. After the reconciliation plan is created, the analysis plan is pushed to the code reconciliation service. The code reconciliation service analyzes the issued unused resource code and generates an alarm by comparing the issued resource code and the target resource. Therefore, the present application provides a code generation method to realize the unified management of the access, use, tracking, perception, and reconciliation of the target resources of the entire site based on dynamic QR codes.
[0082] See also Figure 5 , Figure 5 1 is a schematic diagram of the structure of an embodiment of a code generating device provided by the present application. The code generating device 50 includes an acquisition module 51, a determination module 52 and a generation module 53. The acquisition module 51 is used to acquire the usage of the first identification code of the target resource; the determination module 52 is used to determine that the first identification code is invalid in response to the usage of the first identification code meeting the invalidation condition; the generation module 53 is used to generate a valid second identification code for the target resource; wherein, the first identification code and the second identification code can be scanned by the terminal device in a valid state to obtain the resource information of the target resource.
[0083] The expiration condition includes that the first identification code has been used or the first identification code has not been used for a preset time period.
[0084] The generating module 53 is used to generate a valid second identification code for the target resource, including: updating the first identification code to obtain the second identification code.
[0085] Among them, the first identification code is obtained based on the encoding of the first character string; the generation module 53 is used to update the first identification code to obtain the second identification code, including: generating a second character string; wherein there is at least one different character between the second character string and the first character string; encoding the second character string to obtain the second identification code.
[0086] The number of characters in the second character string is the same as that in the first character string; and / or the second character string and the first character string do not have the same characters.
[0087] The generating module 53 is used to generate the second string, including: selecting at least two characters from the character set; wherein the first string is generated by at least two characters in the character set, and at least one character in the first string is removed from the character set; and generating the second string based on the at least two characters selected from the character set.
[0088] The generating module 53 is further configured to remove at least one character in the second character string from the character set.
[0089] The generating module 53 is further used to establish a mapping relationship between the second character string and the resource information of the target resource.
[0090] The code generating device 50 further includes a detection module 54, which is used to obtain code scanning behavior data; perform anomaly detection on the code scanning behavior data to determine whether the terminal device has abnormal code scanning behavior.
[0091] Among them, the abnormal scanning behavior includes that the scanning location of the terminal device is located in an uncommon area; and / or, the target resources include at least two, the abnormal scanning behavior includes that the first scanning quantity of the terminal device meets the first quantity threshold, and the first scanning quantity is the number of identification codes of different target resources scanned; and / or, the abnormal scanning behavior includes that the number of times the identification code of the target resource is scanned meets the second quantity threshold.
[0092] Among them, the identification code includes a QR code.
[0093] See also Figure 6 , Figure 66 is a schematic diagram of the structure of an embodiment of an electronic device provided by the present application. The electronic device 60 includes a memory 61 and a processor 62 coupled to each other, and the processor 62 is used to execute program instructions stored in the memory 61 to implement the steps of any of the above code generation method embodiments. In a specific implementation scenario, the electronic device 60 may include but is not limited to: a microcomputer, a server, and in addition, the electronic device 60 may also include a mobile device such as a laptop computer and a tablet computer, which is not limited here.
[0094] Specifically, the processor 62 is used to control itself and the memory 61 to implement the steps of any of the above-mentioned code generation method embodiments. The processor 62 can also be called a CPU (Central Processing Unit). The processor 62 may be an integrated circuit chip with signal processing capabilities. The processor 62 can also be a general-purpose 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 general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. In addition, the processor 62 can be implemented by an integrated circuit chip.
[0095] See also Figure 7 , Figure 7 It is a schematic diagram of the structure of an embodiment of a computer-readable storage medium provided by the present application. The computer-readable storage medium 70 of the embodiment of the present application stores a program instruction 71, and when the program instruction 71 is executed, it implements the method provided by an embodiment of the code generation method of the present application and any non-conflicting combination. Among them, the program instruction 71 can form a program file and be stored in the above-mentioned computer-readable storage medium 70 in the form of a software product, so that a computer device (which can be a personal computer, a server, or a network device, etc.) executes all or part of the steps of each implementation method of the present application. The aforementioned computer-readable storage medium 70 includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a disk or an optical disk, or a terminal device such as a computer, a server, a mobile phone, and a tablet.
[0096] If the technical solution of this application involves personal information, the product using the technical solution of this application has clearly informed the personal information processing rules and obtained the individual's voluntary consent before processing the personal information. If the technical solution of this application involves sensitive personal information, the product using the technical solution of this application has obtained the individual's separate consent before processing the sensitive personal information, and at the same time meets the "explicit consent" requirement. For example, on personal information collection devices such as cameras, clear and prominent signs are set to inform that the personal information collection scope has been entered and personal information will be collected. If the individual voluntarily enters the collection scope, it is deemed that he or she agrees to the collection of his or her personal information; or on the device that processes personal information, the personal information processing rules are notified by obvious signs / information, and the individual's authorization is obtained through pop-up information or by asking the individual to upload his or her personal information; among them, the personal information processing rules may include information such as the personal information processor, the purpose of personal information processing, the processing method, and the type of personal information processed.
[0097] The above description is only an implementation method of the present application, and does not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly used in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. A code generation method, characterized in that: The method comprises: Obtain usage of the first identification code of the target resource; In response to the usage of the first identification code meeting an expiration condition, determining that the first identification code is invalid; Generate a valid second identification code for the target resource; wherein the first identification code and the second identification code, when valid, can be scanned by a terminal device to obtain resource information of the target resource.
2. The method according to claim 1, characterized in that The expiration condition includes that the first identification code has been used or the first identification code has not been used for a preset time period.
3. The method according to claim 1, characterized in that The generating a valid second identification code for the target resource comprises: The first identification code is updated to obtain the second identification code.
4. The method according to claim 3, characterized in that: The first identification code is obtained based on the first character string encoding; and the updating of the first identification code to obtain the second identification code includes: Generate a second character string; wherein the second character string and the first character string have at least one different character; The second character string is encoded to obtain the second identification code.
5. The method according to claim 4, characterized in that The second character string has the same number of characters as the first character string; And / or, the second character string and the first character string do not have the same characters.
6. The method according to claim 4, characterized in that The generating of the second character string comprises: Select at least two characters from a character set; wherein the first character string is generated by at least two characters in the character set, and at least one character in the first character string is removed from the character set; The second character string is generated based on at least two characters selected from the character set.
7. The method according to claim 6, characterized in that The method further comprises: At least one character in the second character string is removed from the character set.
8. The method according to claim 4, characterized in that The method further comprises: A mapping relationship between the second character string and the resource information of the target resource is established.
9. The method according to claim 1, characterized in that: The method further comprises: Get scanning behavior data; Anomaly detection is performed on the code scanning behavior data to determine whether the terminal device has abnormal code scanning behavior.
10. The method according to claim 9, characterized in that The abnormal code scanning behavior includes that the code scanning location of the terminal device is located in an unused area; And / or, the target resources include at least two, the abnormal code scanning behavior includes that the first code scanning quantity of the terminal device meets a first quantity threshold, and the first code scanning quantity is the number of identification codes of different target resources scanned; And / or, the abnormal scanning behavior includes that the identification code of the target resource is scanned a number of times that satisfies a second quantity threshold.
11. The method according to claim 1, characterized in that The identification code includes a QR code.
12. A code generating device, characterized in that: The device comprises: An acquisition module, used to acquire usage of the first identification code of the target resource; A determination module, configured to determine that the first identification code is invalid in response to the usage of the first identification code meeting an invalidation condition; A generation module is used to generate a valid second identification code for the target resource; wherein the first identification code and the second identification code, when in a valid state, can be scanned by a terminal device to obtain resource information of the target resource.
13. An electronic device, characterized in that: The electronic device comprises a processor and a memory, wherein the memory stores program instructions, and the program instructions can be executed to implement the code generation method according to any one of claims 1 to 11.
14. A computer-readable storage medium, characterized in that: The computer-readable storage medium is used to store program instructions, and the program instructions can be executed to implement the code generation method according to any one of claims 1 to 11.