Data encryption method, encryption device and computer readable storage medium

By generating and encrypting random numbers to combine to form an encryption key, the problem of key leakage when front-end applications transmit encrypted data is solved, and the effect of improving transmission security is achieved.

CN119254467AActive Publication Date: 2025-01-03金邦达有限公司
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202411283464.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-13
Publication Date
2025-01-03
Estimated Expiration
2044-09-13

AI Technical Summary

Technical Problem

When front-end applications transmit encrypted data, random keys are easily leaked, resulting in insecure data encryption and reducing the security of the front-end.

Method used

By generating two random numbers, the temporary key is generated and encrypted, the encryption key is intercepted and combined to form an encryption key. Only the random number and encryption algorithm type are transmitted during transmission. The front-end device organizes decryption based on the random numbers and increases the acquisition of the encryption key. Difficulty, improve transmission security.

Benefits of technology

The encryption key fragment is not included during the transmission process, which improves the security of data encryption, enhances the difficulty of protection of front-end data, and prevents key leakage.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119254467A_ABST
    Figure CN119254467A_ABST
Patent Text Reader

Abstract

The invention provides a data encryption method, an encryption device and a computer readable storage medium. The method comprises the following steps: generating a first random number, generating a first temporary key, generating a second random number and generating a second temporary key; encrypting the first random number and the first temporary key to generate a first ciphertext, and encrypting the second random number and the second temporary key to generate a second ciphertext; intercepting a plurality of segmented ciphertexts from the first ciphertext and the second ciphertext according to a preset interception mode, and combining the plurality of segmented ciphertexts to generate an encryption key; encrypting the front-end data according to the encryption key and the encryption algorithm to generate original ciphertext data; the first random number, the second random number, the encryption algorithm type and the original ciphertext data are combined to generate final ciphertext data, and the final ciphertext data are sent to the front-end device; and after receiving the final ciphertext data, the front-end device organizes the encryption key to decrypt the original ciphertext data according to the first random number and the second random number. According to the method, the encryption security can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data processing, and in particular to a data encryption method, an encryption device and a computer-readable storage medium. Background Art

[0002] In modern web development, front-end applications need to process a large amount of sensitive data and algorithmic data. However, the front-end code can be easily decompiled and analyzed, resulting in the leakage of sensitive data or algorithmic data, which will significantly reduce the security of the front-end and may cause a series of security issues.

[0003] Generally speaking, for front-end data, traditional encryption technologies such as symmetric keys are generally used for encryption, or obfuscation technology is used to improve the security of front-end data. However, the keys of traditional encryption methods are easily leaked, resulting in front-end data leakage.

[0004] An existing data encryption method is to obtain at least two pre-configured fixed key segments from a local; determine the permutation and combination order of at least two fixed key segments according to a randomly generated random number, and permutate and combine at least two fixed key segments according to the permutation and combination order to obtain a combined fixed key; randomly generate at least one random key segment; determine the embedding position of at least one random key segment in the combined fixed key according to the random number, and embed at least one random key segment into the combined fixed key according to the embedding position to obtain a complete key to be used; use the complete key to encrypt the data to be encrypted to obtain encrypted data for transmission. When this encryption method needs to transmit the random key segment when transmitting the encrypted data, the key segment is easily leaked during transmission, resulting in insecure data encryption. Summary of the invention

[0005] The first object of the present invention is to provide a data encryption method for improving transmission security.

[0006] The second object of the present invention is to provide a data encryption method for implementing the above data encryption method.

[0007] A third object of the present invention is to provide a computer-readable storage medium to which the above data encryption method is applied.

[0008] To achieve the first purpose of the present invention, the present invention provides a method for data encryption, which includes: generating a first random number, generating a first temporary key through the first random number; generating a second random number, generating a second temporary key through the second random number; encrypting the first temporary key with the first random number to generate a first ciphertext, encrypting the second temporary key with the second random number to generate a second ciphertext; intercepting multiple segmented ciphertexts from the first ciphertext and the second ciphertext according to a preset interception method, and combining the multiple segmented ciphertexts to generate an encryption key; encrypting front-end data according to the encryption key and the encryption algorithm to generate original ciphertext data; combining the first random number, the second random number, the encryption algorithm type and the original ciphertext data to generate final ciphertext data, and sending it to the front-end device; after the front-end device receives the final ciphertext data, it organizes the encryption key according to the first random number and the second random number to decrypt the original ciphertext data.

