Method, encryption device and computer readable storage medium for data encryption

By generating a random number encryption key and transmitting only the ciphertext during transmission, and using a preset interception method to combine and generate the encryption key, the problem of easy key leakage in traditional encryption methods is solved, thus improving the security of data transmission.

CN119254467BActive Publication Date: 2025-11-28金邦达有限公司
View PDF 2 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

During front-end data transmission, the keys for traditional encryption methods are easily leaked, resulting in insecure data encryption.

Method used

By generating first and second random numbers, a temporary key is generated and encrypted into ciphertext. Segments of ciphertext are extracted from the ciphertext using a preset truncation method, and combined to generate an encryption key. During transmission, only the random number and the combination key of the random number are transmitted. When the front-end device decrypts, it decrypts the data according to the combination key of the random number and the preset rules.

Benefits of technology

It improves security during transmission, enhances security during adversarial processes, prevents data encryption security, and prevents data leakage.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119254467B_ABST
    Figure CN119254467B_ABST
Patent Text Reader

Abstract

The application provides a data encryption method, an encryption device and a computer readable storage medium, and 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, combining the plurality of segmented ciphertexts to generate an encryption key; encrypting front-end data according to the encryption key and an 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 the final ciphertext data to a front-end device; and after the front-end device receives the final ciphertext data, the original ciphertext data is decrypted according to the first random number and the second random number. The method can improve the security of encryption.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application 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

[0002] In modern web development, front-end applications need to process a large amount of sensitive data and algorithm data, but front-end code is easy to be analyzed after being decompiled, which can lead to leakage of sensitive data or algorithm data, significantly reducing the security of the front-end and possibly causing a series of security problems.

[0003] Generally speaking, for front-end data, traditional encryption techniques such as symmetric key encryption or obfuscation techniques are used to improve the security of front-end data, but the keys of traditional encryption methods are easy to leak, resulting in front-end data leakage.

[0004] A data encryption method in the prior art is to obtain at least two fixed key segments from the local by pre-configuration; determine the permutation and combination order of the at least two fixed key segments according to a randomly generated random number, and arrange and combine the at least two fixed key segments in the permutation and combination order to obtain a combined fixed key; randomly generate at least one random key segment; determine the embedding position of the at least one random key segment in the combined fixed key according to the random number, and embed the 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 transmits the encrypted data, the random key segment needs to be transmitted, and the key segment is easy to be leaked during transmission, resulting in insecure data encryption. SUMMARY

[0005] The first object of the present application is to provide a data encryption method that improves transmission security.

[0006] The second object of the present application is to provide a data encryption method that implements the above-mentioned data encryption method.

[0007] The third object of the present application is to provide a computer readable storage medium that applies the above-mentioned data encryption method.

[0008] To achieve the first object of the present application, the present application provides a data encryption method, which comprises: 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 a plurality of segmented ciphertexts from the first ciphertext and the second ciphertext according to a preset interception mode, combining the plurality of segmented ciphertexts to generate an encryption key; encrypting front-end data according to the encryption key and an 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 the final ciphertext data to a front-end device; after the front-end device receives the final ciphertext data, the original ciphertext data is decrypted according to the first random number and the second random number.

[0009] As can be seen from the above scheme, the encryption key for encrypting the front-end data is obtained by intercepting the first random number and the second random number multiple times, wherein the plurality of segmented ciphertexts are obtained from the first ciphertext and the second ciphertext according to the preset interception mode, and the encryption key is obtained by combining the plurality of segmented ciphertexts. 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 segment of 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 to decrypt the original ciphertext data, and the encryption key is obtained through the agreed preset interception mode, so that a third party cannot obtain the encryption key even if the first random number and the second random number are known and the first ciphertext and the second ciphertext are generated, thereby increasing the difficulty of obtaining the encryption key and improving the security of encryption.

[0010] In a further scheme, the step of intercepting a plurality of segmented ciphertexts from the first ciphertext and the second ciphertext according to the preset interception mode further comprises: intercepting at least one segmented ciphertext from the first ciphertext according to the preset interception mode, and intercepting at least one segmented ciphertext from the second ciphertext according to the preset interception mode.

[0011] As can be seen, if segmented ciphertexts are needed, the first random number and the second random number need to be intercepted, thereby increasing the security of encryption.

[0012] In a further scheme, the step of combining the plurality of segmented ciphertexts to generate the encryption key comprises: combining the plurality of segmented ciphertexts according to a preset rule to generate the encryption key.

[0013] As can be seen, the plurality of segmented ciphertexts are combined according to the preset rule, thereby increasing the security of encryption.

[0014] In a further scheme, the step of generating the first temporary key by the first random number and generating the second temporary key by the second random number comprises: splicing the first random number with a preset fixed character, encrypting according to a preset encryption algorithm to generate the first temporary key; and splicing the second random number with the fixed character, encrypting according to the preset encryption algorithm to generate the second temporary key.

