Data encryption interaction method, device and readable medium
By preprocessing, encrypting, compressing and generating graphic codes on original data, the problem of low data encryption transmission efficiency in the existing technology is solved, and efficient and safe data interaction is achieved.
Patent Information
- Application Number
- CN202111195609.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-01
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2041-10-01
AI Technical Summary
Existing data encryption transmission methods have problems such as the risk of encrypted data being cracked and low efficiency, making it difficult to meet the needs of rapid development.
Data interaction is carried out by preprocessing, encrypting, compressing and generating graphic codes on the original data, using AES-128-ECB encryption and gzdeflate compression, using QR codes for data transmission, and decoding, decompressing and decrypting through code scanning. Implement data reception.
It improves the security and efficiency of data interaction, ensures the security of non-physical transmission, and greatly improves the efficiency of data transmission.
Smart Images

Figure CN114095203B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing, and in particular to a data encryption interaction method, device and readable medium. Background Art
[0002] There are many security risks in the transmission or interaction of existing data. In order to ensure the data security of the intranet and the extranet, the data is encrypted before transmission.
[0003] However, this method has the risk of encrypted data being cracked, and data transmission is cumbersome and inefficient, which does not meet the current needs of rapid development. Summary of the invention
[0004] The purpose of the present invention is to solve at least one of the technical problems existing in the prior art, and to provide a data encryption interaction method, device and readable medium to solve the deficiencies of the prior art.
[0005] The technical solution of the present invention includes a data encryption interaction method, which includes a sending method and a receiving method, and is characterized in that: the sending method includes: performing preprocessing on the original data to be sent to obtain a string of the original data; encrypting and compressing the string, and generating a corresponding graphic code and displaying it on a display device; the receiving method includes: obtaining the graphic code and performing decoding processing to obtain the string; decompressing and decrypting the string to complete data reception.
[0006] According to the data encryption interaction method, the original data to be sent is preprocessed to obtain a character string of the original data, including: converting the original data into a two-dimensional array with one-to-one correspondence between key values; traversing the two-dimensional array, querying and filtering illegal characters, and determining whether there is picture data. If there is picture data, converting the picture data into a base64 character string, splitting it into data fragments of 700 bytes each, and combining it into a fragment array according to the key value, saving it in the picture transmission queue, and replacing the source base64 character string according to the key value.
[0007] According to the data encryption interaction method, the character string is encrypted and compressed, and a corresponding graphic code is generated and displayed on a display device, including: encrypting a base64 character string by an AES-128-ECB encryption method, wherein the encryption algorithm is AES-128-ECB; compressing the encrypted base64 character string by gzdeflate; generating a corresponding graphic code from the character string compressed by gzdeflate, and displaying the graphic code on a display.
[0008] According to the data encryption interaction method, the graphic code is a two-dimensional code.
[0009] According to the data encryption interaction method, encrypting the base64 string by the AES-128-ECB encryption method also includes generating a key: obtaining the current system time and combining it into a time string; encrypting the time string by MD5; and using the first 10 bytes of the time string encrypted by MD5 as the key.
[0010] According to the data encryption interaction method, the graphic code is obtained and decoded to obtain the string, which includes: obtaining the graphic code through a code scanning device, decoding the graphic code, and obtaining a string in the json standard format; judging whether there is a picture key-value pair in the string, if so, it means that there is a picture to be transmitted, performing picture parsing, restoring and obtaining picture data; after receiving the picture data, parsing the json string to obtain a data object, and completing data reception.
[0011] According to the data encryption interaction method, the image parsing includes: judging the received character string, if a picture key-value pair is found, triggering a graphic code parsing event, decompressing the graphic code, calculating the secret key and decrypting it to obtain picture fragments and picture keywords; replacing the key values in the source data with the picture fragments and picture keywords to obtain a restored picture.
[0012] The technical solution of the present invention also includes a data encryption interaction device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and is characterized in that the processor implements any of the method steps described when executing the computer program.
[0013] The technical solution of the present invention also includes a computer-readable storage medium, which stores a computer program, and is characterized in that when the computer program is executed by a processor, any of the method steps described is implemented.
[0014] The beneficial effects of the present invention are: ensuring the security of non-physical transmission and greatly improving the efficiency of data interaction. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] The present invention is further described below in conjunction with the accompanying drawings and embodiments;
[0016] Figure 1 Shown is a flow chart according to an embodiment of the present invention.
[0017] Figure 2 FIG. 1 is a flowchart of data transmission according to an embodiment of the present invention.
[0018] Figure 3 Shown is a data transmission encryption flow chart according to an embodiment of the present invention.
[0019] Figure 4 FIG. 1 is a flowchart of data receiving according to an embodiment of the present invention.
[0020] Figure 5 Shown is a data receiving and decryption flow chart according to an embodiment of the present invention.
[0021] Figure 6 Shown is a diagram of an apparatus according to an embodiment of the present invention. DETAILED DESCRIPTION
[0022] This section will describe in detail the specific embodiments of the present invention. The preferred embodiments of the present invention are shown in the accompanying drawings. The purpose of the accompanying drawings is to supplement the description of the text part of the specification with graphics, so that people can intuitively and vividly understand each technical feature and the overall technical solution of the present invention, but it cannot be understood as a limitation on the scope of protection of the present invention.
[0023] In the description of the present invention, “several” means one or more, “more” means more than two, “greater than”, “less than”, “exceed”, etc. are understood as not including the number itself, and “above”, “below”, “within”, etc. are understood as including the number itself.
[0024] In the description of the present invention, the consecutive numbering of the method steps is for the convenience of review and understanding. Combined with the overall technical scheme of the present invention and the logical relationship between the various steps, adjusting the implementation order between the steps will not affect the technical effect achieved by the technical scheme of the present invention.
[0025] In the description of the present invention, unless otherwise clearly defined, words such as "setting" should be understood in a broad sense, and technicians in the relevant technical field can reasonably determine the specific meaning of the above words in the present invention in combination with the specific content of the technical solution.
[0026] Figure 1 The flowchart according to the embodiment of the present invention is shown. The technical solution of the present embodiment includes: the sending method includes the process of sending data and the process of receiving data.
[0027] The data transmission process includes: pre-processing the original data to be transmitted to obtain a character string of the original data; encrypting and compressing the character string, generating a corresponding graphic code and displaying it on a display device;
[0028] The method for receiving data includes: obtaining a graphic code and performing decoding processing to obtain a character string; decompressing and decrypting the character string to complete data reception.
[0029] In a preferred embodiment, the data flows of sending and receiving are both implemented by physically isolating the data through graphic codes, and the implementation devices corresponding to the sending flow and the receiving flow include a display device and a code scanning device.
[0030] Figure 2The data transmission flow chart according to the embodiment of the present invention is shown. The flow chart of this embodiment is as follows:
[0031] The original data is converted into a two-dimensional array with one key value corresponding to each other
[0032] Traverse the array, query and filter illegal characters, and determine whether there is image data
[0033] If there is image data, convert the image data into a base64 string and split it into data segments of 700 bytes each. Combine them into a fragment array according to the key value, save it to the image transmission queue, and replace the source base64 string according to the key value (the receiving end will receive the combined original image according to the key value).
[0034] Compile the processed raw data array into a standard JSON string
[0035] Encrypt the json string, the encryption algorithm is AES-128-ECB,
[0036] refer to Figure 3 , where the secret key generation process is:
[0037] 1). Get the current time and combine it into a string, such as: 202172711
[0038] 2). Encrypt the time string with MD5, such as: 33b10716c28d49bd9e1ac806f64a5bed
[0039] 3). Take the first 10 bytes as the secret key, such as: 33b10716c2
[0040] 6. The AES encrypted string is compressed by gzdeflate to improve transmission efficiency
[0041] The encrypted and compressed string is used to generate a QR code, which is displayed on the screen and read by the receiver through a decoder.
[0042] Figure 4 The data receiving flow chart according to the embodiment of the present invention is shown. The flow chart of this embodiment is as follows:
[0043] The decoder reads the QR code message and triggers the message parsing event
[0044] Decompress the message string through gzinflate to get the original encrypted data
[0045] Calculate the decryption key. The calculation process is referenced Figure 5 The process shown:
[0046] 1). Get the current time and combine it into a string, such as: 202172711
[0047] 2). Encrypt the time string with MD5, such as: 33b10716c28d49bd9e1ac806f64a5bed
[0048] 3). Take the first 10 bytes as the secret key, such as: 33b10716c2
[0049] 4. Decrypt the string using the secret key to get a string in the json standard format
[0050] Determine whether the string contains a picture key-value pair. If so, it means there is a picture to be transferred and wait for the next parsing.
[0051] Image parsing process:
[0052] Determine the source data, find the image key-value pair, and wait for the next round of QR code parsing event
[0053] Trigger the QR code parsing event, decompress the QR code, calculate the secret key and decrypt it to get the image fragment and image keywords
[0054] Replace the key value in the source data according to the fragment keyword and restore the image
[0055] After the picture data is received, the json string is parsed to obtain the data object, and the data reception is completed.
[0056] Figure 6 The device diagram according to an embodiment of the present invention is shown. The device includes a memory 100 and a processor 200, wherein the processor 200 stores a computer program, and the computer program is used to execute:
[0057] Sending data: pre-processing the original data to be sent to obtain a string of the original data; encrypting and compressing the string, generating a corresponding graphic code and displaying it on the display device; receiving data: obtaining the graphic code and performing decoding processing to obtain a string; decompressing and decrypting the string to complete data reception. The memory 100 is used to store data.
[0058] It should be appreciated that the method steps in the embodiments of the present invention can be implemented or implemented by computer hardware, a combination of hardware and software, or by computer instructions stored in a non-transitory computer readable memory. The method can use standard programming techniques. Each program can be implemented in a high-level process or object-oriented programming language to communicate with a computer system. However, if necessary, the program can be implemented in an assembly or machine language. In any case, the language can be a compiled or interpreted language. In addition, the program can be run on a programmed ASIC for this purpose.
[0059] Furthermore, the operations of the processes described herein may be performed in any suitable order unless otherwise indicated herein or otherwise clearly contradicted by context. The processes described herein (or variations and / or combinations thereof) may be performed under the control of one or more computer systems configured with executable instructions, and may be implemented as code (e.g., executable instructions, one or more computer programs, or one or more applications) that is executed collectively on one or more processors, by hardware, or a combination thereof. The computer program includes a plurality of instructions that may be executed by one or more processors.
[0060] Further, the method can be implemented in any type of computing platform that is operably connected to a suitable computer, including but not limited to a personal computer, a minicomputer, a mainframe, a workstation, a network or distributed computing environment, a separate or integrated computer platform, or in communication with a charged particle tool or other imaging device, etc. Various aspects of the present invention can be implemented in machine-readable code stored on a non-transitory storage medium or device, whether removable or integrated into a computing platform, such as a hard disk, an optical read and / or write storage medium, a RAM, a ROM, etc., so that it can be read by a programmable computer, and when the storage medium or device is read by the computer, it can be used to configure and operate the computer to perform the process described herein. In addition, the machine-readable code, or portions thereof, can be transmitted via a wired or wireless network. When such media includes instructions or programs that implement the steps described above in conjunction with a microprocessor or other data processor, the invention described herein includes these and other different types of non-transitory computer-readable storage media. When programmed according to the methods and techniques of the present invention, the present invention also includes the computer itself.
[0061] The computer program can be applied to input data to perform the functions described herein, thereby converting the input data to generate output data stored in a non-volatile memory. The output information can also be applied to one or more output devices such as consumers. In a preferred embodiment of the present invention, the converted data represents physical and tangible objects, including specific visual depictions of physical and tangible objects produced on consumers.
[0062] The embodiments of the present invention are described in detail above in conjunction with the accompanying drawings, but the present invention is not limited to the above embodiments, and various changes can be made within the knowledge scope of ordinary technicians in the technical field without departing from the purpose of the present invention.
Claims
1. A data encryption interaction method, the method comprising a sending method and a receiving method, characterized in that: The sending method comprises: Preprocess the original data to obtain the character string of the original data; Encrypting and compressing the character string, generating a corresponding graphic code and displaying it on a display device; The receiving method comprises: Obtain the graphic code and perform decoding processing to obtain the character string; Decompressing and decrypting the character string to complete data reception; The implementation devices corresponding to the sending method and the receiving method both include a display device and a code scanning device; The original data to be sent is preprocessed to obtain a character string of the original data including: Convert the original data into a two-dimensional array with one key value to another; Traverse the two-dimensional array, query and filter illegal characters, and determine whether there is image data If there is image data, convert the image data into a base64 string, split it into data segments of 700 bytes each, combine it into a segment array according to the key value, save it in the image transmission queue, and replace the source base64 string according to the key value; The step of encrypting and compressing the character string, generating a corresponding graphic code and displaying the code on a display device comprises: Encrypt the base64 string using the AES-128-ECB encryption method, where the encryption algorithm is AES-128-ECB; Compress the encrypted base64 string using gzdeflate; Generate a corresponding graphic code from the character string compressed by gzdeflate, and display the graphic code on a display; The graphic code is a QR code; Encrypting the base64 string using the AES-128-ECB encryption method also includes generating a key: Get the current system time and combine it into a time string; Perform MD5 encryption on the time character string; The first 10 bytes of the time string encrypted by MD5 are used as a secret key; The obtaining of the graphic code and performing decoding processing to obtain the character string includes: Obtain the graphic code through a code scanning device, decode the graphic code, and obtain a string in a json standard format; Determine whether the string contains a picture key-value pair. If so, it indicates that a picture needs to be transmitted. Perform picture parsing, restore and obtain picture data. After receiving the image data, parse the json string to get the data object and complete the data reception; The picture analysis includes: Determine the received string, if a picture key-value pair is found, trigger a graphic code parsing event, decompress the graphic code, calculate the secret key and decrypt it, and obtain the picture fragment and picture keyword; The image fragment and the image keyword replace the key value in the source data to obtain the restored image.
2. A data encryption interaction device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method steps of claim 1 are implemented.
3. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method steps of claim 1 are implemented.
