Computer data encryption method and system
By segmenting and encrypting long data, and using the RSA encryption algorithm to encrypt and concatenate the sliced data, the problem of slow encryption speed for long data in existing technologies is solved, and fast and secure data transmission is achieved.
Patent Information
- Application Number
- CN202511899811.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-16
- Publication Date
- 2026-02-10
AI Technical Summary
Existing technologies struggle to quickly and securely encrypt long data, especially in dynamic encryption environments, resulting in ineffective data encryption control.
The RSA encryption algorithm is used to segment the data to be encrypted. First, the data is segmented, then the segmented data is encrypted and concatenated based on the RSA encryption algorithm, and finally the data is decrypted and concatenated using the RSA decryption algorithm.
It enables fast encryption and decryption of long data, improving the security of data transmission, and is not limited by the application environment, supporting flexible encryption of both long and short data.
Smart Images

Figure CN121509078A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data security technology, and more specifically, to a computer data encryption method and system. Background Technology
[0002] In the application of computer networks, computer data, hardware, and software are easily damaged by viruses or Trojans, which can seriously affect the security of computer networks. Therefore, relevant personnel must attach great importance to information security. Network security mainly includes network information security and network equipment security, and data encryption technology is a major method for maintaining network security. Data encryption technology is a means of encrypting various computer information using cryptographic techniques. It mainly uses function shifting, substitution, and encryption keys to replace the information inside the computer with information that cannot be accessed by others. The information recipient can restore the encrypted information using decryption functions, which can significantly improve the security of computer information.
[0003] Data encryption technology can be divided into symmetric and asymmetric encryption. Symmetric encryption refers to the use of the same key by both the sender and receiver to decrypt data. This encryption technology requires the sender and receiver to agree on and properly safeguard the key beforehand to ensure information security. Asymmetric encryption, on the other hand, involves the sender and receiver using different keys for encryption and decryption, with these keys being either private or public keys. Using asymmetric encryption eliminates the need for key exchange between the sender and receiver, further enhancing data confidentiality and security. However, in today's dynamic encryption environment, both approaches struggle to quickly and securely encrypt long datasets. Furthermore, the management and control of data encryption remains ineffective. Summary of the Invention
[0004] The purpose of this invention is to provide a computer data encryption method and system that can quickly encrypt and decrypt long data in segments, thereby improving the security of data transmission.
[0005] The embodiments of the present invention are implemented as follows: In a first aspect, the present invention provides a computer data encryption method, comprising: The sending end extracts the corresponding data to be encrypted, 'a', based on the data request information. The data to be encrypted, a, is divided according to a preset segmentation rule to generate slice data b; After encrypting the sliced data b separately using the RSA encryption algorithm, they are then concatenated to obtain the data c to be transmitted. The sending end sends the data to be transmitted, c, to the receiving end, and the receiving end decrypts and concatenates the data according to the RSA decryption algorithm.
[0006] The step of the sending end extracting the corresponding data to be encrypted 'a' based on the data request information includes: Acquire and parse the sent data request information, including the sender's identity information and the request content; Verify the sender's identity information to determine if the identity belongs to the user's whitelist. If so, the verification is successful. After successful verification, the sending end extracts the corresponding data to be encrypted, 'a', based on the content of the data request information.
[0007] Preferably, a data encryption priority table is set according to the sender's identity information and the importance of the request content; When multiple sending ends simultaneously send data request information, the data encryption priority table is queried to obtain the corresponding encryption priority. The extracted data 'a' to be encrypted is processed according to the encryption priority.
[0008] Preferably, the step of segmenting the data to be encrypted 'a' according to a preset segmentation rule includes: The total byte length of the data to be encrypted, a, is compared with a preset standard byte length value to determine the corresponding segmentation point position; The data to be encrypted, 'a', is segmented according to the location of the segmentation point.
[0009] Preferably, the generation process of the RSA encryption algorithm includes: Randomly select two distinct prime numbers and calculate their common modulus and Euler's totient function; The public key for encryption is determined based on Euler's totient function, and the private key for decryption is calculated and obtained using the public key; The sending and receiving ends publish the public key and keep the private key private.
[0010] Specifically, the process of calculating the common modulus and Euler's totient function of two distinct prime numbers: Step S3-1: Assume two prime numbers are p and q, where p=65 and q=71. Calculate their product n=p*q=4615, which is 1001000000111 in binary. That is, the byte length of this encryption algorithm is 13 bits. The RSA key can be either 1024 bits or 2048 bits; Calculate Euler's totient function: φ(n) = φ(p*q) = (p-1)(q-1), where φ(n) represents the number of positive integers less than or equal to n that are relatively prime to n; Step S3-2: Determine the public key for encryption according to the Euler's totient function, and calculate and obtain the private key for decryption by using the public key; specifically, determine the public key e for encryption according to 1 < e < φ(n), where the value of e must be an integer, and e and φ(n) must be relatively prime numbers, and then calculate the private key: e * d % m = 1, where (φ(n) = m), so as to obtain the public key and the private key: public key = (e, n), private key = (d, n); Step S3-3: The sender makes the public key public and retains the private key. Thus, according to C = M e mod n, encrypt to generate the ciphertext, where C represents the ciphertext and M represents the plaintext; the receiver decrypts according to M = C d mod n to generate the plaintext.
[0011] Perform key calculation for p and q: S1. Calculate the product of p and q as the common modulus n: n = p * q; S2. Calculate the Euler's totient function φ(n): φ(n) = (p - 1)(q - 1); S3. Calculate the public key e: 1 < e < φ(n), so the value range of e is: prime numbers between 1 and φ(n), and e and φ(n) are relatively prime numbers, satisfying the condition; S4. Calculate the private key d: e * d % φ(n) = 1, and calculate d; S5. Public key encryption: Set the value of M, C = M 3 % d, then "M" becomes "C" after being encrypted by RSA.
[0012] S6. Private key decryption: The decrypted plaintext is 3.
[0013] Send the data c to be transmitted to the receiver for decryption and data splicing according to the RSA decryption algorithm, so as to obtain the original data.
[0014] In a second aspect, the present invention provides a computer data encryption system, which includes: A data extraction module, configured to extract the corresponding data a to be encrypted according to the data request information sent by the sender; A data splitting module, configured to split the data a to be encrypted according to a preset splitting rule; A segmented encryption module, configured to perform segmented encryption and splicing on the sliced data b respectively based on the RSA encryption algorithm to obtain the data c to be transmitted; A data decryption module, configured to perform reverse disassembling on the data c to be transmitted by the receiver, restore it to the fragment data in the encrypted state, then decrypt it according to the RSA decryption algorithm, and splice the decrypted sliced data b.
[0015] Compared with the prior art, the embodiments of the present invention have at least the following advantages or beneficial effects: This application provides a computer data encryption method and system. First, based on the data request information sent by the sending end, authentication and encryption priority are performed. After successful authentication, the corresponding data to be encrypted, 'a', is extracted. Then, the total byte length of the data to be encrypted, 'a', is compared with a preset byte length standard value, and the data to be encrypted, 'a', is segmented according to a preset segmentation rule. Next, the segmented data, 'b', is encrypted and concatenated using the RSA encryption algorithm to obtain the data to be transmitted, 'c'. Finally, the data to be transmitted, 'c', is sent to the corresponding receiving end for decryption and data concatenation using the RSA decryption algorithm to obtain the original data. By employing the RSA encryption algorithm, data encryption is not limited by the application environment, making it flexible and convenient. Furthermore, for excessively long data, segmentation and encryption are performed before concatenation to form encrypted long data, enabling fast encryption even for excessively long data. Moreover, RSA encryption is not limited by data length, supporting both long and short encryption. Attached Figure Description
[0016] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0017] Figure 1 This is a flowchart illustrating an embodiment of a computer data encryption method provided by the present invention; Figure 2 A schematic diagram illustrating the RSA encryption and decryption principle in one embodiment of a computer data encryption method provided by the present invention; Figure 3 A schematic diagram illustrating the steps of an RSA key generation process in an embodiment of a computer data encryption method provided by the present invention; Figure 4 This is a structural block diagram of an embodiment of a computer data encryption system provided by the present invention; Figure 5 This is a structural block diagram of an electronic device provided in an embodiment of the present invention.
[0018] Icons: 1. Memory; 2. Processor; 3. Communication interface; 11. Data extraction module; 12. Data segmentation module; 13. Segment encryption module; 14. Data decryption module. Detailed Implementation
[0019] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. The components of the embodiments of this application described and shown in the accompanying drawings can generally be arranged and designed in various different configurations.
[0020] Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely to illustrate selected embodiments of the application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.
[0021] The following detailed description of some embodiments of this application is provided in conjunction with the accompanying drawings. Unless otherwise specified, the following embodiments and features can be combined with each other.
[0022] Please refer to Figure 1 , Figure 1 The diagram shows a flowchart of a computer data encryption method provided by an embodiment of the present invention. The method includes the following steps: Step S1: Extract the corresponding data to be encrypted, a, based on the data request information sent by the communication terminal.
[0023] In the above steps, the data request information sent by the sender from the sending end is first obtained and parsed to obtain the sender's identity information and request content. Then, the sender's identity information is verified to determine if the sender belongs to a user whitelist; if so, the verification passes. After successful verification, the corresponding data to be encrypted, 'a', is extracted based on the request content. When a sending end connects to the network system for the first time, the sender's identity information is read and verified by the network system's backend. If the verification passes, the sender is added to the user whitelist. Subsequent data requests can be made by directly checking the whitelist. If the communication terminal is found to be in the user whitelist, the verification passes, and a communication connection is established; if neither the sender nor the sending end is found to be in the user whitelist, the verification fails, and the communication connection is refused to be established with the sending end to ensure information security.
[0024] In addition, verification methods can also employ one or more of the following: username and password authentication, card-based authentication, or biometric authentication. Username and password authentication is simple and easy to use, and is currently the most commonly used authentication method. However, passwords are easily leaked and even brute-forced. Many users use weak passwords such as their birthdate, which are easily cracked by password dictionaries. Many users also use the same username and password on different websites. Once a user's account information is leaked on a particular website, these leaked accounts may be vulnerable to credential stuffing attacks. Therefore, single-factor password authentication is not secure enough. Card-based authentication includes IC cards with built-in smart card chips and magnetic stripe cards that store personal information. Smart IC cards authenticate through the chip, cannot be copied, and have high security, but require a dedicated card reader and have limited universality. Magnetic stripe cards are easily copied, and the magnetic stripe can easily disappear. SMS verification codes are also frequently used for authentication. This method can also be classified as card-based authentication because the SMS verification code is sent to the mobile phone number linked to the user's account. Since the mobile phone number and SIM card are integrated, this is essentially SIM card authentication. Biometric authentication includes voiceprint authentication, fingerprint authentication, iris authentication, and handwriting authentication. Biometric features are unique, reliable, and stable, making them difficult to copy. Furthermore, biometric features cannot be lost or misused by others. Therefore, biometric authentication is the most reliable authentication method; however, the authentication process often requires complex technologies and equipment, resulting in high costs.
[0025] When multiple senders simultaneously issue data requests, the corresponding encryption priority can be obtained by querying a data encryption priority table. Then, the extracted data 'a' to be encrypted is processed according to the encryption priority. The data encryption priority table is set based on the sender's identity information and the importance of the request content.
[0026] Step S2: Divide the data to be encrypted, a, into slices according to the preset segmentation rules.
[0027] In the above steps, the maximum length of data encrypted using the RSA encryption algorithm is 117 bytes. For longer data, the RSA encryption algorithm cannot be directly used. Therefore, in this embodiment, when encrypting longer data 'a', the total byte length of 'a' is first compared with a preset byte length standard value to determine the corresponding segmentation point positions. Then, the data 'a' is segmented according to these segmentation point positions. This allows the data 'a' to be divided into multiple segments 'b', where each segment 'b' is less than or equal to the maximum length for encryption. For example, the preset segmentation rule can be: a length threshold of less than or equal to 117 bytes is preset; starting from the end of the data 'a', a segmentation point is set at intervals of one length threshold on the data 'a', until the data 'a' is divided into multiple segments 'b', and the length of each segment 'b' is less than or equal to the preset length threshold.
[0028] Step S3: Based on the RSA encryption algorithm, the sliced data b is segmented, encrypted, and concatenated to obtain the data c to be transmitted.
[0029] The splicing process is recorded, and then encrypted and packaged before being sent to the receiving end for decomposition.
[0030] In the above steps, the RSA encryption algorithm is an asymmetric encryption algorithm. The encryptor uses the public key of the key pair for encryption, while the receiver uses the private key to decrypt. Its basic principle is as follows: Figure 2 As shown. Specifically, as... Figure 3 As shown, the RSA key generation process specifically includes: Step S3-1: Randomly select two distinct prime numbers and calculate their common modulus and Euler's totient function. For example, assume the two prime numbers are p and q, where p = 65 and q = 71. Then calculate their product n = p * q = 4615, which in binary is 1001000000111, meaning the encryption algorithm has a byte length of 13 bits. The longer the bit length, the harder the algorithm is to crack. Typically, RSA keys are 1024 bits, and in important cases, 2048 bits. Next, calculate Euler's totient function: φ(n) = φ(p * q) = (p-1)(q-1), where φ(n) represents the number of positive integers less than or equal to n that are coprime to n. For example, among the numbers from 1 to 8, the numbers coprime to 8 are 1, 3, 5, and 7, so φ(n) = 4. With p=65 and q=71, φ(n)=64*70=4480, meaning there are 4480 numbers that are coprime to n (4615).
[0031] Step S3-2: Determine the public key for encryption according to the Euler's totient function, and calculate and obtain the private key for decryption using the public key. Specifically, determine the public key e for encryption according to 1 < e < φ(n), where the value of e must be an integer, and e and φ(n) must be relatively prime. Then calculate the private key: e * d % m = 1, where (φ(n) = m), so as to obtain the public key and the private key: public key = (e, n), private key = (d, n).
[0032] Step S3-3: The above communication terminal discloses the above public key and retains the private key. Thus, according to C = M e mod n to encrypt and generate the ciphertext, where C represents the ciphertext and M represents the plaintext; and decrypt according to M = C d mod n to generate the plaintext.
[0033] Exemplarily, the following takes p = 3 and q = 11 for key calculation: S1. Calculate the common modulus n: n = p * q = 3 * 11 = 33, so n = 33 is obtained; S2. Calculate the Euler's totient function φ(n): φ(n) = (p - 1)(q - 1) = 2 * 10 = 20; So φ(n) = 20 is obtained; S3. Calculate the public key e: 1 < e < 20, so the value range of e is prime numbers between 1 and 20: {3, 7, 9, 11, 13, 17, 19}, here take the smallest value e = 3, 3 and φ(n) = 20 are relatively prime and meet the conditions.
[0034] S4. Calculate the private key d: 3 * d % 20 = 1, and calculate d = 7; S5. Public key encryption: Take M = 3, C = 3 3 % 33 = 8, then "M = 3" becomes "C = 8" after RSA encryption.
[0035] S6. Private key decryption: M = 8 7 % 33 = 3, that is, the decrypted plaintext is 3.
[0036] Send the above data to be transmitted to the above communication terminal for decryption and data splicing according to the RSA decryption algorithm. Thus, the original data is obtained. [[ID=�5]]
[0037] Based on the same inventive concept, the present invention also proposes a computer data encryption system. Please refer to Figure 4 , Figure 4 which is the structural block diagram of a computer data encryption system provided in an embodiment of the present application. The system includes: A data extraction module 11, configured to extract the corresponding data a to be encrypted according to the data request information sent by the communication terminal; The data segmentation module 12 is used to segment the data to be encrypted, a, according to a preset segmentation rule, to generate slice data b. Segmented encryption module 13 is used to segment and encrypt sliced data b based on RSA encryption algorithm and then splice the data c to be transmitted. The data decryption module 14 is used to send the data to be transmitted c to the receiving end for decryption and data splicing according to the RSA decryption algorithm.
[0038] Please refer to Figure 5 , Figure 5 This is a structural block diagram of an electronic device provided in an embodiment of this application. The electronic device includes a memory 1, a processor 2, and a communication interface 3. The memory 1, processor 2, and communication interface 3 are electrically connected directly or indirectly to achieve data transmission or interaction. For example, these components can be electrically connected to each other through one or more communication buses or signal lines. The memory 1 can be used to store software programs and modules, such as the program instructions / modules corresponding to a computer data encryption system provided in an embodiment of this application. The processor 2 executes the software programs and modules stored in the memory 1 to perform various functional applications and data processing. The communication interface 3 can be used for signaling or data communication with other node devices.
[0039] The above description is merely a preferred embodiment of this application and is not intended to limit this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.
[0040] It will be apparent to those skilled in the art that this application is not limited to the details of the exemplary embodiments described above, and that this application can be implemented in other specific forms without departing from the spirit or essential characteristics of this application. Therefore, the embodiments should be considered illustrative and non-limiting in all respects, and the scope of this application is defined by the appended claims rather than the foregoing description. Thus, all variations falling within the meaning and scope of equivalents of the claims are intended to be included within this application. No reference numerals in the claims should be construed as limiting the scope of the claims.
Claims
1. A computer data encryption method, characterized in that, Including: The sending end extracts the corresponding data a to be encrypted according to the data request information; The data a to be encrypted is segmented according to a preset segmentation rule to generate sliced data b; After encrypting the sliced data b respectively based on the RSA encryption algorithm and then splicing them, the data c to be transmitted is obtained; The sending end sends the data c to be transmitted to the receiving end, and the receiving end decrypts and splices the data according to the RSA decryption algorithm.
2. The computer data encryption method as described in claim 1, characterized in that, The step in which the sending end extracts the corresponding data a to be encrypted according to the data request information includes: Obtain and parse the sent data request information, and carry the identity information and request content of the sender; Verify the identity information of the sender, and determine whether the identity belongs to the identity information in the user whitelist. If so, the verification passes; After the verification passes, the sending end extracts the corresponding data a to be encrypted according to the content of the data request information.
3. The computer data encryption method as described in claim 1, characterized in that, It also includes: Set a data encryption priority table according to the identity information of the sender and the importance of the request content; When multiple sending ends send data request information simultaneously, query the data encryption priority table to obtain the corresponding encryption priority; Process the extracted data a to be encrypted according to the encryption priority.
4. The computer data encryption method as described in claim 1, characterized in that, The step of segmenting the data a to be encrypted according to a preset segmentation rule includes: Compare the total byte length of the data a to be encrypted with a preset byte length standard value to determine the corresponding segmentation point position; Segment the data a to be encrypted according to the segmentation point position.
5. A computer data encryption method as described in claim 1, characterized in that, The generation process of the RSA encryption algorithm includes: Randomly select two different prime numbers and calculate their common modulus and Euler's totient function; Determine the public key for encryption according to Euler's totient function, and calculate and obtain the private key for decryption using the public key; The sending end and the receiving end make the public key public and keep the private key.
6. A computer data encryption method as described in claim 5, characterized in that, The process of two different prime numbers and calculating their common modulus and Euler's totient function: Step S3-1: Assume that the two prime numbers are p and q, where p = 65 and q = 71. Calculate their product n = p * q = 4615, which is converted to binary as 1001000000111, that is, the byte length of this encryption algorithm is 13 bits; The RSA key is either 1024 bits or 2048 bits; Calculate Euler's totient function: φ(n)=φ(p * q)=(p - 1)(q - 1), where φ(n) represents the number of positive integers less than or equal to n that are relatively prime to n; Step S3-2: Determine the public key for encryption according to Euler's totient function, and calculate and obtain the private key for decryption using the public key; specifically, determine the public key e for encryption according to 1 < e < φ(n), where the value of e must be an integer and e and φ(n) must be relatively prime numbers, and then calculate the private key: e * d % m = 1, where (φ(n)=m), so as to obtain the public key and private key: public key = (e, n), private key = (d, n); Step S3-3: The sender publishes the public key and keeps the private key secret, thus, according to C=M e The ciphertext is generated by encrypting with mod n, where C represents the ciphertext and M represents the plaintext; the receiving end uses M=C d The plaintext is generated by decrypting mod n.
7. A computer data encryption method according to claim 6, characterized in that Perform key calculation on p and q: S1, calculate the product of p and q as the common modulus n of n: n = p * q; S2, calculate the Euler's totient function φ(n): φ(n) = (p - 1)(q - 1); S3, calculate the public key e: 1 < e < φ(n), so the value range of e is: prime numbers between 1 and φ(n), e and φ(n) are relatively prime, meeting the conditions; S4, calculate the private key d: e * d % φ(n) = 1, calculate d; S5, Public Key Encryption: Set the value of M, C=M 3 %d, then "M" becomes "C" after RSA encryption; S6, decrypt with the private key: the decrypted plaintext is 3; Send the data c to be transmitted to the receiver for decryption and data splicing according to the RSA decryption algorithm to obtain the original data.
8. A computer data encryption system based on any one of the computer data encryption methods of claims 1-6, characterized in that, Include: A data extraction module, used to extract the corresponding data a to be encrypted according to the data request information sent by the sender; A data segmentation module, used to segment the data a to be encrypted according to a preset segmentation rule; A segmented encryption module, used to perform segmented encryption and splicing on the sliced data b respectively based on the RSA encryption algorithm to obtain the data c to be transmitted; A data decryption module, used to reverse the data c to be transmitted at the receiver to restore it to the fragmented data in the encrypted state, then decrypt it according to the RSA decryption algorithm, and then splice the decrypted sliced data b.
9. An electronic device based on any one of the computer data encryption methods of claims 1-6, characterized in that, Include: A memory, used to store one or more programs; A processor: when the one or more programs are executed by the processor, a computer data encryption method is implemented.
10. A computer-readable storage medium based on any one of the computer data encryption methods of claims 1-6, wherein a computer program is stored thereon, characterized in that, When the computer program is executed by the processor, a computer data encryption method is implemented.