Two-dimensional code generation method and device in weak network environment, equipment and storage medium
By using local encrypted stored offline data packets in the airport's QR code generation system, the limitations of QR code generation in weak network environments are solved, ensuring service availability in signal blind spots or network failures , improves passenger experience and operational efficiency.
Patent Information
- Application Number
- CN202411004149.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-25
- Publication Date
- 2024-12-06
AI Technical Summary
In the case of signal blind spots or network failures in the existing technology, QR code generation and verification services fail, affecting passenger experience and airport operation efficiency, mainly due to the limitations of QR code generation in the network environment.
When receiving the QR code generation instruction, determine the current network environment. When it is a weak network environment, obtain the local encrypted offline data packets, including metadata segments, key segments, code value segments and verification segments, and The target QR code is generated based on these data for verification by scanning the code device; in a good network environment, requests are distributed asynchronously to update offline data packets to ensure the accuracy and reliability of QR code generation.
In a weak network environment, the limitations of QR code generation are effectively solved, ensuring the availability of QR code generation and verification services in airport signal blind spots or network failures, and improving passenger experience and airport operation efficiency.
Smart Images

Figure CN119089926A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a method, device, equipment and storage medium for generating a two-dimensional code in a weak network environment. Background Art
[0002] At present, the application of QR code generation technology in the aviation field has greatly promoted the digital transformation of airports and convenient travel for passengers. However, most QR code generation and verification processes are highly dependent on stable network connections. In the case of signal blind spots or network failures at airports, cloud-based QR code generation and verification services fail, thus affecting passenger experience and airport operating efficiency.
[0003] Therefore, there is an urgent need for a method for generating a two-dimensional code in a weak network environment, which can solve the limitations of the network environment on the generation of two-dimensional codes in the prior art. Summary of the invention
[0004] The main purpose of the present invention is to provide a method, device, equipment and storage medium for generating a two-dimensional code in a weak network environment, aiming to solve the technical problem of network environment restrictions on two-dimensional code generation in the prior art.
[0005] To achieve the above object, the present invention provides a method for generating a two-dimensional code in a weak network environment, the method comprising the following steps:
[0006] Upon receiving a QR code generation instruction, determining the current network environment;
[0007] When the current network environment is a weak network environment, obtaining a locally encrypted and stored offline data packet, wherein the locally encrypted and stored offline data packet includes a metadata segment, a secret key segment, a code value data segment, and a check segment;
[0008] A target two-dimensional code is generated according to the locally encrypted and stored offline data packet, and the target two-dimensional code is displayed so that a code scanning device can verify the target two-dimensional code.
[0009] Optionally, after the step of determining the current network environment when receiving the QR code generation instruction, the method further includes:
[0010] When the current network environment is a good network environment, asynchronously distribute a target QR code generation request and an offline data package download update request to the server, so that the server generates a target QR code value according to the target QR code and downloads and / or updates an initial offline data package according to the offline data package download update request;
[0011] Receive the target two-dimensional code value, generate a target two-dimensional code based on the target two-dimensional code value, and display the target two-dimensional code so that a scanning device can verify the target two-dimensional code;
[0012] The initial offline data packet is obtained, and the initial offline data packet is encrypted according to a preset encryption method to obtain a locally encrypted and stored offline data packet.
[0013] Optionally, the step of encrypting the initial offline data packet according to a preset encryption method to obtain a locally encrypted and stored offline data packet includes:
[0014] Classifying the data in the initial offline data packet to obtain a classification result;
[0015] Based on the classification result, different categories of data in the initial offline data packet are encrypted respectively according to a preset encryption method to obtain a locally encrypted and stored offline data packet.
[0016] Optionally, the classification result includes metadata, key data, code value data and verification data; the metadata includes the version number, timestamp and encryption identifier in the initial offline data packet; the key data includes the decryption key in the initial offline data packet; the code value data includes the QR code business content information in the initial offline data packet; the verification data includes the metadata, the key data and the code value data.
[0017] Optionally, the step of encrypting different categories of data in the initial offline data packet respectively according to a preset encryption method based on the classification result to obtain a locally encrypted and stored offline data packet includes:
[0018] Performing SM4 encryption on the metadata and the code value data respectively to obtain a metadata segment and a code value data segment;
[0019] Perform SM2 public key encryption on the secret key data to obtain a secret key segment;
[0020] Performing SM3 encryption on the verification data to obtain a verification segment;
[0021] The metadata segment, the secret key segment, the code value data segment and the verification segment are encoded to obtain a locally encrypted and stored offline data packet.
[0022] Optionally, the method is applied to a code scanning device, and the method includes:
[0023] Scan the target QR code to obtain the scanned code information of the target QR code;
[0024] Use the SM2 private key to decrypt the key segment in the scanned code information to obtain the decryption key;
[0025] Decrypting the metadata segment and the code value data segment in the scanned code information based on the decryption key to obtain decrypted metadata and decrypted code value data;
[0026] Performing SM3 encryption on the decrypted metadata and the decrypted code value data to obtain target verification data;
[0027] The target verification data is compared with the verification segment in the scan code information, and whether the target two-dimensional code verification is passed is determined based on the comparison result.
[0028] In addition, to achieve the above purpose, the present invention also proposes a two-dimensional code generation device in a weak network environment, the device is applied to a client, and the device includes:
[0029] A network determination module, used to determine the current network environment when receiving a QR code generation instruction;
[0030] A data acquisition module, used for acquiring a locally encrypted and stored offline data packet when the current network environment is a weak network environment, wherein the locally encrypted and stored offline data packet includes a metadata segment, a secret key segment, a code value data segment, and a check segment;
[0031] The QR code generation module is used to generate a target QR code according to the offline data packet stored in local encryption, and display the target QR code so that a code scanning device can verify the target QR code.
[0032] In addition, to achieve the above purpose, the present invention also proposes a two-dimensional code generation device in a weak network environment, the device is applied to a code scanning device, and the device includes:
[0033] An information scanning module is used to scan a target QR code and obtain the scanned code information of the target QR code;
[0034] A first decoding module, used to decrypt the key segment in the scanned code information using the SM2 private key to obtain a decryption key;
[0035] A second decoding module is used to decrypt the metadata segment and the code value data segment in the scanned code information based on the decryption key to obtain the decrypted metadata and the decrypted code value data;
[0036] A data encryption module, used for performing SM3 encryption on the decrypted metadata and the decrypted code value data to obtain target verification data;
[0037] The information verification module is used to compare the target verification data with the verification segment in the scanned code information, and determine whether the target two-dimensional code verification has passed according to the comparison result.
[0038] In addition, to achieve the above-mentioned purpose, the present invention also proposes a QR code generation device in a weak network environment, the device comprising: a memory, a processor, and a QR code generation program in a weak network environment stored in the memory and run on the processor, the QR code generation program in a weak network environment being configured to implement the steps of the QR code generation method in a weak network environment as described above.
[0039] In addition, to achieve the above-mentioned purpose, the present invention also proposes a storage medium, which stores a QR code generation program in a weak network environment. When the QR code generation program in a weak network environment is executed by a processor, the steps of the QR code generation method in a weak network environment as described above are implemented.
[0040] The present invention discloses a method for generating a two-dimensional code in a weak network environment, the method comprising: upon receiving a two-dimensional code generation instruction, determining the current network environment; when the current network environment is a weak network environment, obtaining a locally encrypted and stored offline data packet, the locally encrypted and stored offline data packet including a metadata segment, a secret key segment, a code value data segment, and a verification segment; generating a target two-dimensional code according to the locally encrypted and stored offline data packet, and displaying the target two-dimensional code so that a code scanning device can verify the target two-dimensional code. Since the present invention obtains a locally encrypted and stored offline data packet when the current network environment is a weak network environment, and then generates a target two-dimensional code according to the locally encrypted and stored offline data packet, compared to the prior art, the present invention effectively solves the technical problem of network environment restrictions on two-dimensional code generation in the case of signal blind spots or network failures at airports. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] Figure 1 This is a flow chart of a first embodiment of a method for generating a two-dimensional code in a weak network environment of the present invention;
[0042] Figure 2 It is a schematic diagram of the structure of the offline data packet in the present invention;
[0043] Figure 3 A schematic diagram of a process of generating a target QR code according to an offline data packet in the present invention;
[0044] Figure 4 This is a flow chart of a second embodiment of a method for generating a two-dimensional code in a weak network environment of the present invention;
[0045] Figure 5 It is a structural block diagram of the first embodiment of the two-dimensional code generation device in a weak network environment of the present invention;
[0046] Figure 6 It is a structural block diagram of the second embodiment of the two-dimensional code generation device in a weak network environment of the present invention;
[0047] Figure 7It is a structural schematic diagram of a QR code generating device in a weak network environment of the hardware operating environment involved in an embodiment of the present invention.
[0048] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0049] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.
[0050] The embodiment of the present invention provides a method for generating a two-dimensional code in a weak network environment. Figure 1 , Figure 1 It is a flowchart of the first embodiment of the method for generating a two-dimensional code in a weak network environment of the present invention.
[0051] In this embodiment, the method for generating a two-dimensional code in a weak network environment is applied to a client, and the method includes the following steps:
[0052] Step S10: upon receiving the QR code generation instruction, determining the current network environment.
[0053] It should be noted that the executor of this embodiment can be a client used to generate an airport pass QR code. The client can be a computer server device with data processing, network communication and program running functions, such as a smart phone, smart watch, tablet computer, etc., or an electronic device that can realize the above functions, a QR code generation device in a weak network environment, etc.
[0054] It should be understood that the current network environment can include a weak network environment and a good network environment. A weak network environment mainly refers to a network environment with unstable network connection, low signal strength, small bandwidth or high network latency. In this environment, the performance of network applications and user experience will be significantly affected. A good network environment refers to a network environment with stable network connection, strong signal, sufficient bandwidth, low latency and extremely low packet loss rate. In this environment, users can enjoy a smooth, fast and uninterrupted network experience, whether browsing the web, watching videos, playing online games or transferring large files. Operations can be well supported.
[0055] Step S20: When the current network environment is a weak network environment, obtain a locally encrypted and stored offline data packet, wherein the locally encrypted and stored offline data packet includes a metadata segment, a secret key segment, a code value data segment, and a verification segment.
[0056] It should be noted that after step S10, steps S101 to S103 are also included:
[0057] Step S101: When the current network environment is a good network environment, asynchronously distribute a target QR code generation request and an offline data package download update request to the server, so that the server generates a target QR code value according to the target QR code and downloads and / or updates the initial offline data package according to the offline data package download update request.
[0058] Step S102: receiving the target two-dimensional code value, generating a target two-dimensional code based on the target two-dimensional code value, and displaying the target two-dimensional code so that a scanning device can verify the target two-dimensional code.
[0059] Step S103: Acquire the initial offline data packet, and encrypt the initial offline data packet according to a preset encryption method to obtain a locally encrypted and stored offline data packet.
[0060] It should be noted that in order to enhance the security of airport QR code access, the data in the initial offline data packet can be classified to obtain a classification result; based on the classification result, different categories of data in the initial offline data packet are encrypted separately according to a preset encryption method to obtain a locally encrypted and stored offline data packet.
[0061] It needs to be explained that the classification result includes metadata, key data, code value data and verification data; the metadata includes the version number, timestamp and encryption identifier in the initial offline data packet; the key data includes the decryption key in the initial offline data packet; the code value data includes the QR code business content information in the initial offline data packet; the verification data includes the metadata, the key data and the code value data.
[0062] In a specific implementation, the metadata and the code value data can be encrypted by SM4 respectively to obtain a metadata segment and a code value data segment; the key data can be encrypted by SM2 public key to obtain a key segment; the verification data can be encrypted by SM3 to obtain a verification segment; the metadata segment, the key segment, the code value data segment and the verification segment can be encoded to obtain a locally encrypted and stored offline data packet.
[0063] For example, refer to Figure 2 , Figure 2It is a schematic diagram of the structure of the offline data packet in the present invention. In the figure, the offline data packet stored in local encryption includes a metadata segment, a key segment, a code value data segment and a check segment. Among them, the metadata segment contains a version number, a generation timestamp (i.e., a timestamp) and an encryption algorithm identifier (i.e., an encryption identifier); the key segment contains an SM4 symmetric key (i.e., a decryption key corresponding to the encryption algorithm), and the key segment is obtained after encryption with the SM2 public key; the code value data segment includes the QR code service content information (i.e., code value data), and the code value data segment is obtained after encryption with the SM4 symmetric key; the check segment includes metadata, key data and code value data, and the check segment can be obtained after encryption with the SM3 hash value.
[0064] refer to Figure 3 , Figure 3 yes Figure 3 The present invention is a flow chart of generating a target QR code according to an offline data packet. In the figure, after the client receives the QR code generation instruction, it goes through metadata segment preparation and key preparation (preparing a decryption key); the decryption key is encrypted by SM2 public key to form a key segment; the code value data is encrypted by SM4 to form a code value segment; then the original value of the metadata segment (i.e. metadata) + the original value of the key segment (i.e. key data) + the original value of the code value data segment (i.e. code value data) are encrypted by SM3 hash value to obtain a verification segment; the metadata segment, the key segment, the code value data segment and the verification segment are encoded to obtain a locally encrypted and stored offline data packet, and finally the target QR code can be generated according to the locally encrypted and stored offline data packet.
[0065] Step S30: Generate a target QR code according to the locally encrypted and stored offline data packet, and display the target QR code so that a code scanning device can verify the target QR code.
[0066] This embodiment is applied to the client, and discloses that when receiving a QR code generation instruction, the current network environment is determined; when the current network environment is a weak network environment, a locally encrypted and stored offline data packet is obtained, and the locally encrypted and stored offline data packet includes a metadata segment, a secret key segment, a code value data segment, and a verification segment; a target QR code is generated according to the locally encrypted and stored offline data packet, and the target QR code is displayed so that the scanning device can verify the target QR code. Since this embodiment obtains a locally encrypted and stored offline data packet when the current network environment is a weak network environment, and then generates a target QR code according to the locally encrypted and stored offline data packet, compared with the prior art, this embodiment effectively solves the technical problem of network environment restrictions on QR code generation in the case of signal blind spots or network failures at airports.
[0067] refer to Figure 4 , Figure 4This is a flow chart of the second embodiment of the method for generating a two-dimensional code in a weak network environment of the present invention. Figure 1 The embodiment shown provides a second embodiment of the method for generating a two-dimensional code in a weak network environment of the present invention.
[0068] In this embodiment, the method for generating a two-dimensional code in a weak network environment is applied to a code scanning device, and the method for generating a two-dimensional code in a weak network environment includes the following steps:
[0069] Step S40: Scan the target two-dimensional code to obtain the scanning information of the target two-dimensional code.
[0070] Step S50: Use the SM2 private key to decrypt the key segment in the scanned code information to obtain a decryption key.
[0071] It should be noted that, since the key segment is obtained by encrypting the key data with the SM2 public key, and the key data includes the decryption key, the SM2 private key can be used to decrypt the key segment in the scanned code information to obtain the decryption key.
[0072] Step S60: decrypt the metadata segment and the code value data segment in the scanned code information based on the decryption key to obtain decrypted metadata and decrypted code value data.
[0073] It should be understood that since the metadata segment and the code value data segment are obtained after the metadata and code value data are encrypted by SM4 respectively, the above-mentioned decryption key is the decryption key corresponding to SM4. Therefore, the metadata segment and code value data segment in the scanned code information can be decrypted based on the decryption key to obtain the decrypted metadata and decrypted code value data.
[0074] Step S70: Perform SM3 encryption on the decrypted metadata and the decrypted code value data to obtain target verification data.
[0075] Step S80: Compare the target verification data with the verification segment in the scan code information, and determine whether the target two-dimensional code verification has passed based on the comparison result.
[0076] It should be noted that if the comparison result is that the target verification data is consistent with the verification segment in the scanned code information, it means that the target QR code verification has passed; if the comparison result is that the target verification data is inconsistent with the verification segment in the scanned code information, it means that the target QR code verification has failed.
[0077] This embodiment is applied to a code scanning device, and discloses scanning a target QR code to obtain the scanned code information of the target QR code; using the SM2 private key to decrypt the key segment in the scanned code information to obtain the decryption key; decrypting the metadata segment and the code value data segment in the scanned code information based on the decryption key to obtain the decrypted metadata and the decrypted code value data; SM3 encrypting the decrypted metadata and the decrypted code value data to obtain the target verification data; comparing the target verification data with the verification segment in the scanned code information, and judging whether the target QR code verification has passed according to the comparison result. Compared with the prior art, this embodiment performs offline verification on the target QR code, which effectively improves the passenger experience and airport operation efficiency.
[0078] In addition, an embodiment of the present invention also proposes a storage medium, which stores a QR code generation program in a weak network environment. When the QR code generation program in a weak network environment is executed by a processor, the steps of the QR code generation method in a weak network environment as described above are implemented.
[0079] Reference Figure 5 , Figure 5 This is a structural block diagram of the first embodiment of the two-dimensional code generation device in a weak network environment of the present invention.
[0080] like Figure 5 As shown, the device for generating a two-dimensional code in a weak network environment proposed in an embodiment of the present invention is applied to a client, and the device includes: a network determination module 501, a data acquisition module 502 and a two-dimensional code generation module 503.
[0081] The network determination module 501 is used to determine the current network environment when receiving a QR code generation instruction.
[0082] The data acquisition module 502 is used to acquire a locally encrypted and stored offline data packet when the current network environment is a weak network environment. The locally encrypted and stored offline data packet includes a metadata segment, a key segment, a code value data segment and a verification segment.
[0083] The two-dimensional code generation module 503 is used to generate a target two-dimensional code according to the offline data packet stored in local encryption, and display the target two-dimensional code so that a scanning device can verify the target two-dimensional code.
[0084] The embodiment of the device is applied to the client, and discloses that when receiving a QR code generation instruction, the current network environment is determined; when the current network environment is a weak network environment, a locally encrypted and stored offline data packet is obtained, and the locally encrypted and stored offline data packet includes a metadata segment, a secret key segment, a code value data segment, and a verification segment; a target QR code is generated according to the locally encrypted and stored offline data packet, and the target QR code is displayed so that the scanning device can verify the target QR code. Since the embodiment of the device obtains the locally encrypted and stored offline data packet when the current network environment is a weak network environment, and then generates the target QR code according to the locally encrypted and stored offline data packet, compared with the prior art, the embodiment of the device effectively solves the technical problem of the network environment restricting the generation of QR codes in the case of signal blind spots or network failures at airports.
[0085] Based on the first embodiment of the two-dimensional code generation device under a weak network environment of the present invention, a second embodiment of the two-dimensional code generation device under a weak network environment of the present invention is proposed. Figure 6 , Figure 6 A structural block diagram of the second embodiment of the two-dimensional code generation device in a weak network environment of the present invention.
[0086] like Figure 6 As shown, the two-dimensional code generation device in a weak network environment proposed in an embodiment of the present invention is applied to a code scanning device, and the device includes: an information scanning module 601, a first decoding module 602, a second decoding module 603, a data encryption module 604 and an information verification module 605.
[0087] The information scanning module 601 is used to scan the target two-dimensional code to obtain the scanning information of the target two-dimensional code.
[0088] The first decoding module 602 is used to use the SM2 private key to decrypt the key segment in the scanned code information to obtain a decryption key.
[0089] The second decoding module 603 is used to decrypt the metadata segment and the code value data segment in the scanned code information based on the decryption key to obtain the decrypted metadata and the decrypted code value data.
[0090] The data encryption module 604 is used to perform SM3 encryption on the decrypted metadata and the decrypted code value data to obtain target verification data.
[0091] The information verification module 605 is used to compare the target verification data with the verification segment in the scanned code information, and determine whether the target two-dimensional code verification has passed according to the comparison result.
[0092] The embodiment of the device is applied to a code scanning device, and discloses scanning a target QR code to obtain the scanned code information of the target QR code; decrypting the key segment in the scanned code information using the SM2 private key to obtain the decryption key; decrypting the metadata segment and the code value data segment in the scanned code information based on the decryption key to obtain the decrypted metadata and the decrypted code value data; SM3 encrypting the decrypted metadata and the decrypted code value data to obtain the target verification data; comparing the target verification data with the verification segment in the scanned code information, and judging whether the target QR code verification has passed according to the comparison result. Compared with the prior art, the embodiment of the device performs offline verification on the target QR code, which effectively improves the passenger experience and airport operation efficiency.
[0093] Other embodiments or specific implementations of the two-dimensional code generation device in a weak network environment of the present invention can refer to the above-mentioned method embodiments, which will not be repeated here.
[0094] The present application provides a two-dimensional code generation device in a weak network environment, and the two-dimensional code generation device in a weak network environment includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the two-dimensional code generation method in the weak network environment in the above-mentioned embodiment one.
[0095] Reference below Figure 7 , which shows a schematic diagram of the structure of a two-dimensional code generating device in a weak network environment suitable for implementing the embodiment of the present application. The two-dimensional code generating device in a weak network environment in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 7 The QR code generating device in a weak network environment shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0096] like Figure 7As shown, the two-dimensional code generating device in a weak network environment may include a processing device 1001 (such as a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM: Read Only Memory) 1002 or the program loaded from the storage device 1003 to the random access memory (RAM: Random Access Memory) 1004. In RAM1004, various programs and data required for the operation of the two-dimensional code generating device in a weak network environment are also stored. The processing device 1001, ROM1002 and RAM1004 are connected to each other via a bus 1005. The input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems can be connected to the I / O interface 1006: input devices 1007 including, for example, a touch screen, a touchpad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; output devices 1008 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; storage devices 1003 including, for example, a magnetic tape, a hard disk, etc.; and communication devices 1009. The communication device 1009 can allow the two-dimensional code generation device in a weak network environment to communicate wirelessly or wired with other devices to exchange data. Although the figure shows a two-dimensional code generation device in a weak network environment with various systems, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems may be implemented or provided alternatively.
[0097] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.
[0098] The two-dimensional code generation device in a weak network environment provided by the present application adopts the two-dimensional code generation method in a weak network environment in the above embodiment, which can solve the technical problem of the network environment limiting the generation of two-dimensional codes in the prior art. Compared with the prior art, the beneficial effects of the two-dimensional code generation device in a weak network environment provided by the present application are the same as the beneficial effects of the two-dimensional code generation method in a weak network environment provided by the above embodiment, and the other technical features of the two-dimensional code generation device in a weak network environment are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.
[0099] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.
[0100] 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.
[0101] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or system. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or system including the element.
[0102] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0103] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as a read-only memory / random access memory, a magnetic disk, or an optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present invention.
[0104] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A method for generating a QR code in a weak network environment, characterized in that: The method is applied to a client, and the method comprises: Upon receiving a QR code generation instruction, determining the current network environment; When the current network environment is a weak network environment, obtaining a locally encrypted and stored offline data packet, wherein the locally encrypted and stored offline data packet includes a metadata segment, a secret key segment, a code value data segment, and a check segment; A target two-dimensional code is generated according to the locally encrypted and stored offline data packet, and the target two-dimensional code is displayed so that a code scanning device can verify the target two-dimensional code.
2. The method for generating a two-dimensional code in a weak network environment as claimed in claim 1, characterized in that: After the step of determining the current network environment upon receiving the QR code generation instruction, the method further includes: When the current network environment is a good network environment, asynchronously distribute a target QR code generation request and an offline data package download update request to the server, so that the server generates a target QR code value according to the target QR code and downloads and / or updates an initial offline data package according to the offline data package download update request; Receive the target two-dimensional code value, generate a target two-dimensional code based on the target two-dimensional code value, and display the target two-dimensional code so that a scanning device can verify the target two-dimensional code; The initial offline data packet is obtained, and the initial offline data packet is encrypted according to a preset encryption method to obtain a locally encrypted and stored offline data packet.
3. The method for generating a two-dimensional code in a weak network environment as claimed in claim 2, characterized in that: The step of encrypting the initial offline data packet according to a preset encryption method to obtain a locally encrypted and stored offline data packet includes: Classifying the data in the initial offline data packet to obtain a classification result; Based on the classification result, different categories of data in the initial offline data packet are encrypted respectively according to a preset encryption method to obtain a locally encrypted and stored offline data packet.
4. The method for generating a two-dimensional code in a weak network environment as claimed in claim 3, characterized in that: The classification result includes metadata, key data, code value data and verification data; the metadata includes the version number, timestamp and encryption identifier in the initial offline data packet; the key data includes the decryption key in the initial offline data packet; the code value data includes the two-dimensional code business content information in the initial offline data packet; the verification data includes the metadata, the key data and the code value data.
5. The method for generating a two-dimensional code in a weak network environment as claimed in claim 3, characterized in that: The step of encrypting different categories of data in the initial offline data packet according to a preset encryption method based on the classification result to obtain a locally encrypted and stored offline data packet includes: Performing SM4 encryption on the metadata and the code value data respectively to obtain a metadata segment and a code value data segment; Perform SM2 public key encryption on the secret key data to obtain a secret key segment; Performing SM3 encryption on the verification data to obtain a verification segment; The metadata segment, the secret key segment, the code value data segment and the verification segment are encoded to obtain a locally encrypted and stored offline data packet.
6. A method for generating a QR code in a weak network environment, characterized in that: The method is applied to a code scanning device, and the method includes: Scan the target QR code to obtain the scanned code information of the target QR code; Use the SM2 private key to decrypt the key segment in the scanned code information to obtain the decryption key; Decrypting the metadata segment and the code value data segment in the scanned code information based on the decryption key to obtain decrypted metadata and decrypted code value data; Performing SM3 encryption on the decrypted metadata and the decrypted code value data to obtain target verification data; The target verification data is compared with the verification segment in the scan code information, and whether the target two-dimensional code verification is passed is determined based on the comparison result.
7. A two-dimensional code generation device in a weak network environment, characterized in that: The device is applied to a client, and comprises: A network determination module, used to determine the current network environment when receiving a QR code generation instruction; A data acquisition module, used for acquiring a locally encrypted and stored offline data packet when the current network environment is a weak network environment, wherein the locally encrypted and stored offline data packet includes a metadata segment, a secret key segment, a code value data segment, and a check segment; The QR code generation module is used to generate a target QR code according to the offline data packet stored in local encryption, and display the target QR code so that a code scanning device can verify the target QR code.
8. A two-dimensional code generation device in a weak network environment, characterized in that: The device is applied to a code scanning device, and the device comprises: An information scanning module is used to scan a target QR code and obtain the scanned code information of the target QR code; A first decoding module, used to decrypt the key segment in the scanned code information using the SM2 private key to obtain a decryption key; A second decoding module is used to decrypt the metadata segment and the code value data segment in the scanned code information based on the decryption key to obtain the decrypted metadata and the decrypted code value data; A data encryption module, used for performing SM3 encryption on the decrypted metadata and the decrypted code value data to obtain target verification data; The information verification module is used to compare the target verification data with the verification segment in the scanned code information, and determine whether the target two-dimensional code verification has passed according to the comparison result.
9. A QR code generating device in a weak network environment, characterized in that: The device includes: a memory, a processor, and a two-dimensional code generation program in a weak network environment stored in the memory and executable on the processor, wherein the two-dimensional code generation program in a weak network environment is configured to implement the steps of the two-dimensional code generation method in a weak network environment as described in any one of claims 1 to 7.
10. A storage medium, characterized in that: The storage medium stores a two-dimensional code generation program in a weak network environment, and when the two-dimensional code generation program in a weak network environment is executed by a processor, the steps of the two-dimensional code generation method in a weak network environment as described in any one of claims 1 to 7 are implemented.