[0009] It can be seen from the above scheme that the encryption key used to encrypt the front-end data is obtained by intercepting and encrypting the first random number and the second random number multiple times, wherein multiple segmented ciphertexts are obtained from the first ciphertext and the second ciphertext by a preset interception method, and then the multiple segmented ciphertexts are combined to obtain the encryption key. Therefore, after subsequent encryption, the final ciphertext data sent to the front end only contains the first random number, the second random number, the encryption algorithm type and the original ciphertext data, and does not contain any data fragments in the encryption key, thereby improving the security during transmission. The front-end device needs to organize the encryption key according to the first random number and the second random number in order to decrypt the original ciphertext data, and obtain the encryption key through the agreed preset interception method. Therefore, when a third party knows the first random number and the second random number and generates the first ciphertext and the second ciphertext, it cannot obtain the encryption key, thereby increasing the difficulty of obtaining the encryption key and improving the security of encryption.

[0010] In a further embodiment, the step of extracting multiple segmented ciphertexts from the first ciphertext and the second ciphertext according to a preset extraction method also includes: extracting at least one segmented ciphertext from the first ciphertext according to a preset extraction method, and extracting at least one segmented ciphertext from the second ciphertext according to a preset extraction method.

[0011] It can be seen from this that if it is necessary to obtain segmented ciphertext, the first random number and the second random number need to be intercepted to increase the security of encryption.

[0012] In a further solution, the step of combining multiple segmented ciphertexts to generate an encryption key includes: combining multiple segmented ciphertexts according to a preset rule to generate an encryption key.

[0013] It can be seen that by combining multiple segmented ciphertexts according to preset rules, the security of encryption is increased.

[0014] In a further scheme, the steps of generating a first temporary key by a first random number and generating a second temporary key by a second random number include: concatenating the first random number with preset fixed characters, encrypting according to a preset encryption algorithm, and generating a first temporary key; concatenating the second random number with fixed characters, encrypting according to a preset encryption algorithm, and generating a second temporary key.

[0015] It can be seen that by concatenating random numbers with fixed characters, the first temporary key and the second temporary key cannot be calculated by knowing only the first random number and the second random number, which increases the difficulty of obtaining the key and thus improves the security of encryption.

[0016] In a further solution, the first temporary key is encrypted by the first random number, and the step of generating the first key includes: dividing the first temporary key into multiple segmented data, encrypting the multiple segmented data and a preset fixed value using the first random number to generate a first ciphertext.

[0017] It can be seen that the encryption security is increased by using the ciphertext group chaining mode to generate the first ciphertext.

[0018] In a further solution, the step of encrypting multiple segmented data and preset fixed values ​​using a first random number also includes: splitting the first random number into a first split key and a second split key, and encrypting multiple segmented data and preset fixed values ​​using the first split key and the second split key.

[0019] It can be seen that in the ciphertext block chaining mode encryption, the combination of encryption with the data encryption standard mode increases the security of encryption.

[0020] In order to achieve the second purpose, the encryption device provided by the present invention includes a processor and a memory, the memory stores a computer program, and the computer program implements the above-mentioned data encryption method when executed by the processor.

[0021] In order to achieve the third purpose, the present invention provides a computer-readable storage medium, on which a computer program is stored, characterized in that: when the computer program is executed, the above-mentioned data encryption method is implemented. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] Figure 1 It is a structural block diagram of an embodiment of the data encryption method of the present invention.

[0023] Figure 2 It is a flow chart of an embodiment of the data encryption method of the present invention.

[0024] The present invention is further described below in conjunction with the accompanying drawings and embodiments. DETAILED DESCRIPTION

[0025] The data encryption method of the present invention generates an encryption key through two random numbers, wherein, when forming the encryption key, the first ciphertext and the second ciphertext are intercepted and obtained through a preset interception method agreed upon by the encryption device and the front-end device. Therefore, during transmission, no fragment of the encryption key is transmitted, and the encryption key is obtained by combining after interception, which increases the difficulty of obtaining the encryption key and improves the security of front-end data encryption.

[0026] Data encryption method embodiment: See also Figure 1 The data encryption method of this embodiment is obtained by executing the encryption device 1. After the encryption device encrypts the front-end data to obtain the final encrypted data, the encrypted data is sent to the front-end device 2, and the front-end device 2 decrypts the front-end data and executes it. The front-end data is the sensitive data and sensitive algorithm that the front-end data needs to execute. The front-end device 2 is the front-end application of the web page.