[0015] Therefore, the first temporary key and the second temporary key cannot be calculated by only knowing the first random number and the second random number, the difficulty of obtaining the key is improved, and the security of encryption is improved.

[0016] In a further scheme, the step of encrypting the first temporary key by the first random number to generate the first key comprises: dividing the first temporary key into a plurality of segmented data, encrypting the plurality of segmented data and a preset fixed value by the first random number to generate the first ciphertext.

[0017] Therefore, the first ciphertext is generated by using the ciphertext block linkage mode, and the security of encryption is improved.

[0018] In a further scheme, the step of encrypting the plurality of segmented data and the preset fixed value by the first random number further comprises: splitting the first random number into a first split key and a second split key, and encrypting the plurality of segmented data and the preset fixed value by the first split key and the second split key.

[0019] Therefore, in the ciphertext block linkage mode encryption, the data encryption standard mode is combined for encryption, and the security of encryption is improved.

[0020] To achieve the second purpose, the encryption device provided by the application comprises a processor and a memory, the memory stores a computer program, and the computer program is executed by the processor to realize the data encryption method described above.

[0021] To achieve the third purpose, the computer readable storage medium provided by the application stores a computer program, and the computer program is executed to realize the data encryption method described above. BRIEF DESCRIPTION OF DRAWINGS

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

[0023] Figure 2 is a flowchart of an embodiment of the data encryption method of the application.

[0024] The application will be further described below in combination with the drawings and embodiments. DETAILED DESCRIPTION

[0025] The data encryption method of the present application generates an encryption key through two random numbers, wherein, when forming the encryption key, the first ciphertext and the second ciphertext are intercepted from a preset interception mode agreed upon by the encryption device and the front-end device, so that, when transmitting, none of the pieces of the encryption key is transmitted, and the encryption key is obtained by combining after interception, thereby improving the difficulty of obtaining the encryption key and improving the security of the front-end data encryption.

[0026] Data encryption method embodiment:

[0027] Referring to Figure 1 The data encryption method of the present embodiment is executed by the encryption device 1. After the encryption device encrypts the front-end data to obtain the final encrypted data, the encryption device sends the encrypted data to the front-end device 2, and the front-end device 2 performs decryption to obtain the front-end data and then executes. The front-end data is sensitive data and sensitive algorithms that the front-end data needs to execute. The front-end device 2 is the front-end application program of the webpage.

[0028] Referring to Figure 2 In the execution of the security encryption method of the present 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. The first random number is spliced with a fixed character, encrypted according to a preset encryption algorithm to generate the first temporary key. The second random number is spliced with a fixed character, encrypted according to a preset encryption algorithm to generate the second temporary key. The fixed character is a character data agreed upon in advance 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, the first temporary key and the second temporary key cannot be calculated from the first random number and the second random number, thereby improving the difficulty of obtaining the key. The preset encryption algorithm is MD5 algorithm, and the preset encryption algorithm is an 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 second random number.

[0029] After the first temporary key and the second temporary key are generated, the encryption device performs step S2 to encrypt the first random number to the first temporary key to generate a first ciphertext, and encrypt the second random number to the second temporary key to generate a second ciphertext. 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, i.e., the first ciphertext is generated by using a ciphertext block linkage mode. The first temporary key is divided into a plurality of segmented data, and each segmented data has the same size. The preset fixed value is an initialization vector agreed in advance by the front-end device and the encryption device, and the preset fixed value and the first segmented data are subjected to an exclusive OR operation to obtain a first to-be-encrypted segmented data, the first to-be-encrypted segmented data is encrypted to obtain a first encrypted segmented ciphertext block, the first encrypted segmented ciphertext block is subjected to an exclusive OR operation with the next segmented data to obtain a second to-be-encrypted segmented data, the second to-be-encrypted segmented data is encrypted again, and so on, until all the segmented data are encrypted to obtain the first ciphertext.

[0030] The encryption device splits the first random number into a first split key and a second split key, and encrypts the plurality of segmented data and the preset fixed value using the first split key and the second split key. That is, in the ciphertext block linkage mode, the data encryption standard mode is used for encryption. That is, after each exclusive OR operation, the encryption mode is encrypted by the data encryption standard mode. That is, after obtaining the first to-be-encrypted segmented data, the first split key is used for encryption, and then the second split key is used for decryption, and then the first split key is used for encryption to obtain the first encrypted segmented ciphertext block. The second ciphertext is also generated in the same way.

[0031] After the first ciphertext and the second ciphertext are generated, the encryption device performs step S3 to intercept a plurality of segmented ciphertexts from the first ciphertext and the second ciphertext according to a preset interception mode, and combine the plurality of segmented ciphertexts to generate an encryption key. The preset interception mode is a preset interception mode agreed 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 mode, and at least one segmented ciphertext is intercepted from the second ciphertext according to the preset interception mode. At least one segmented ciphertext is intercepted from the first ciphertext according to the preset interception mode, and at least one segmented ciphertext is intercepted from the second ciphertext according to the preset interception mode. One preset interception mode is to intercept the first 8 characters arranged at the front of the first ciphertext, and the last 8 characters arranged at the rear of the first ciphertext; the first 8 characters arranged at the front of the second ciphertext, and the last 8 characters arranged at the rear of the second ciphertext.

