Data encryption and decryption method, device, electronic device and storage medium
By converting the data to be encrypted to generate public keys and private keys, using asymmetric encryption and decryption methods, it solves the problems of symmetric encryption and plaintext key display, significantly improves the security of data transmission, and adapts to the dynamics of user privacy data. protection needs.
Patent Information
- Application Number
- CN202211124858.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-15
- Publication Date
- 2024-10-08
- Estimated Expiration
- 2042-09-15
AI Technical Summary
The existing technology uses symmetric encryption during the data transmission process, causing the key to be displayed in plain text, which reduces the security of the data.
By performing hexadecimal conversion on the data to be encrypted, the public key and private key are generated, and the asymmetric encryption and decryption method is used to avoid symmetric encryption and plaintext key display, thus improving the security of the data.
It achieves advanced encryption and decryption of data, avoids the display of keys in plain text, significantly improves the security of data transmission, and adapts to the dynamic protection needs of user privacy data.
Smart Images

Figure CN115589286B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data encryption and decryption, and in particular to a data encryption and decryption method, a data encryption and decryption device, an electronic device and a computer-readable storage medium. Background Art
[0002] With the continuous development of network technology, network security is a very important part of the network production process, and parameter encryption or data encryption is a common security measure in the data transmission process. However, related technologies often use symmetric encryption and display the key in plain text, which reduces the security of the data. Summary of the invention
[0003] The embodiments of the present invention provide a data encryption and decryption method, device, electronic device and computer-readable storage medium to solve the problem of how to improve the security of data.
[0004] An embodiment of the present invention discloses a data encryption and decryption method, which is applied to a first device, wherein the first device has a corresponding second device, and the second device is used to extract sub-data to be encrypted from the data to be encrypted according to a preset rule, and send the sub-data to be encrypted to the first device. The method may include:
[0005] receiving the sub-data to be encrypted sent by the second device;
[0006] Extracting sub-data to be encrypted from the data to be encrypted according to a preset rule;
[0007] Determine a first target base and a second target base by using the sub-data to be encrypted;
[0008] Converting the to-be-encrypted data into a first encrypted string using the first target base, and generating a public key using the first encrypted string;
[0009] Converting the to-be-encrypted data into a second encrypted string using the second target base, and generating a private key using the second encrypted string;
[0010] The public key is sent to the second device; the second device is used to encrypt the data to be encrypted using the public key and generate a ciphertext; the second device is also used to send the ciphertext to the first device;
[0011] The private key is used to decrypt the ciphertext, and the ciphertext is restored to the data to be encrypted.
[0012] Optionally, before the step of sending the public key to the second device, the method may further include:
[0013] Generate a decryption identifier for the private key through the sub-data to be encrypted; the private key and the decryption identifier have a first association relationship;
[0014] The decryption identifier is sent to the second device.
[0015] Optionally, the ciphertext and the decryption identifier have a second association relationship, and the step of using the private key to decrypt the ciphertext and restoring the ciphertext to the data to be encrypted may include:
[0016] Determine a target private key for the ciphertext using the first association relationship and the second association relationship;
[0017] The target private key is used to decrypt the ciphertext, and the ciphertext is restored to the data to be encrypted.
[0018] Optionally, the step of converting the data to be encrypted into a first encrypted string by using the first target base, and generating a public key by using the first encrypted string may include:
[0019] generating a first random number;
[0020] Determine a third target system using the first random number and the first target system;
[0021] The data to be encrypted is converted into a first encrypted string using the third target base, and a public key is generated using the first encrypted string.
[0022] Optionally, the step of converting the to-be-encrypted data into a second encrypted string by using the second target base, and generating a private key by using the second encrypted string may include:
[0023] generating a second random number;
[0024] Determine a fourth target system using the second random number and the second target system;
[0025] The data to be encrypted is converted into a second encrypted string using the fourth target base, and a private key is generated using the second encrypted string.
[0026] Optionally, the first device is configured with a base pool for converting bases.
[0027] The embodiment of the present invention further discloses a data encryption and decryption method, the method is applied to a second device, the second device has a corresponding first device, and the method may include:
[0028] Extracting sub-data to be encrypted from the data to be encrypted according to preset rules;
[0029] The sub-data to be encrypted is sent to the first device; the first device is used to receive the sub-data to be encrypted sent by the second device; a first target system and a second target system are determined by the sub-data to be encrypted; the data to be encrypted is converted into a first encrypted string by the first target system, and a public key is generated by the first encrypted string; the data to be encrypted is converted into a second encrypted string by the second target system, and a private key is generated by the second encrypted string; the public key is sent to the second device;
[0030] Encrypting the data to be encrypted using the public key and generating a ciphertext;
[0031] The ciphertext is sent to a first device; the first device is further configured to decrypt the ciphertext using the private key and restore the ciphertext to the data to be encrypted.
[0032] Optionally, the first device is used to generate a decryption identifier for the private key through the sub-data to be encrypted, and send the decryption identifier to the second device, the private key and the decryption identifier have a first association relationship, and the method may further include:
[0033] A decryption identifier sent by the first device is received.
[0034] Optionally, the ciphertext and the decryption identifier may have a second association relationship, and the first device may be used to determine a target private key for the ciphertext using the first association relationship and the second association relationship, may use the target private key to decrypt the ciphertext, and restore the ciphertext to the data to be encrypted.
[0035] The embodiment of the present invention further discloses a data encryption and decryption device, which is applied to a first device, the first device has a corresponding second device, the second device is used to extract sub-data to be encrypted from the data to be encrypted according to a preset rule, and send the sub-data to be encrypted to the first device, the device may include:
[0036] an encryption request information receiving module, configured to receive the sub-data to be encrypted sent by the second device;
[0037] An encrypted sub-data extraction module, used to extract the sub-data to be encrypted from the data to be encrypted according to a preset rule;
[0038] A first target system determination module, used to determine a first target system and a second target system according to the sub-data to be encrypted;
[0039] A public key generation module, used for converting the to-be-encrypted data into a first encrypted string by using the first target base, and generating a public key by using the first encrypted string;
[0040] a private key generation module, configured to convert the to-be-encrypted data into a second encrypted string using the second target base, and generate a private key using the second encrypted string;
[0041] a public key sending module, used to send the public key to the second device; the second device is used to encrypt the data to be encrypted using the public key and generate a ciphertext; the second device is also used to send the ciphertext to the first device;
[0042] The ciphertext decryption module is used to decrypt the ciphertext using the private key and restore the ciphertext to the data to be encrypted.
[0043] Optionally, it may also include:
[0044] A decryption identifier generating module, used to generate a decryption identifier for the private key through the sub-data to be encrypted; the private key and the decryption identifier have a first association relationship;
[0045] A decryption identifier sending module is used to send the decryption identifier to the second device.
[0046] Optionally, the ciphertext and the decryption identifier have a second association relationship, and the ciphertext decryption module may include:
[0047] a target private key determination submodule, configured to determine a target private key for the ciphertext by using the first association relationship and the second association relationship;
[0048] The ciphertext decryption submodule is used to decrypt the ciphertext using the target private key and restore the ciphertext to the data to be encrypted.
[0049] Optionally, the public key generation module may include:
[0050] A first random number generation submodule, used to generate a first random number;
[0051] A third target system determination submodule, configured to determine a third target system using the first random number and the first target system;
[0052] The public key generation submodule is used to convert the to-be-encrypted data into a first encrypted string using the third target base, and generate a public key using the first encrypted string.
[0053] Optionally, the private key generation module may include:
[0054] A second random number generation submodule, used to generate a second random number;
[0055] A fourth target system determination submodule, configured to determine a fourth target system using the second random number and the second target system;
[0056] The private key generation submodule is used to convert the to-be-encrypted data into a second encrypted string using the fourth target base, and generate a private key using the second encrypted string.
[0057] Optionally, the first device may be configured with a base pool for converting bases.
[0058] The embodiment of the present invention further discloses a data encryption and decryption device, which is applied to a second device, the second device has a corresponding first device, and the device may include:
[0059] The encryption request information generation module is used to extract the sub-data to be encrypted from the data to be encrypted according to a preset rule;
[0060] The encryption information sending request module is used to send the sub-data to be encrypted to the first device; the first device is used to receive the sub-data to be encrypted sent by the second device; determine a first target system and a second target system through the sub-data to be encrypted; convert the data to be encrypted into a first encrypted string through the first target system, and generate a public key through the first encrypted string; convert the data to be encrypted into a second encrypted string through the second target system, and generate a private key through the second encrypted string; and send the public key to the second device;
[0061] A ciphertext generation module, used to encrypt the data to be encrypted using the public key and generate a ciphertext;
[0062] The ciphertext sending module is used to send the ciphertext to the first device; the first device is also used to decrypt the ciphertext using the private key and restore the ciphertext to the data to be encrypted.
[0063] Optionally, the first device is used to generate a decryption identifier for the private key through the sub-data to be encrypted, and send the decryption identifier to the second device, the private key and the decryption identifier have a first association relationship, and the apparatus may further include:
[0064] The decryption identifier sending module is used to receive the decryption identifier sent by the first device.
[0065] Optionally, the ciphertext and the decryption identifier may have a second association relationship, and the first device may be used to determine a target private key for the ciphertext using the first association relationship and the second association relationship, may use the target private key to decrypt the ciphertext, and restore the ciphertext to the data to be encrypted.
[0066] The embodiment of the present invention further discloses an electronic device, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;
[0067] The memory is used to store computer programs;
[0068] The processor is used to implement the method described in the embodiment of the present invention when executing the program stored in the memory.
[0069] The embodiment of the present invention further discloses a computer-readable storage medium on which instructions are stored. When executed by one or more processors, the processors are enabled to execute the method described in the embodiment of the present invention.
[0070] The embodiments of the present invention include the following advantages:
[0071] In an embodiment of the present invention, the sub-data to be encrypted is received by a second device; the sub-data to be encrypted is extracted from the data to be encrypted according to a preset rule; a first target system and a second target system are determined by the sub-data to be encrypted; the data to be encrypted is converted into a first encrypted string by the first target system, and a public key is generated by the first encrypted string; the data to be encrypted is converted into a second encrypted string by the second target system, and a private key is generated by the second encrypted string; the ciphertext is decrypted by the private key, and the ciphertext is restored to the data to be encrypted, thereby avoiding encrypting the encrypted data in a symmetric encryption form, and also avoiding displaying the key in plain text, thereby improving the security of the data. BRIEF DESCRIPTION OF THE DRAWINGS
[0072] Figure 1 is a structural diagram of a first device and a second device provided in an embodiment of the present invention;
[0073] Figure 2 This is a flowchart of a data encryption and decryption method provided in Embodiment 1 of the present invention;
[0074] Figure 3 is a flowchart of another data encryption and decryption method provided in an embodiment of the present invention;
[0075] Figure 4 is a flowchart of another method for data encryption and decryption provided in an embodiment of the present invention;
[0076] Figure 5 This is a flowchart of a data encryption and decryption method provided in Embodiment 2 of the present invention;
[0077] Figure 6 It is a structural block diagram of a data encryption and decryption device provided in Embodiment 3 of the present invention;
[0078] Figure 7 It is a structural block diagram of a data encryption and decryption device provided in Embodiment 4 of the present invention;
[0079] Figure 8 It is a hardware structure block diagram of an electronic device provided in each embodiment of the present invention. DETAILED DESCRIPTION
[0080] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0081] In practical applications, with the continuous development of network technology, network security is a very important part of the network production process, and parameter encryption or data encryption is a very common security means in the data transmission process. In the traditional telecommunications industry, mobile phone numbers are often the carriers of various user information. Obtaining a user's mobile phone number can obtain a large amount of user information. Most of the encryption algorithms used in related technologies are unified encryption methods, and the encryption keys are almost dynamic and unchanged, which cannot adapt to the telecommunications industry's protection of user privacy data. One of the important cores of the embodiments of the present invention is that the proposed dynamic encryption and decryption algorithm for encrypted data based on base conversion uses an asymmetric encryption and decryption method to generate public keys and private keys by performing different base conversions on the encrypted data, so that each request is different according to the mobile phone number, thereby greatly improving the security level of user privacy protection.
[0082] The data encryption and decryption method provided by the embodiment of the present invention can be applied to Figure 1In the application environment shown. Among them, the first device 102 communicates with the second device 104 through the network. Specifically, the first device 102 can receive the request encryption information sent by the second device 104, and the data to be encrypted corresponding to the request encryption information; the first device 102 can extract the sub-data to be encrypted from the data to be encrypted according to the preset rules; the first device 102 can determine the first target system and the second target system through the sub-data to be encrypted; the first device 102 can convert the data to be encrypted into a first encrypted string through the first target system, and generate a public key through the first encrypted string; the first device 102 can convert the data to be encrypted into a second encrypted string through the second target system, and generate a private key through the second encrypted string; the first device 102 can send the public key to the second device 104; the second device 104 can be used to encrypt the data to be encrypted using the public key and generate a ciphertext; the second device 104 can also be used to send the ciphertext to the first device 102; the first device 102 can decrypt the ciphertext using the private key and restore the ciphertext to the data to be encrypted.
[0083] In actual applications, the terminal device 102 may include but is not limited to a decryption server, and the second device 104 may be a data encryption device.
[0084] Embodiment 1
[0085] Reference Figure 2 , shows a flowchart of a data encryption and decryption method provided in Embodiment 1 of the present invention, which may specifically include the following steps:
[0086] Step 201, receiving the sub-data to be encrypted sent by the second device;
[0087] Step 202, extracting sub-data to be encrypted from the data to be encrypted according to a preset rule;
[0088] Step 203, determining a first target base and a second target base by using the sub-data to be encrypted;
[0089] Step 204, converting the data to be encrypted into a first encrypted string using the first target base, and generating a public key using the first encrypted string;
[0090] Step 205, converting the data to be encrypted into a second encrypted string using the second target base, and generating a private key using the second encrypted string;
[0091] Step 206: Send the public key to the second device; the second device is used to encrypt the data to be encrypted using the public key and generate a ciphertext; the second device is also used to send the ciphertext to the first device;
[0092] Step 207: Decrypt the ciphertext using the private key and restore the ciphertext to the data to be encrypted.
[0093] In a specific implementation, the first device in the embodiment of the present invention may be a decryption device, for example, a decryption server, and the second device may be an encryption device.
[0094] In an embodiment of the present invention, a second device can generate a request encryption message, where the request encryption message has corresponding data to be encrypted. The second device can also respond to the request encryption message, extract sub-data to be encrypted from the data to be encrypted according to preset rules, and then send the request encryption message and the sub-data to be encrypted to the first device. For example, the second device can obtain the user's mobile phone number. When the user needs to encrypt the mobile phone number, the second device can generate a request encryption message corresponding to the mobile phone number. Assuming that the user's mobile phone number is 19110411217, the second device can respond to the request encryption message, extract the last four digits "1217" of 19110411217 as the sub-data to be encrypted, and send the request encryption message and the sub-data to be encrypted "1217" to the first device.
[0095] Of course, the above examples are only for illustration, and those skilled in the art can extract numbers of any digit as sub-data to be encrypted, and the embodiments of the present invention are not limited to this.
[0096] After extracting the sub-data to be encrypted, the first device of the embodiment of the present invention can generate a key for the data to be encrypted in response to the encryption request information. Specifically, the first target base and the second target base can be determined by the sub-data to be encrypted. Optionally, the first target base and the second target base are any bases from 2 to 36.
[0097] For example, assuming that the user's mobile phone number is 19110411217, the second device can respond to the request for encryption information, extract the last four digits "1217" of 19110411217 as the sub-data to be encrypted, and send the sub-data to be encrypted to the first device; assuming that the first digit a=1, the second digit b=2, the third digit c=1, and the fourth digit d=7 of the sub-data to be encrypted "1217", the first device can determine the first target system (public key system) A=1*1+(1+1)=3, and the second target system (private key system) B=2*7+(2+7)=23.
[0098] Of course, the above examples are only for illustration, and those skilled in the art may use other algorithms to determine the first target system and the second target system through the sub-data to be encrypted, and the embodiments of the present invention do not limit this.
[0099] Symmetric encryption algorithms use the same secret key for encryption and decryption; while asymmetric encryption algorithms require two keys for encryption and decryption, which are a public key (public key for short) and a private key (private key for short).
[0100] Unlike symmetric encryption algorithms, asymmetric encryption algorithms require two keys: a public key and a private key. The public key and the private key are a pair. If the public key is used to encrypt data, it can only be decrypted with the corresponding private key; if the private key is used to encrypt data, it can only be decrypted with the corresponding public key. Because two different keys are used for encryption and decryption, this algorithm is called an asymmetric encryption algorithm.
[0101] The encryption and decryption process of data is controlled by cryptographic systems and keys. The security of cryptographic systems depends on the security of keys. Modern cryptography does not pursue the confidentiality of encryption algorithms, but the completeness of encryption algorithms, that is, to make it impossible for attackers to find a breakthrough in the algorithm without knowing the key. Depending on whether the keys used in the encryption and decryption algorithms are the same, or whether the decryption (encryption) key can be simply obtained from the encryption (decryption) key, cryptographic systems can be divided into symmetric cryptographic systems and asymmetric cryptographic systems.
[0102] Asymmetric cryptographic systems are also called public key encryption technology. This technology was proposed to address the defects of private key cryptographic systems (symmetric encryption algorithms). Unlike symmetric cryptographic systems, in public key cryptographic systems, encryption and decryption are relatively independent. Encryption and decryption use two different keys. The encryption key (public key) is open to the public and can be used by anyone. The decryption key (secret key) is only known to the decryptor himself. Illegal users cannot deduce the decryption key based on the public encryption key, which greatly strengthens information protection. The public key cryptographic system not only solves the problem of key distribution, but also provides a means for signature and authentication.
[0103] After determining the first target system, the embodiment of the present invention can convert the data to be encrypted into a first encrypted string using the first target system, and generate a public key using the first encrypted string.
[0104] For example, assuming that the user's mobile phone number is 19110411217, the second device can respond to the request for encryption information, extract the last four digits "1217" of 19110411217 as the sub-data to be encrypted, and send the sub-data to be encrypted to the first device; assuming that the first digit a=1, the second digit b=2, the third digit c=1, and the fourth digit d=7 of the sub-data to be encrypted "1217", the first device can determine the first target system (public key system) A=1*1+(1+1)=3, and the first device can also perform a 3-base conversion on 19110411217 to generate a string "1211022211121110212001" as the first encrypted string. In order to distinguish it from the private key, it can be configured with an identifier "G" to generate a public key "G1211022211121110212001".
[0105] After determining the second target system, the embodiment of the present invention can convert the data to be encrypted into a second encrypted string using the second target system, and generate a private key using the second encrypted string.
[0106] For example, assuming that the user's mobile phone number is 19110411217, the second device can respond to the request for encryption information, extract the last four digits "1217" of 19110411217 as the sub-data to be encrypted, and send the sub-data to be encrypted to the first device; assuming that the first digit a=1, the second digit b=2, the third digit c=1, and the fourth digit d=7 of the sub-data to be encrypted "1217", the first device can determine the second target system (private key system) B=2*7+(2+7)=23. At the same time, the first device can convert 19110411217 into base 23 to generate a string "5e235g15" as the second encrypted string. In order to distinguish it from the public key, it can be configured with an identifier "S" to generate a private key "S5e235g15".
[0107] After generating the public key and the private key, the embodiment of the present invention can send the public key to the second device, and the second device can use the public key to encrypt the data to be encrypted and generate a ciphertext. When the ciphertext needs to be decrypted, the second device can send the ciphertext to the first device, and the first device can use the private key to decrypt the ciphertext and restore the ciphertext to the data to be encrypted.
[0108] In an embodiment of the present invention, the sub-data to be encrypted is received by a second device; the sub-data to be encrypted is extracted from the data to be encrypted according to a preset rule; a first target system and a second target system are determined by the sub-data to be encrypted; the data to be encrypted is converted into a first encrypted string by the first target system, and a public key is generated by the first encrypted string; the data to be encrypted is converted into a second encrypted string by the second target system, and a private key is generated by the second encrypted string; the ciphertext is decrypted by the private key, and the ciphertext is restored to the data to be encrypted, thereby avoiding encrypting the encrypted data in a symmetric encryption form, and also avoiding displaying the key in plain text, thereby improving the security of the data.
[0109] Based on the above embodiment, a variant embodiment of the above embodiment is proposed. It should be noted that in order to make the description concise, only the differences from the above embodiment are described in the variant embodiment.
[0110] In an optional embodiment of the present invention, before the step of sending the public key to the second device, the method further includes:
[0111] Generate a decryption identifier for the private key through the sub-data to be encrypted; the private key and the decryption identifier have a first association relationship;
[0112] sending the decryption identifier to the second device;
[0113] The ciphertext and the decryption identifier have a second association relationship, and the step of using the private key to decrypt the ciphertext and restoring the ciphertext to the data to be encrypted includes:
[0114] Determine a target private key for the ciphertext using the first association relationship and the second association relationship;
[0115] The target private key is used to decrypt the ciphertext, and the ciphertext is restored to the data to be encrypted.
[0116] In actual applications, the first device and the second device usually encrypt and decrypt more than one piece of data to be encrypted. Therefore, in an embodiment of the present invention, before sending the public key to the second device, the first device can first generate a decryption identifier for the private key and having a first association relationship with the private key through the sub-data to be encrypted, and then the first device can send the decryption identifier to the second device. After the second device receives the decryption identifier sent by the first device and generates a ciphertext having a second association relationship with the decryption identifier, the second device can package the ciphertext and the decryption identifier together and send them to the first device. The first device can determine the target private key from multiple private keys through the second association relationship between the decryption identifier and the ciphertext and the first association relationship between the decryption identifier and the private key, and decrypt the ciphertext through the target private key.
[0117] In a specific implementation, the decryption identifier can be a key-value pair. The original meaning of key-value is key and value. It is usually used as a key-value pair in computer applications. In a key-value pair, value can be a value. Therefore, the embodiment of the present invention can use a private key as a value. When determining the target private key, the target private key can be determined from many private keys through the value as the first association relationship, and the key can be a public key, or other values that can be used to establish a second association relationship.
[0118] The embodiment of the present invention generates a decryption identifier for the private key through the sub-data to be encrypted before the step of sending the public key to the second device; the private key and the decryption identifier have a first association relationship; the decryption identifier is sent to the second device; the ciphertext and the decryption identifier have a second association relationship, and the first association relationship and the second association relationship are used to determine the target private key for the ciphertext; the ciphertext is decrypted using the target private key, and the ciphertext is restored to the data to be encrypted, so that when encryption and decryption are performed on multiple data to be encrypted, it can also be ensured that the private key corresponding to the ciphertext can be quickly determined, thereby improving the efficiency of decrypting the encrypted data.
[0119] In an optional embodiment of the present invention, the step of converting the to-be-encrypted data into a first encrypted string by using the first target base, and generating a public key by using the first encrypted string includes:
[0120] generating a first random number;
[0121] Determine a third target system using the first random number and the first target system;
[0122] The data to be encrypted is converted into a first encrypted string using the third target base, and a public key is generated using the first encrypted string.
[0123] In actual applications, the relevant technology will use a "fixed key" method to encrypt data. For example, each time the same mobile phone number is encrypted, the generated key is the same. That is, the prior art does not have a mechanism to update the key and cannot adapt to the security level required for mobile phone number encryption. Therefore, the embodiment of the present invention can generate a first random number, and then use the first random number and the first target system to determine the third target system, and then use the third target system to convert the data to be encrypted into a first encrypted string, and generate a public key through the first encrypted string.
[0124] For example, assuming that the user's mobile phone number is 19110411217, the second device can respond to the request for encryption information, extract the last four digits "1217" of 19110411217 as the sub-data to be encrypted, and send the sub-data to be encrypted to the first device; assuming that the first digit a=1, the second digit b=2, the third digit c=1, and the fourth digit d=7 of the sub-data to be encrypted "1217", the first device can determine the first target system (public key system) A=1*1+(1+1)=3, and then generate the first random number 6, 3+6=9. The first device can also convert 19110411217 into base 9 to generate the string "54284543761" as the first encrypted string. In order to distinguish it from the private key, it can be configured with an identifier "G" to generate a public key "G54284543761".
[0125] Of course, those skilled in the art may determine the third target system using the first random number and the first target system based on other algorithms, and this embodiment of the present invention does not limit this.
[0126] In the embodiment of the present invention, a first random number is generated; a third target system is determined using the first random number and the first target system; the data to be encrypted is converted into a first encrypted string using the third target system, and a public key is generated using the first encrypted string, thereby avoiding the use of a fixed key to generate a public key, thereby further improving the security of the data to be encrypted.
[0127] In an optional embodiment of the present invention, the step of converting the data to be encrypted into a second encrypted string by using the second target base, and generating a private key by using the second encrypted string includes:
[0128] generating a second random number;
[0129] Determine a fourth target system using the second random number and the second target system;
[0130] The data to be encrypted is converted into a second encrypted string using the fourth target base, and a private key is generated using the second encrypted string.
[0131] In actual applications, the relevant technology will use a "fixed key" method to encrypt data. For example, each time the same mobile phone number is encrypted, the generated key is the same. That is, the prior art does not have a mechanism for updating the key and cannot adapt to the security level required for mobile phone number encryption. Therefore, the embodiment of the present invention can generate a second random number, and then use the second random number and the second target system to determine the fourth target system, and then use the fourth target system to convert the data to be encrypted into a second encrypted string, and generate a private key through the second encrypted string.
[0132] For example, assuming that the user's mobile phone number is 19110411217, the second device can respond to the request for encryption information, extract the last four digits "1217" of 19110411217 as the sub-data to be encrypted, and send the sub-data to be encrypted to the first device; assuming that the first digit a=1, the second digit b=2, the third digit c=1, and the fourth digit d=7 of the sub-data to be encrypted "1217", the first device can determine the second target system (private key system) B=2*7+(2+7)=23, generate a second random number 2, 23+2=25, and the first device can also convert 19110411217 into base 25 to generate a string "336mg7nh" as the second encrypted string. In order to distinguish it from the public key, it can be configured with an identifier "S" to generate a private key "S336mg7nh".
[0133] Of course, those skilled in the art may determine the fourth target system using the second random number and the second target system based on other algorithms, and this embodiment of the present invention does not limit this.
[0134] In the embodiment of the present invention, a second random number is generated, and then a fourth target system is determined using the second random number and the second target system. The data to be encrypted is then converted into a second encrypted string using the fourth target system, and a private key is generated using the second encrypted string, thereby avoiding the use of a fixed key to generate a private key, thereby further improving the security of the data to be encrypted.
[0135] Optionally, the embodiment of the present invention deletes the private key and the public key after the encrypted data is decrypted using the private key. The embodiment of the present invention can destroy the private key and the public key after the encrypted data is decrypted using the private key, thereby further ensuring the security of the encrypted data.
[0136] In an optional embodiment of the present invention, the first device is configured with a base pool for converting bases.
[0137] In practical applications, if base conversion needs to be done manually every time, it will lead to increased costs and low efficiency. Therefore, in an embodiment of the present invention, a base pool for converting bases can be configured for the first device. When base conversion of data is required, the first encrypted string and / or the second encrypted string can be automatically generated by the following formula.
[0138] Base conversion formula:
[0139] abcd=a*X (n-1) +b*X (n-1) +c*X (n-1)
[0140] Here, X represents the base and n represents the number of digits.
[0141] In order to enable those skilled in the art to better understand the embodiments of the present invention, a complete example is used below to illustrate the embodiments of the present invention.
[0142] refer to Figure 3 , Figure 3 It is a step flow chart of another data encryption and decryption method provided in an embodiment of the present invention. The decryption party (first device) in the embodiment of the present invention can be configured with a data interface for sending a public key to the encryption party (second device). Before encrypting data, the encryption party can first access the data interface to obtain the public key and decryption ID. The encryption party needs to carry the decryption ID when transmitting encrypted data. The decryption party obtains the private key through the decryption ID for decryption.
[0143] Specifically, please refer to Figure 4 , Figure 4: is a flowchart of another method for data encryption and decryption provided in an embodiment of the present invention. The first device can generate a base pool. Assuming that the user's mobile phone number is 19110411217, the second device can respond to the request for encryption information, extract the last four digits "1217" of 19110411217 as the sub-data to be encrypted, and send the sub-data to be encrypted to the first device. Assuming that the first digit a of the last four digits "1217" is 1, the second digit b is 2, the third digit c is 1, and the fourth digit d is 7, the first device can determine the first target base ( Public key system) A=1*1+(1+1)=3, and then generate the first random number 6, 3+6=9, then 19110411217 can be converted into 9-base to generate the string "54284543761" as the first encrypted string. In order to distinguish it from the private key, it can be configured with an identifier "G" to generate the public key "G54284543761"; the first device can also determine the second target system (private key system) B=2*7+(2+7)=23, and generate the second random number 2, 23+2=25 , 19110411217 can be converted into base 25 to generate a string "336mg7nh" as the second encrypted string. In order to distinguish it from the public key, an identifier "S" can be configured for it to generate a private key "S336mg7nh", where the minimum base number is binary and the maximum is hexadecimal. This process can be completed by the base pool set at the decryption party based on the base conversion formula; a key-value pair key-value is generated as a decryption ID, and value can be used as a first association to determine the target private key from many private keys, and key can be a public key, or other values that can be used to establish a second association; the decryption party sends the public key and decryption ID to the encryption party, and the encryption party encrypts the mobile phone number with the public key; when the data transmission party completes the encryption, it needs to transmit the decryption ID to the data recipient, and the decryption ID is unique and can only be used once; the data recipient requests a private key acquisition method through the decryption base ID, determines the decryption base through the base ID, generates a private key and decrypts, and after the decryption is completed, destroys the public key and private key.
[0144] Base conversion formula:
[0145] abcd=a*X (n-1) +b*X (n-1) +c*X (n-1)
[0146] Here, X represents the base and n represents the number of digits.
[0147] Through the above method, symmetric encryption is avoided, the key is avoided from being displayed in plain text, and a pair of public and private keys are allocated for one request. They can be regenerated for each request and destroyed after use. Even if the secret key is hacked or leaked, only the data of a single user will be lost, which better protects the security of user data and greatly improves the security level of mobile phone number encryption.
[0148] Embodiment 2
[0149] Reference Figure 5 , shows a flow chart of the steps of a data encryption and decryption method provided in Embodiment 2 of the present invention, which may specifically include the following steps:
[0150] Step 501, extracting sub-data to be encrypted from the data to be encrypted according to a preset rule;
[0151] Step 502, sending the sub-data to be encrypted to the first device;
[0152] Step 503, encrypt the data to be encrypted using the public key and generate a ciphertext;
[0153] Step 504: Send the ciphertext to the first device; the first device is further configured to decrypt the ciphertext using the private key and restore the ciphertext to the data to be encrypted.
[0154] In a specific implementation, an embodiment of the present invention can be applied to a second device. Specifically, the second device can be an encryption party device, such as an encryption server, an encryption terminal device, etc. The first device can be used to receive the sub-data to be encrypted sent by the second device; determine a first target system and a second target system through the sub-data to be encrypted; convert the data to be encrypted into a first encrypted string through the first target system, and generate a public key through the first encrypted string; convert the data to be encrypted into a second encrypted string through the second target system, and generate a private key through the second encrypted string; and send the public key to the second device.
[0155] In an optional embodiment of the present invention, the first device is used to generate a decryption identifier for the private key through the sub-data to be encrypted, and send the decryption identifier to the second device, the private key and the decryption identifier have a first association relationship, and the method further includes:
[0156] A decryption identifier sent by the first device is received.
[0157] In an optional embodiment of the present invention, the ciphertext and the decryption identifier have a second association relationship, and the first device is used to use the first association relationship and the second association relationship to determine a target private key for the ciphertext, use the target private key to decrypt the ciphertext, and restore the ciphertext to the data to be encrypted.
[0158] The embodiment of the present invention extracts sub-data to be encrypted from the data to be encrypted according to a preset rule; sends the sub-data to be encrypted to the first device; the first device is used to receive the sub-data to be encrypted sent by the second device; determines a first target system and a second target system through the sub-data to be encrypted; converts the data to be encrypted into a first encrypted string through the first target system, and generates a public key through the first encrypted string; converts the data to be encrypted into a second encrypted string through the second target system, and generates a private key through the second encrypted string; sends the public key to the second device; encrypts the data to be encrypted using the public key and generates a ciphertext; sends the ciphertext to the first device; the first device is also used to decrypt the ciphertext using the private key and restore the ciphertext to the data to be encrypted, thereby avoiding encrypting the encrypted data in the form of symmetric encryption, and also avoiding displaying the key in plain text, thereby improving the security of the data.
[0159] As for the second embodiment, since it is basically similar to the first embodiment on the first device side, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0160] It should be noted that, for the sake of simplicity, the method embodiments are described as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.
[0161] Embodiment 3
[0162] Reference Figure 6 , shows a structural block diagram of a data encryption and decryption device provided in Embodiment 3 of the present invention, which may specifically include the following modules:
[0163] The encryption request information receiving module 601 is used to receive the sub-data to be encrypted sent by the second device;
[0164] The encrypted sub-data extraction module 602 is used to extract the sub-data to be encrypted from the data to be encrypted according to a preset rule;
[0165] A first target system determination module 603, configured to determine a first target system and a second target system according to the sub-data to be encrypted;
[0166] A public key generation module 604, configured to convert the to-be-encrypted data into a first encrypted string using the first target base, and generate a public key using the first encrypted string;
[0167] A private key generation module 605, configured to convert the to-be-encrypted data into a second encrypted string using the second target base, and generate a private key using the second encrypted string;
[0168] A public key sending module 606 is used to send the public key to the second device; the second device is used to encrypt the data to be encrypted using the public key and generate a ciphertext; the second device is also used to send the ciphertext to the first device;
[0169] The ciphertext decryption module 607 is used to decrypt the ciphertext using the private key and restore the ciphertext to the data to be encrypted.
[0170] Embodiment 4
[0171] Reference Figure 7 , shows a structural block diagram of a data encryption and decryption device provided in Embodiment 4 of the present invention, which may specifically include the following modules:
[0172] The encryption request information generation module 701 is used to extract the sub-data to be encrypted from the data to be encrypted according to a preset rule;
[0173] The encryption information request sending module 702 is used to send the sub-data to be encrypted to the first device; the first device is used to receive the sub-data to be encrypted sent by the second device; determine the first target system and the second target system through the sub-data to be encrypted; convert the data to be encrypted into a first encrypted string through the first target system, and generate a public key through the first encrypted string; convert the data to be encrypted into a second encrypted string through the second target system, and generate a private key through the second encrypted string; send the public key to the second device;
[0174] The ciphertext generation module 703 is used to encrypt the data to be encrypted using the public key and generate ciphertext;
[0175] The ciphertext sending module 704 is used to send the ciphertext to the first device; the first device is also used to decrypt the ciphertext using the private key and restore the ciphertext to the data to be encrypted.
[0176] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0177] In addition, an embodiment of the present invention further provides an electronic device, including: a processor, a memory, and a computer program stored in the memory and executable on the processor. When the computer program is executed by the processor, the various processes of the above-mentioned data encryption and decryption method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.
[0178] The embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, each process of the above-mentioned data encryption and decryption method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it is not repeated here. The computer-readable storage medium is, for example, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0179] Figure 8 A schematic diagram of the hardware structure of an electronic device for implementing various embodiments of the present invention.
[0180] The electronic device 800 includes but is not limited to: a radio frequency unit 801, a network module 802, an audio output unit 803, an input unit 804, a sensor 805, a display unit 806, a user input unit 807, an interface unit 808, a memory 809, a processor 810, and a power supply 811. Those skilled in the art will appreciate that Figure 8 The electronic device structure shown in the figure does not constitute a limitation on the electronic device, and the electronic device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently. In the embodiments of the present invention, the electronic device includes but is not limited to a mobile phone, a tablet computer, a laptop computer, a PDA, a vehicle-mounted terminal, a wearable device, and a pedometer.
[0181] It should be understood that in the embodiment of the present invention, the radio frequency unit 801 can be used for receiving and sending signals during information transmission or communication. Specifically, after receiving downlink data from the base station, it is sent to the processor 810 for processing; in addition, uplink data is sent to the base station. Generally, the radio frequency unit 801 includes but is not limited to an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier, a duplexer, etc. In addition, the radio frequency unit 801 can also communicate with the network and other devices through a wireless communication system.
[0182] The electronic device provides users with wireless broadband Internet access through the network module 802, such as helping users to send and receive emails, browse web pages, and access streaming media.
[0183] The audio output unit 803 can convert the audio data received by the RF unit 801 or the network module 802 or stored in the memory 809 into an audio signal and output it as sound. Moreover, the audio output unit 803 can also provide audio output related to a specific function performed by the electronic device 800 (for example, a call signal reception sound, a message reception sound, etc.). The audio output unit 803 includes a speaker, a buzzer, a receiver, etc.
[0184] The input unit 804 is used to receive audio or video signals. The input unit 804 may include a graphics processor (GPU) 8041 and a microphone 8042, and the graphics processor 8041 processes the image data of a static picture or video obtained by an image capture device (such as a camera) in a video capture mode or an image capture mode. The processed image frame can be displayed on the display unit 806. The image frame processed by the graphics processor 8041 can be stored in the memory 809 (or other storage medium) or sent via the radio frequency unit 801 or the network module 802. The microphone 8042 can receive sound and can process such sound into audio data. The processed audio data can be converted into a format output that can be sent to a mobile communication base station via the radio frequency unit 801 in the case of a telephone call mode.
[0185] The electronic device 800 also includes at least one sensor 805, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor includes an ambient light sensor and a proximity sensor, wherein the ambient light sensor can adjust the brightness of the display panel 8061 according to the brightness of the ambient light, and the proximity sensor can turn off the display panel 8061 and / or the backlight when the electronic device 800 is moved to the ear. As a type of motion sensor, the accelerometer sensor can detect the magnitude of acceleration in each direction (generally three axes), and can detect the magnitude and direction of gravity when stationary, which can be used to identify the posture of the electronic device (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer, tapping), etc.; the sensor 805 can also include a fingerprint sensor, a pressure sensor, an iris sensor, a molecular sensor, a gyroscope, a barometer, a hygrometer, a thermometer, an infrared sensor, etc., which will not be repeated here.
[0186] The display unit 806 is used to display information input by the user or information provided to the user. The display unit 806 may include a display panel 8061, which may be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), or the like.
[0187] The user input unit 807 can be used to receive input digital or character information, and to generate key signal input related to user settings and function control of the electronic device. Specifically, the user input unit 807 includes a touch panel 8071 and other input devices 8072. The touch panel 8071, also known as a touch screen, can collect the user's touch operation on or near it (such as the user's operation on the touch panel 8071 or near the touch panel 8071 using any suitable object or accessory such as a finger, stylus, etc.). The touch panel 8071 may include two parts: a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch orientation, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into the contact point coordinates, and then sends it to the processor 810, receives the command sent by the processor 810 and executes it. In addition, the touch panel 8071 can be implemented using multiple types such as resistive, capacitive, infrared and surface acoustic waves. In addition to the touch panel 8071, the user input unit 807 may also include other input devices 8072. Specifically, other input devices 8072 may include but are not limited to a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, and a joystick, which will not be described in detail here.
[0188] Furthermore, the touch panel 8071 may be overlaid on the display panel 8061. When the touch panel 8071 detects a touch operation on or near it, it transmits the information to the processor 810 to determine the type of the touch event. Then, the processor 810 provides a corresponding visual output on the display panel 8061 according to the type of the touch event. Figure 8 In the figure, the touch panel 8071 and the display panel 8061 are used as two independent components to realize the input and output functions of the electronic device. However, in some embodiments, the touch panel 8071 and the display panel 8061 can be integrated to realize the input and output functions of the electronic device, which is not limited here.
[0189] The interface unit 808 is an interface for connecting an external device to the electronic device 800. For example, the external device may include a wired or wireless headset port, an external power supply (or battery charger) port, a wired or wireless data port, a memory card port, a port for connecting a device with an identification module, an audio input / output (I / O) port, a video I / O port, a headphone port, etc. The interface unit 808 may be used to receive input (e.g., data information, power, etc.) from an external device and transmit the received input to one or more elements within the electronic device 800 or may be used to transmit data between the electronic device 800 and an external device.
[0190] The memory 809 can be used to store software programs and various data. The memory 809 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, at least one application required for a function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data created according to the use of the mobile phone (such as audio data, a phone book, etc.), etc. In addition, the memory 809 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0191] The processor 810 is the control center of the electronic device. It uses various interfaces and lines to connect various parts of the entire electronic device. By running or executing software programs and / or modules stored in the memory 809 and calling data stored in the memory 809, it performs various functions of the electronic device and processes data, thereby monitoring the electronic device as a whole. The processor 810 may include one or more processing units; preferably, the processor 810 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 810.
[0192] The electronic device 800 may also include a power supply 811 (such as a battery) for supplying power to each component. Preferably, the power supply 811 may be logically connected to the processor 810 through a power management system, thereby implementing functions such as charging, discharging, and power consumption management through the power management system.
[0193] In addition, the electronic device 800 includes some functional modules not shown, which will not be described in detail here.
[0194] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0195] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for enabling a terminal (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present invention.
[0196] The embodiments of the present invention are described above in conjunction with the accompanying drawings, but the present invention is not limited to the above-mentioned specific implementation modes, which are merely illustrative rather than restrictive. Under the guidance of the present invention, ordinary technicians in this field can also make many forms without departing from the scope of protection of the present invention and the claims, all of which are within the protection of the present invention.
[0197] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed in the embodiments of the present invention can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0198] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0199] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0200] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0201] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0202] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard disks, ROM, RAM, magnetic disks, or optical disks.
[0203] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. A data encryption and decryption method, It is characterized in that The method is applied to a first device, the first device has a corresponding second device, the second device is used to extract sub-data to be encrypted from the data to be encrypted according to a preset rule, and send the sub-data to be encrypted to the first device, the method includes: receiving the sub-data to be encrypted sent by the second device; Determine a first target base and a second target base by using the sub-data to be encrypted; Converting the to-be-encrypted data into a first encrypted string using the first target base, and generating a public key using the first encrypted string; Converting the to-be-encrypted data into a second encrypted string using the second target base, and generating a private key using the second encrypted string; The public key is sent to the second device; the second device is used to encrypt the data to be encrypted using the public key and generate a ciphertext; the second device is also used to send the ciphertext to the first device; The private key is used to decrypt the ciphertext, and the ciphertext is restored to the data to be encrypted.
2. The method according to claim 1, It is characterized in that Before the step of sending the public key to the second device, the method further includes: Generate a decryption identifier for the private key through the sub-data to be encrypted; the private key and the decryption identifier have a first association relationship; The decryption identifier is sent to the second device.
3. The method according to claim 2, It is characterized in that The ciphertext and the decryption identifier have a second association relationship, and the step of using the private key to decrypt the ciphertext and restoring the ciphertext to the data to be encrypted includes: Determine a target private key for the ciphertext using the first association relationship and the second association relationship; The target private key is used to decrypt the ciphertext, and the ciphertext is restored to the data to be encrypted.
4. The method according to claim 1, It is characterized in that The step of converting the to-be-encrypted data into a first encrypted string by using the first target base, and generating a public key by using the first encrypted string comprises: generating a first random number; Determine a third target system using the first random number and the first target system; The data to be encrypted is converted into a first encrypted string using the third target base, and a public key is generated using the first encrypted string.
5. The method according to claim 1, It is characterized in that The step of converting the to-be-encrypted data into a second encrypted string by using the second target base, and generating a private key by using the second encrypted string comprises: generating a second random number; Determine a fourth target system using the second random number and the second target system; The data to be encrypted is converted into a second encrypted string using the fourth target base, and a private key is generated using the second encrypted string.
6. The method according to any one of claims 1 to 5, It is characterized in that The first device is configured with a base pool for converting bases.
7. A data encryption and decryption method, It is characterized in that The method is applied to a second device, the second device having a corresponding first device, and the method includes: Extracting sub-data to be encrypted from the data to be encrypted according to preset rules; The sub-data to be encrypted is sent to the first device; the first device is used to receive the sub-data to be encrypted sent by the second device; a first target system and a second target system are determined by the sub-data to be encrypted; the data to be encrypted is converted into a first encrypted string by the first target system, and a public key is generated by the first encrypted string; the data to be encrypted is converted into a second encrypted string by the second target system, and a private key is generated by the second encrypted string; the public key is sent to the second device; Encrypting the data to be encrypted using the public key and generating a ciphertext; The ciphertext is sent to a first device; the first device is further configured to decrypt the ciphertext using the private key and restore the ciphertext to the data to be encrypted.
8. The method according to claim 7, It is characterized in that The first device is used to generate a decryption identifier for the private key through the sub-data to be encrypted, and send the decryption identifier to the second device, the private key and the decryption identifier have a first association relationship, and the method further includes: A decryption identifier sent by the first device is received.
9. The method according to claim 8, It is characterized in that The ciphertext and the decryption identifier have a second association relationship, and the first device is used to use the first association relationship and the second association relationship to determine a target private key for the ciphertext, use the target private key to decrypt the ciphertext, and restore the ciphertext to the data to be encrypted.
10. A data encryption and decryption device, It is characterized in that The apparatus is applied to a first device, the first device has a corresponding second device, the second device is used to extract sub-data to be encrypted from the data to be encrypted according to a preset rule, and send the sub-data to be encrypted to the first device, the apparatus includes: an encryption request information receiving module, configured to receive the sub-data to be encrypted sent by the second device; An encrypted sub-data extraction module, used to extract the sub-data to be encrypted from the data to be encrypted according to a preset rule; A first target system determination module, used to determine a first target system and a second target system according to the sub-data to be encrypted; A public key generation module, used for converting the to-be-encrypted data into a first encrypted string by using the first target base, and generating a public key by using the first encrypted string; a private key generation module, configured to convert the to-be-encrypted data into a second encrypted string using the second target base, and generate a private key using the second encrypted string; a public key sending module, used to send the public key to the second device; the second device is used to encrypt the data to be encrypted using the public key and generate a ciphertext; the second device is also used to send the ciphertext to the first device; The ciphertext decryption module is used to decrypt the ciphertext using the private key and restore the ciphertext to the data to be encrypted.
11. The device according to claim 10, It is characterized in that Also includes: A decryption identifier generating module, used to generate a decryption identifier for the private key through the sub-data to be encrypted; the private key and the decryption identifier have a first association relationship; A decryption identifier sending module is used to send the decryption identifier to the second device.
12. The device according to claim 11, It is characterized in that The ciphertext and the decryption identifier have a second association relationship, and the ciphertext decryption module includes: a target private key determination submodule, configured to determine a target private key for the ciphertext by using the first association relationship and the second association relationship; The ciphertext decryption submodule is used to decrypt the ciphertext using the target private key and restore the ciphertext to the data to be encrypted.
13. The device according to claim 10, It is characterized in that The public key generation module comprises: A first random number generation submodule, used to generate a first random number; A third target system determination submodule, configured to determine a third target system using the first random number and the first target system; The public key generation submodule is used to convert the to-be-encrypted data into a first encrypted string using the third target base, and generate a public key using the first encrypted string.
14. The device according to claim 10, It is characterized in that The private key generation module comprises: A second random number generation submodule, used to generate a second random number; A fourth target system determination submodule, configured to determine a fourth target system using the second random number and the second target system; The private key generation submodule is used to convert the to-be-encrypted data into a second encrypted string using the fourth target base, and generate a private key using the second encrypted string.
15. The device according to any one of claims 10 to 14, It is characterized in that The first device is configured with a base pool for converting bases.
16. A data encryption and decryption device, It is characterized in that The apparatus is applied to a second device, the second device has a corresponding first device, and the apparatus includes: The encryption request information generation module is used to extract the sub-data to be encrypted from the data to be encrypted according to a preset rule; The encryption information sending request module is used to send the sub-data to be encrypted to the first device; the first device is used to receive the sub-data to be encrypted sent by the second device; determine a first target system and a second target system through the sub-data to be encrypted; convert the data to be encrypted into a first encrypted string through the first target system, and generate a public key through the first encrypted string; convert the data to be encrypted into a second encrypted string through the second target system, and generate a private key through the second encrypted string; and send the public key to the second device; A ciphertext generation module, used to encrypt the data to be encrypted using the public key and generate a ciphertext; The ciphertext sending module is used to send the ciphertext to the first device; the first device is also used to decrypt the ciphertext using the private key and restore the ciphertext to the data to be encrypted.
17. The device according to claim 16, It is characterized in that The first device is used to generate a decryption identifier for the private key through the sub-data to be encrypted, and send the decryption identifier to the second device, the private key and the decryption identifier have a first association relationship, and the apparatus further includes: The decryption identifier sending module is used to receive the decryption identifier sent by the first device.
18. The device according to claim 17, It is characterized in that The ciphertext and the decryption identifier have a second association relationship, and the first device is used to use the first association relationship and the second association relationship to determine a target private key for the ciphertext, use the target private key to decrypt the ciphertext, and restore the ciphertext to the data to be encrypted.
19. An electronic device, It is characterized in that It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; The memory is used to store computer programs; The processor, when used to execute a program stored in the memory, implements the method described in any one of claims 1-6 or 7-9.
20. A computer-readable storage medium having instructions stored thereon, which, when executed by one or more processors, cause the processors to perform the method according to any one of claims 1-6 or 7-9.