[0027] See also Figure 2 In the implementation of the security encryption method of this embodiment, the encryption device first executes step S1 to generate a first random number and a second random number, generates a first temporary key through the first random number, and generates a second temporary key through the second random number. Among them, the first random number is spliced ​​with a fixed character, encrypted according to a preset encryption algorithm, and a first temporary key is generated. The second random number is spliced ​​with a fixed character, encrypted according to a preset encryption algorithm, and a second temporary key is generated. The fixed character is the character data pre-agreed by the front end and the encryption device, and only the front end device and the encryption device store and know the fixed character. By splicing the first random number with the fixed character, and the second random number with the fixed character, only the first random number and the second random number are known, and the first temporary key and the second temporary key cannot be calculated, thereby increasing the difficulty of obtaining the key. The preset encryption algorithm is the MD5 algorithm, and the preset encryption algorithm is the encryption algorithm agreed upon by the front end and the encryption device. Only the front end and the encryption device know that the preset encryption algorithm needs to be used to encrypt the spliced ​​first random number and the second random number.

[0028] After generating the first temporary key and the second temporary key, the encryption device executes step S2, encrypts the first temporary key with the first random number to generate the first ciphertext, and encrypts the second temporary key with the second random number to generate the second ciphertext. The first temporary key is divided into a plurality of segmented data, and the plurality of segmented data and the preset fixed value are encrypted using the first random number to generate the first ciphertext, that is, the first ciphertext is generated by using the ciphertext grouping link mode. The first temporary key is divided into a plurality of segmented data, and the size of each segmented data is the same. The preset fixed value is the initialization vector pre-agreed by the front-end device and the encryption device, and the preset fixed value is used to perform an XOR operation with the first segmented data to obtain the first data to be segmented and encrypted, and the first data to be segmented and encrypted is encrypted to obtain the first segmented encrypted ciphertext block, and the first segmented encrypted ciphertext block is XORed with the next segmented data to obtain the second data to be segmented and encrypted, and the second data to be segmented and encrypted is encrypted again, and so on, until all the segmented data are encrypted, and the first ciphertext is obtained.

[0029] The encryption device splits the first random number into a first split key and a second split key, and encrypts multiple segmented data and preset fixed values ​​using the first split key and the second split key. That is, in the ciphertext group linking mode, the data encryption standard mode is used for encryption. That is, after each XOR operation, its encryption method is encrypted by the data encryption standard mode. That is, after obtaining the first segmented encrypted data, it is encrypted using the first split key, and then decrypted using the second split key, and then encrypted using the first split key to obtain the first segmented encrypted ciphertext block. The second ciphertext is also generated in the same way.

[0030] After generating the first ciphertext and the second ciphertext, the encryption device executes step S3, intercepts multiple segmented ciphertexts from the first ciphertext and the second ciphertext according to a preset interception method, and combines multiple segments to generate an encryption key. The preset interception method is a preset interception method agreed upon by the front-end device and the encryption device. At least one segmented ciphertext is intercepted from the first ciphertext according to the preset interception method, and at least one segmented ciphertext is intercepted from the second ciphertext according to the preset interception method. At least one segmented ciphertext is intercepted from the first ciphertext according to the preset interception method, and at least one segmented ciphertext is intercepted from the second ciphertext according to the preset interception method. One preset interception method is to intercept the 8 characters arranged at the front of the first ciphertext and the last 8 characters arranged at the back of the first ciphertext; intercept the first 8 characters arranged at the front of the second ciphertext and the last 8 characters arranged at the back of the second ciphertext.

[0031] In the encryption device combining multiple segments to generate an encryption key, multiple segmented ciphertexts are combined according to a preset rule to generate an encryption key. That is, after the segmented data is intercepted from the first ciphertext and the second ciphertext, the multiple segmented data are arranged according to a preset rule. One preset rule is to arrange them in the order of interception.

[0032] After the encryption key is generated by the combination, the encryption device executes step S4 to encrypt the front-end data according to the encryption key and the encryption algorithm to generate original ciphertext data. There are multiple encryption algorithms, and the front-end device and the encryption device are both set with multiple encryption algorithms, and each encryption algorithm corresponds to an encryption algorithm type. The front-end data is encrypted according to the encryption algorithm and the encryption key to generate original ciphertext data, thereby improving the security of encryption.

[0033] After generating the original ciphertext data, the encryption device executes step S5 to combine the first random number, the second random number, the encryption algorithm type and the original ciphertext data to generate the final ciphertext data and send it to the front-end device. The front-end code can be written to the front-end device through a static solution.

[0034] After the front-end device receives the final ciphertext data, it executes step S6 to organize the encryption key to decrypt the original ciphertext data. After the front-end device obtains the first random number and the second random number, it can splice the first random number with the agreed fixed characters, and the second random number with the fixed characters to generate the first temporary key and the second temporary key, encrypt the first random number with the first temporary key to generate the first ciphertext, and encrypt the second random number with the second temporary key to generate the second ciphertext. According to the preset interception method, multiple segmented ciphertexts are obtained, and the multiple segmented ciphertexts are combined according to the preset rules to generate an encryption key. The encryption algorithm is obtained according to the encryption algorithm type, and the original ciphertext data is encrypted according to the encryption algorithm and the encryption key to obtain the front-end data, and the front-end device can execute the front-end data.