[0032] The encryption device combines the plurality of segments to generate the encryption key. The plurality of segment ciphertexts are combined according to a preset rule to generate the encryption key. That is, after the segment data is obtained by intercepting the first ciphertext and the second ciphertext, the plurality of segment data are arranged according to the preset rule. One preset rule is to arrange according to the intercepting order.

[0033] After the encryption key is generated by combination, the encryption device performs step S4 to encrypt the front-end data according to the encryption key and the encryption algorithm to generate the original ciphertext data. The encryption algorithm is multiple, and the front-end device and the encryption device are both provided with multiple encryption algorithms. 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 the original ciphertext data, thereby improving the security of encryption.

[0034] After the original ciphertext data is generated, the encryption device performs 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 the final ciphertext data to the front-end device. The front-end code can be written to the front-end device through a static scheme.

[0035] After the final ciphertext data is received by the front-end device, the front-end device performs step S6 to organize the encryption key to decrypt the original ciphertext data. After the first random number and the second random number are obtained by the front-end device, the first random number and the agreed fixed character are spliced, the second random number and the fixed character are spliced to generate the first temporary key and the second temporary key, the first random number and the first temporary key are encrypted to generate the first ciphertext, and the second random number and the second temporary key are encrypted to generate the second ciphertext. The plurality of segment ciphertexts are obtained according to the preset intercepting mode, and the encryption key is generated by combining the plurality of segment ciphertexts according to the preset rule. 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.

[0036] The first ciphertext and the second ciphertext are formed by multiple encryption of the first random number and the second random number, so that the difficulty of obtaining the first ciphertext and the second ciphertext is increased. Only part of the segment ciphertexts of the first ciphertext and the second ciphertext are intercepted, so that the encryption key is obtained by combining the plurality of segment 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 segment 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.

[0037] Encryption device embodiment:

[0038] The computer device of the embodiment includes a processor and a memory, and the memory stores a computer program. The processor implements the above-mentioned data encryption method when executing the computer program.

[0039] The computer device can include but is not limited to a processor and a memory. Those skilled in the art can understand that the encryption device can include more or fewer components, or combine certain components, or different components, for example, the computer device can also include an input / output device, a network access device, a bus, etc.

[0040] Computer readable storage medium embodiment:

[0041] The data encryption method of the encryption device described in the above-mentioned embodiments can be stored in a computer readable storage medium in the form of a computer program, and the computer program is executed by a processor to complete the steps of the above-mentioned data encryption method embodiment of the computer device. The computer readable medium can be a computer readable signal medium or a computer readable storage medium. The computer readable storage medium may, for example, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or component, or any combination thereof. More specific examples (non-exhaustive list) of the computer readable storage medium include: electrical connections with one or more conductors, portable computer disks, hard disks, random access memories (RAM), read-only memories (ROM), erasable programmable read-only memories (EPROM or flash memory), optical fibers, portable compact disk read-only memories (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.

[0042] The above-mentioned is only the preferred embodiment of the present application, but the design concept of the application is not limited thereto, and more other equivalent embodiments can be included without departing from the concept of the present application, and various obvious changes, re-adjustments and substitutions can be made by those skilled in the art without departing from the protection scope of the present application.

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; The first random number is used to encrypt the first temporary key to generate the first ciphertext, and the second random number is used to encrypt the second temporary key to generate the second ciphertext. According to a preset interception method, multiple segments of ciphertext are extracted from the first ciphertext and the second ciphertext, and the multiple segments of ciphertext are combined to generate an encryption key. The front-end data is encrypted using the encryption key and encryption algorithm to generate the original ciphertext data; The first random number, the second random number, the encryption algorithm type, and the original ciphertext data are combined to generate the final ciphertext data, which is then sent 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 steps of extracting multiple segments of ciphertext from the first ciphertext and the second ciphertext according to a preset extraction method also include: At least one segment of ciphertext is extracted from the first ciphertext according to the preset extraction method. At least one segmented ciphertext is extracted from the second ciphertext according to the preset extraction method.

3. The data encryption method according to claim 2, characterized in that: The step of combining multiple segments of ciphertext to generate an encryption key includes: The encryption key is generated by combining multiple segments of ciphertext according to preset rules.

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 using the first random number and generating a second temporary key 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 steps of encrypting the first temporary key with the first random number to generate the first key include: The first temporary key is divided into multiple data segments, and the multiple data segments 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 multiple segments of data and preset fixed values ​​using the first random number further includes: The first random number is split into a first split key and a second split key, and the first split key and the second split key are used to encrypt multiple segments of data and preset fixed values.

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, it implements the data encryption method as described in any one of claims 1 to 6.

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

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