[0035] The first ciphertext and the second ciphertext are formed by encrypting the first random number and the second random number multiple times, making it more difficult to obtain the first ciphertext and the second ciphertext; only part of the segmented ciphertext is intercepted from the first ciphertext and the second ciphertext, so that the encryption key is obtained by combining multiple segmented ciphertexts, thereby increasing the difficulty of obtaining the encryption key. Since only the first random number and the second random number are transmitted during transmission, and no fragment of the encryption key is transmitted, it is difficult for a third party to obtain the encryption key through the first random number and the second random number, thereby increasing the difficulty of obtaining the encryption key and improving the security of encryption.

[0036] Encryption device embodiment: The computer device of this embodiment includes a processor and a memory. The memory stores a computer program. When the processor executes the computer program, the above-mentioned data encryption method is implemented.

[0037] The computer device may include but is not limited to a processor and a memory. Those skilled in the art will appreciate that the encryption device may include more or fewer components, or a combination of certain components, or different components, for example, the computer device may also include input and output devices, network access devices, buses, etc.

[0038] Computer readable storage medium embodiment: The method for data encryption in the encryption device described in the above embodiment can be stored in a computer-readable storage medium in the form of a computer program. When the computer program is executed by a processor, the steps of the method embodiment of data encryption in the above computer device can be completed. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium can be, for example, but not limited to: an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media (a non-exhaustive list) include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.

[0039] The above are only preferred embodiments of the present invention, but the design concept of the invention is not limited thereto. Without departing from the concept of the present invention, more other equivalent embodiments may be included. It is possible for those skilled in the art to make various obvious changes, readjustments and substitutions without departing from the protection scope of the present invention.

Claims

1. A method for data encryption, characterized in that: The method includes: Generate a first random number, generate a first temporary key using the first random number, generate a second random number, and generate a second temporary key using the second random number; Encrypting the first temporary key with the first random number to generate a first ciphertext, and encrypting the second temporary key with the second random number to generate a second ciphertext; intercepting a plurality of segmented ciphertexts from the first ciphertext and the second ciphertext according to a preset interception method, and combining the plurality of segmented ciphertexts to generate an encryption key; Encrypt the front-end data according to the encryption key and encryption algorithm to generate original ciphertext data; Combine the first random number, the second random number, the encryption algorithm type and the original ciphertext data to generate final ciphertext data, and send it to the front-end device; After receiving the final ciphertext data, the front-end device organizes the encryption key according to the first random number and the second random number to decrypt the original ciphertext data.

2. The data encryption method according to claim 1, characterized in that: The step of intercepting a plurality of segmented ciphertexts from the first ciphertext and the second ciphertext according to a preset interception method also includes: intercepting at least one segmented ciphertext from the first ciphertext according to the preset interception method, At least one of the segmented ciphertexts is intercepted from the second ciphertext according to the preset interception method.

3. The data encryption method according to claim 2, characterized in that: The step of combining a plurality of the segmented ciphertexts to generate an encryption key comprises: The plurality of segmented ciphertexts are combined according to a preset rule to generate the encryption key.

4. The data encryption method according to any one of claims 1 to 3, characterized in that: The steps of generating a first temporary key by using the first random number and generating a second temporary key by using the second random number include: The first random number is concatenated with a preset fixed character, and encrypted according to a preset encryption algorithm to generate the first temporary key; The second random number is concatenated with the fixed character, and encrypted according to the preset encryption algorithm to generate the second temporary key.

5. The data encryption method according to claim 4, characterized in that: The step of encrypting the first temporary key by the first random number to generate the first key comprises: The first temporary key is divided into a plurality of segmented data, and the plurality of segmented data and a preset fixed value are encrypted using the first random number to generate the first ciphertext.

6. The data encryption method according to claim 5, characterized in that: The step of encrypting the plurality of segmented data and the preset fixed value using the first random number also includes: The first random number is split into a first split key and a second split key, and the plurality of segmented data and a preset fixed value are encrypted using the first split key and the second split key.

7. An encryption device, comprising a processor and a memory, wherein the memory stores a computer program, characterized in that: When the computer program is executed by the processor, the data encryption method according to any one of claims 1 to 6 is implemented.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed, the data encryption method according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Cryptography module for use with fragmented key and methods for use therewith

    CN103283177A

  • Data encryption method and device and storage medium

    CN110417543A

  • File self-encryption and decryption method

    CN111914280A

  • Encryption communication method, first end device and second end device

    CN115834043A

  • Data processing method and device, processor and electronic equipment

    CN116361837A