A string encryption method, device, electronic device and storage medium
By extracting and encrypting multiple strings in the data to be encrypted, and increasing complexity through character permutation, combining the combination of multiple encryption characters, the risk of brute force cracking faced by existing encryption technologies is solved, and the security of data encryption is significantly improved.
Patent Information
- Application Number
- CN202411114248.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-14
- Publication Date
- 2025-04-11
- Estimated Expiration
- 2044-08-14
AI Technical Summary
Existing encryption technologies are at risk of brute force cracking, especially in the context of the rapid development of computing technology and the rise of quantum computing, a method is needed to further improve the security of data encryption.
By extracting and encrypting multiple first character strings and second character strings from the data to be encrypted, encrypting characters are generated using encryption methods, and the complexity of the encryption process is increased through character substitution. Finally, these encrypting characters are combined to create a multi-level security protection network.
It significantly improves the overall security of data encryption, resists multiple cracking methods, provides more comprehensive data protection, ensuring that even if some data is decrypted, it is difficult for unauthorized individuals to reconstruct the complete original information.
Smart Images

Figure CN118965401B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of information security, and in particular to a string encryption method, device, electronic device and storage medium. Background Art
[0002] Data encryption is a security technology that protects information from unauthorized access by converting data into an encrypted form that can only be understood by those who hold the key. This conversion usually uses complex algorithms to process the data, making it unintelligible to the outside world without the appropriate key. Encryption technology is widely used in various fields, including network communications, financial transactions and personal data protection to prevent data leakage, theft or tampering.
[0003] In today's digital age, data security has become a critical issue. Although existing encryption methods such as AES and RSA are widely used to protect data from unauthorized access, they are still at risk of being cracked by brute force. A brute force attack is a method in which an attacker uses all possible key combinations to try to decrypt encrypted data. With the rapid development of computing technology, especially the potential rise of quantum computing, the security of existing encryption technology may be further threatened. Therefore, a method is needed to further improve the security of data encryption. Summary of the invention
[0004] The present application provides a string encryption method, device, electronic device and storage medium, which have the effect of further improving the security of data encryption.
[0005] In a first aspect of the present application, a method for encrypting a string is provided, the method comprising:
[0006] Obtain the data to be encrypted;
[0007] Extracting a plurality of first character strings and a plurality of second character strings from the data to be encrypted;
[0008] Based on encrypting each of the first character strings respectively, a first encryption symbol is obtained;
[0009] Performing character replacement on each of the second character strings respectively to obtain a second encryption symbol;
[0010] Encrypted data is obtained based on a combination of the plurality of the first encryption symbols and the plurality of the second encryption symbols.
[0011] By adopting the above technical solution, firstly, by extracting and separately encrypting multiple first character strings from the data to be encrypted, and using the encryption method to generate the first encryption symbol, strong confidentiality is provided for the data. Then, the characters of the second character string are replaced, which increases the complexity and randomness of the encryption process, and further resists attempts to crack the encryption through pattern analysis. Finally, by combining these data fragments encrypted in different ways, a multi-level security protection network is created, so that even if part of the data is decrypted, it is difficult for unauthorized individuals to reconstruct the complete original information, thereby significantly improving the overall security of data encryption. In short, it effectively combines the advantages of multiple encryption technologies, resists multiple cracking methods, and provides more comprehensive data protection.
[0012] Optionally, extracting a plurality of first character strings and a plurality of second character strings from the data to be encrypted specifically includes:
[0013] Generate a first random number and a plurality of second random numbers based on the length of the data to be encrypted, wherein the value of the first random number is smaller than the length of the data to be encrypted, and the value of the second random number is smaller than the length of the data to be encrypted;
[0014] Starting from the first count bit, sequentially extracting multiple character strings of the first length to obtain an extracted character string, wherein the value of the first count bit is the same as the first random number, and the value of the first length is the same as the second random number and corresponds one to one;
[0015] A first number of extracted character strings are randomly selected from the plurality of extracted character strings to obtain a first character string, and a second number of extracted character strings are randomly selected from the plurality of extracted character strings to obtain a second character string.
[0016] By adopting the above technical solutions, the security and exclusivity of encrypted data are enhanced, because only the recipient who knows the correct combination rules can decrypt and understand the data. This not only effectively prevents unauthorized access, but also reduces the risk of data tampering, because any illegal modification of encrypted data may result in failure to decode correctly, thus immediately exposing any tampering attempt. In addition, this encryption strategy customized according to the identity of the recipient enhances the pertinence and effectiveness of the encryption process, providing an additional security layer for the transmission of sensitive information.
[0017] Optionally, the step of encrypting each of the first character strings to obtain a first encryption symbol specifically includes:
[0018] Acquire the first identity information data of the sender of the data to be encrypted and the receiver public key of the receiver of the encrypted data;
[0019] Splitting the first identity information data into the first number of sub-data;
[0020] Using the receiver's public key, encrypt each of the first character strings to obtain intermediate encrypted data;
[0021] Each of the sub-data is sequentially embedded into the intermediate encrypted data to obtain the first encryption symbol.
[0022] By adopting the above technical solution, firstly, the data is encrypted by using the public key of the recipient, ensuring that only the recipient holding the corresponding private key can decrypt the data, which increases the security of data transmission. Secondly, the sender's identity information is split and embedded into the encrypted data, so that the encrypted data not only carries the confidentiality of the content, but also contains information to verify the identity of the sender, which is very helpful for verifying the source and authenticity of the data. In addition, this method can also prevent identity impersonation and data tampering, because any unauthorized changes may cause the encrypted data to be unable to be correctly decrypted, thereby protecting the integrity and trust of the data.
[0023] Optionally, performing character replacement on each of the second character strings to obtain a second encryption symbol specifically includes:
[0024] Determine a corresponding preset corresponding rule according to the first identity information data of the sender of the data to be encrypted, wherein the preset corresponding rule is a corresponding relationship between the original character group and the replacement character group;
[0025] Determine, according to the preset corresponding rule, a second character group corresponding to the first character group, where the first character group is a character group included in the second character string;
[0026] The first character group is replaced by the second character group to obtain the second encryption symbol.
[0027] By adopting the above technical solution, a unique character replacement rule is generated according to the first identity information data of the sender, which defines how to replace each character in the second character string with other characters. As a result, each sender has its own unique replacement pattern, so that even if the same data content is encrypted by different senders, completely different second encrypted characters will be generated. This not only increases the complexity of the encrypted data, but also greatly reduces the possibility of cracking the encryption by analyzing the encrypted data.
[0028] Optionally, combining a plurality of the first encryption symbols and a plurality of the second encryption symbols to obtain encrypted data specifically further includes:
[0029] Performing a hash operation on the data to be encrypted to obtain a data summary;
[0030] Acquire the first identity information data of the sender of the data to be encrypted;
[0031] Embedding the first identity information data into the data digest to obtain encrypted verification data;
[0032] The plurality of the first encryption symbols and the plurality of the second encryption symbols are combined and embedded into the encryption verification data to obtain the encrypted data.
[0033] By adopting the above technical solution, the hash operation generates a unique data summary for the encrypted data, ensuring the integrity and non-tamperability of the data during transmission. By embedding the sender's identity information into this data summary, an encrypted verification data containing identity authentication is created, which not only strengthens the security protection of the data, but also facilitates the recipient to verify the source of the data. The combination of multiple encryption symbols is used to further encrypt the data, which increases the difficulty of cracking and makes the encryption process more complex and secure.
[0034] Optionally, after obtaining the encrypted data based on the combination of the plurality of first encryption symbols and the plurality of second encryption symbols, the method further includes:
[0035] Obtaining data to be verified input by a recipient of the encrypted data;
[0036] Extracting the encrypted data to be verified and the encrypted verification data from the data to be verified;
[0037] According to a preset combination rule, extracting encryption symbols from the encrypted data to be verified to obtain a plurality of first verification encryption symbols and a plurality of second verification encryption symbols;
[0038] Obtaining a recipient private key input by the recipient;
[0039] Decrypting each of the first verification encryption characters using the receiver's private key to obtain a first verification character string;
[0040] According to a preset corresponding rule, each of the second verification encryption characters is replaced with a character to obtain a second verification character string;
[0041] Combining a plurality of the first verification character strings and a plurality of the second verification character strings to obtain verification data;
[0042] Performing a hash operation on the verification data to obtain operation data;
[0043] If it is determined that the operation data is the same as the encrypted verification data, then the data to be verified is determined to be the encrypted data.
[0044] By adopting the above technical solution, the receiver decrypts the first encryption symbol and performs character replacement on the second encryption symbol, then combines these data and performs a hash operation to generate a new summary. This newly generated summary is compared with the original summary (encrypted verification data) embedded in the encrypted data by the sender. If the two match, this indicates that the data has not been tampered with during transmission and has maintained its original state, thereby verifying the authenticity of the data.
[0045] Optionally, obtaining encrypted data based on a combination of a plurality of the first encryption symbols and a plurality of the second encryption symbols specifically further includes:
[0046] Obtaining second identity information data of a recipient of the encrypted data;
[0047] Determine a corresponding preset combination rule according to the second identity information data;
[0048] According to the preset combination rule, a plurality of the first encryption symbols and a plurality of the second encryption symbols are combined to obtain the encrypted data.
[0049] By adopting the above technical solution, it is ensured that the configuration of encrypted data is unique, and only the recipient who knows the correct combination rules can correctly parse and restore the original data, which significantly reduces the risk of unauthorized access and data cracking. By relying on the identity information of the recipient to configure the data combination, it not only provides targeted security measures, but also enhances the confidentiality of the data and the verification process of the recipient, making the entire encrypted transmission process more secure and reliable.
[0050] In a second aspect of the present application, a string encryption device is provided, the device comprising an acquisition module, an extraction module, an encryption module, a replacement module and a processing module, wherein:
[0051] The acquisition module is used to acquire the data to be encrypted;
[0052] The extraction module is used to extract a plurality of first character strings and a plurality of second character strings from the data to be encrypted;
[0053] The encryption module is used to encrypt each of the first character strings respectively to obtain a first encryption symbol;
[0054] The replacement module is used to perform character replacement on each of the second character strings to obtain a second encryption symbol;
[0055] The processing module is used to obtain encrypted data based on a combination of a plurality of the first encryption symbols and a plurality of the second encryption symbols.
[0056] Optionally, the encryption module is used to generate a first random number and multiple second random numbers based on the length of the data to be encrypted, the value of the first random number is smaller than the length of the data to be encrypted, and the value of the second random number is smaller than the length of the data to be encrypted;
[0057] The extraction module is used to extract multiple strings of the first length in sequence starting from the first count bit to obtain an extracted string, the value of the first count bit is the same as the first random number, and the value of the first length is the same as the second random number and corresponds one to one;
[0058] The extraction module is used to randomly select a first number of extraction strings from the plurality of extraction strings to obtain a first string, and randomly select a second number of extraction strings from the plurality of extraction strings to obtain a second string.
[0059] Optionally, the acquisition module is used to acquire the first identity information data of the sender of the data to be encrypted and the receiver public key of the receiver of the encrypted data;
[0060] The processing module is used to split the first identity information data into the first number of sub-data;
[0061] The encryption module is used to encrypt each of the first character strings using the recipient's public key to obtain intermediate encrypted data;
[0062] The processing module is used to embed each of the sub-data into the intermediate encrypted data in sequence to obtain the first encryption symbol.
[0063] Optionally, the processing module is used to determine a corresponding preset corresponding rule according to the first identity information data of the sender of the data to be encrypted, and the preset corresponding rule is a corresponding relationship between the original character group and the replacement character group;
[0064] The processing module is used to determine the second character group corresponding to the first character group according to the preset corresponding rule, and the first character group is the character group included in the second character string;
[0065] The replacement module is used to replace the first character group with the second character group to obtain the second encryption symbol.
[0066] Optionally, the processing module is used to perform a hash operation on the data to be encrypted to obtain a data summary;
[0067] The acquisition module is used to acquire the first identity information data of the sender of the data to be encrypted;
[0068] The processing module is used to embed the first identity information data into the data digest to obtain encrypted verification data;
[0069] The processing module is used to combine the multiple first encryption symbols and the multiple second encryption symbols, and embed the encryption verification data to obtain the encrypted data.
[0070] Optionally, the acquisition module is used to acquire the data to be verified input by the recipient of the encrypted data;
[0071] The extraction module is used to extract the encrypted data to be verified and the encrypted verification data from the data to be verified;
[0072] The extraction module is used to extract encryption symbols from the encrypted data to be verified according to a preset combination rule to obtain a plurality of first verification encryption symbols and a plurality of second verification encryption symbols;
[0073] The acquisition module is used to acquire the recipient's private key input by the recipient;
[0074] The processing module is used to decrypt each of the first verification encryption characters using the receiver's private key to obtain a first verification character string;
[0075] The replacement module is used to replace the characters of each of the second verification encryption characters according to a preset corresponding rule to obtain a second verification character string;
[0076] The processing module is used to combine a plurality of the first verification strings and a plurality of the second verification strings to obtain verification data;
[0077] The processing module is used to perform a hash operation on the verification data to obtain operation data;
[0078] The processing module is used to determine that the data to be verified is the encrypted data if it is determined that the operation data is the same as the encrypted verification data.
[0079] Optionally, the acquisition module is used to acquire second identity information data of a recipient of the encrypted data;
[0080] The processing module is used to determine a corresponding preset combination rule according to the second identity information data;
[0081] The processing module is used to combine the plurality of the first encryption symbols and the plurality of the second encryption symbols according to the preset combination rule to obtain the encrypted data.
[0082] In the third aspect of the present application, an electronic device is provided, including a processor, a memory, a user interface and a network interface, the memory is used to store instructions, the user interface and the network interface are both used to communicate with other devices, and the processor is used to execute the instructions stored in the memory so that the electronic device executes any one of the methods described above.
[0083] In a fourth aspect of the present application, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores instructions, and when the instructions are executed, any of the methods described above is executed.
[0084] In summary, one or more technical solutions provided in the embodiments of the present application have at least the following technical effects or advantages:
[0085] First, by extracting and separately encrypting multiple first character strings from the data to be encrypted, and using encryption methods (such as public key encryption) to generate the first encryption symbol, strong confidentiality is provided for the data. Then, the characters of the second character string are replaced, which increases the complexity and randomness of the encryption process, and further resists attempts to crack the encryption through pattern analysis. Finally, by combining these data fragments encrypted in different ways, a multi-level security protection network is created, so that even if part of the data is decrypted, it is difficult for unauthorized individuals to reconstruct the complete original information, thereby significantly improving the overall security of data encryption. In short, it effectively combines the advantages of multiple encryption technologies to resist multiple cracking methods and provide more comprehensive data protection. BRIEF DESCRIPTION OF THE DRAWINGS
[0086] Figure 1 It is a flowchart of a string encryption method disclosed in an embodiment of the present application;
[0087] Figure 2 It is a module schematic diagram of a string encryption device disclosed in an embodiment of the present application;
[0088] Figure 3 It is a structural schematic diagram of an electronic device disclosed in an embodiment of the present application.
[0089] Explanation of the reference numerals: 201, acquisition module; 202, extraction module; 203, encryption module; 204, replacement module; 205, processing module; 301, processor; 302, communication bus; 303, user interface; 304, network interface; 305, memory. DETAILED DESCRIPTION
[0090] In order to enable technicians in this field to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below in conjunction with the drawings in the embodiments of this specification. Obviously, the described embodiments are only part of the embodiments of this application, not all of the embodiments.
[0091] In the description of the embodiments of the present application, words such as "for example" or "for example" are used to indicate examples, illustrations or explanations. Any embodiment or design described as "for example" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "for example" or "for example" is intended to present related concepts in a specific way.
[0092] In the description of the embodiments of the present application, the meaning of the term "multiple" refers to two or more. For example, multiple systems refer to two or more systems, and multiple screen terminals refer to two or more screen terminals. In addition, the terms "first" and "second" are used for descriptive purposes only and cannot be understood as indicating or implying relative importance or implicitly indicating the indicated technical features. Thus, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. The terms "include", "comprise", "have" and their variations all mean "including but not limited to", unless otherwise specifically emphasized.
[0093] Data encryption is a security technology that prevents unauthorized access by converting information into a form that only the key holder can understand. Although widely used algorithms such as AES and RSA provide protection, they are at risk of being cracked by brute force, especially in the context of rapid advances in computing technology, including the development of quantum computing. Therefore, it is particularly important to strengthen data encryption security to defend against these emerging threats.
[0094] This embodiment discloses a string encryption method. Figure 1 , including the following steps S110-S150:
[0095] S110, obtaining data to be encrypted.
[0096] The embodiment of the present application is applied to a server, which includes but is not limited to electronic devices such as mobile phones, tablet computers, wearable devices, PCs (Personal Computers), etc., and can also be a background server running a string encryption method. The server can be implemented as an independent server or a server cluster composed of multiple servers.
[0097] Before the sender of data exchanges data with the receiver of data, the sender encrypts the data to be encrypted through corresponding technical means so that only the receiver can read the original data to be encrypted. Therefore, the sender first needs to input the data to be encrypted to the server.
[0098] S120, extracting a plurality of first character strings and a plurality of second character strings from the data to be encrypted.
[0099] In a possible implementation, extracting multiple first character strings and multiple second character strings from the data to be encrypted specifically includes: generating a first random number and multiple second random numbers based on the length of the data to be encrypted, the value of the first random number being less than the length of the data to be encrypted, and the value of the second random number being less than the length of the data to be encrypted; starting from the first count bit, sequentially extracting multiple character strings of the first length to obtain an extracted character string, the value of the first count bit being the same as the first random number, and the value of the first length being the same as the second random number and corresponding one to one; randomly selecting a first number of extracted character strings from the multiple extracted character strings to obtain a first character string, and randomly selecting a second number of extracted character strings from the multiple extracted character strings to obtain a second character string.
[0100] Specifically, first, based on the length of the data to be encrypted, a first random number is generated, and this value needs to be smaller than the total length of the data to be encrypted. This random number will be used to determine the starting position of the extracted string. At the same time, multiple second random numbers are generated, and the value of each second random number is also smaller than the length of the data to be encrypted. These second random numbers will determine the length of each extracted string. The values of the multiple second random numbers can be the same or different, but preferably the values of the multiple second random numbers are different.
[0101] Then, a string is extracted starting from the first count bit in the data to be encrypted, and multiple strings are extracted. The value of the first count bit is determined by the first random number, that is, the starting position of the extraction is random. The length of each string is determined by the corresponding second random number, which means that the length of the string extracted each time can be different, determined by the respective second random numbers one by one. This process may need to be executed in a loop until all characters in the data to be encrypted are extracted and processed.
[0102] For example, suppose there is a piece of data to be encrypted: "HelloWorldDataEncryption", with a length of 24 characters. Generate the first random number: 10 (starting position), generate the second random number: [5, 6, 8, 7] (extraction length), start from position 10, extract the string of length 5: "ataEn", then extract the string of length 6: "crypti", then extract the string of length 8: "onHelloW", and finally extract the remaining string: "orldD".
[0103] After extracting multiple extracted character strings, a certain number (first number) of character strings are randomly selected from the extracted multiple character strings as first character strings. Similarly, another certain number (second number) of character strings are randomly selected from the extracted character strings as second character strings.
[0104] S130: encrypt each first character string to obtain a first encryption symbol.
[0105] In a possible implementation, the first encryption symbol is obtained based on encrypting each first character string separately, which specifically includes: obtaining the first identity information data of the sender of the data to be encrypted, and the receiver public key of the receiver of the encrypted data; splitting the first identity information data into a first number of sub-data; using the receiver public key to encrypt each first character string to obtain intermediate encrypted data; and embedding each sub-data in turn into the intermediate encrypted data to obtain the first encryption symbol.
[0106] Specifically, first collect the sender's first identity information data, which includes but is not limited to the identity code or ID number. At the same time, obtain the public key of the data recipient. In the public key encryption system, the sender uses the recipient's public key to encrypt, ensuring that only the recipient holding the corresponding private key can decrypt the data. Then split the sender's first identity information data into several sub-data. The number of these sub-data should be the same as the number of the first string (i.e., the first number). This step is to embed each sub-data into the corresponding encrypted string in the subsequent process.
[0107] Each first string is encrypted using the recipient's public key. Here, each first string is encrypted independently to generate intermediate encrypted data, which not only ensures the security of data transmission, but also ensures that only specific recipients (private key holders) can access these encrypted data. The sub-data obtained by splitting are then embedded into each intermediate encrypted data obtained in turn, which can be done through simple data merging, such as appending, inserting or modifying existing encrypted data. Each embedded encrypted string now contains the sender's specific identity sub-data, which increases the authentication level of the encrypted data and improves security.
[0108] S140, performing character replacement on each second character string to obtain a second encryption symbol.
[0109] Performing character replacement on each second character string respectively to obtain a second encryption symbol specifically includes: determining a corresponding preset corresponding rule according to the first identity information data of the sender of the data to be encrypted, the preset corresponding rule being the correspondence between the original character group and the replacement character group; determining a second character group corresponding to the first character group according to the preset corresponding rule, the first character group being the character group included in the second character string; and replacing the first character group with the second character group to obtain a second encryption symbol.
[0110] Specifically, first, preset corresponding rules are determined based on the first identity information data of the sender. These rules consist of the correspondence between the original character group and the replacement character group. Specific rules can be formulated based on the sender's name, birthday, address and other information to ensure that each sender has a unique corresponding rule. For example, the ASCII value of the sender's name can be used as a seed to generate a random or pseudo-random character mapping table, or a stable mapping table can be generated based on a specific cryptographic method (such as a hash function).
[0111] Then identify the character groups contained in the second string (the data portion to be encrypted). These characters will be replaced according to the preset rules. According to the preset pair rule, determine the second character group corresponding to the first character group, and each original character has a corresponding replacement character in the replacement character group. Use the second character group to replace each character in the first character group. This process involves traversing each character in the second string, finding the corresponding replacement character according to the preset rule, and generating a new encrypted string (the second encryption character). It should be noted that it is the character group that is replaced, not the individual character, that is, a character group contained in the preset pair rule is selected in the second string and replaced with the corresponding replacement character group.
[0112] The purpose of using character group replacement instead of character replacement is as follows: in single character replacement, if the encrypted text is long enough, the attacker may guess the characters in the original text by counting the character frequency. This is because the frequency of some characters in natural language (such as 'e', 't', 'a', etc.) is much higher than that of other characters. In character group replacement, since multiple characters are replaced at the same time, this frequency analysis becomes extremely difficult because the attacker cannot directly associate it with the frequency of a single character. The key space of character group replacement is much larger than that of single character replacement. For example, if a two-character group is used for replacement, and the character set is 26 English letters, then the possible replacement rules will be 262=676 (not considering repeated groups), while there are only 26 for single character replacement. As the length of the character group increases, the key space grows exponentially, greatly improving the security of encryption.
[0113] In addition, character group replacement can be designed to depend on the context of the previous one or several characters. This design makes the encryption process more complicated because the replacement of each character depends not only on itself, but also on the characters around it. This dependency makes the encrypted text more difficult to analyze and predict. Through complex character group replacement rules, non-linear character transformation can be achieved, which further increases the complexity and security of encryption. Patterns existing in natural language (such as word structure, grammatical rules, etc.) may still retain certain traces in single character replacement. Character group replacement can more effectively disrupt these patterns, making the encrypted text statistically closer to random noise, making it more difficult to recognize or analyze. Due to the complexity and nonlinearity of character group replacement, any part of the encrypted text becomes more difficult to predict, which reduces the possibility of inferring the overall information through partial decryption.
[0114] S150, obtaining encrypted data based on a combination of the plurality of first encryption symbols and the plurality of second encryption symbols.
[0115] In a possible implementation, encrypted data is obtained based on a combination of multiple first encryption symbols and multiple second encryption symbols, which specifically also includes: obtaining second identity information data of a recipient of the encrypted data; determining a corresponding preset combination rule based on the second identity information data; and combining multiple first encryption symbols and multiple second encryption symbols according to the preset combination rule to obtain encrypted data.
[0116] Specifically, the final encrypted data is generated by combining the first encryption symbol and the second encryption symbol using the sender's identity information, and the final combination is determined by the receiver's identity information. This method not only improves the security of the encrypted data, but also ensures that only the designated receiver can correctly parse and restore the information.
[0117] First, the second identity information data of the recipient needs to be obtained, which may include the recipient's ID number, telephone number or other information that can uniquely identify the individual. A preset combination rule is determined based on the recipient's second identity information data. This rule defines how to combine multiple first encryption symbols and second encryption symbols. These rules can be sorting rules based on specific algorithms, mixing rules or any other method that can be generated based on identity information. Finally, according to the preset combination rule, multiple first encryption symbols and multiple second encryption symbols are combined. This may involve the process of sorting, mixing or interweaving these encryption symbols to generate the final encrypted data.
[0118] Furthermore, in addition to using a combination of the first and second encryption symbols to encrypt data, the concepts of data summary and authentication data are introduced to enhance overall security. This scheme creates encrypted data that is more difficult to tamper with and has verification functions by embedding the sender's identity information and data summary on the basis of the original encryption.
[0119] In a possible implementation, multiple first encryption symbols and multiple second encryption symbols are combined to obtain encrypted data, which specifically also includes: performing a hash operation on the data to be encrypted to obtain a data summary; obtaining first identity information data of the sender of the data to be encrypted; embedding the first identity information data into the data summary to obtain encrypted verification data; combining multiple first encryption symbols and multiple second encryption symbols, and embedding the encrypted verification data to obtain encrypted data.
[0120] Specifically, first, a hash operation is performed on the data to be encrypted. This step compresses the entire data to be encrypted into a data summary of a fixed length (for example, using the SHA-256 algorithm). The data summary is used to ensure the integrity of the data, that is, it has not been modified during transmission or storage. The sender's first identity information data is then embedded in the resulting data summary. This can be achieved by simple concatenation or using a more complex data structure, the purpose of which is to include both the data summary and the identity information in the verification data.
[0121] Then, multiple first encryption symbols and second encryption symbols are combined according to pre-set rules. These rules may depend on the identity information or other parameters of the recipient to ensure that only a specific recipient can correctly parse the combined data. Finally, the generated encryption verification data is embedded in the combined encrypted data. In this way, the final encrypted data contains all the necessary information for identity authentication and data integrity check when the data is transmitted or used.
[0122] In a possible implementation, after obtaining the encrypted data based on the combination of multiple first encryption symbols and multiple second encryption symbols, the method also includes: obtaining the data to be verified input by the recipient of the encrypted data; extracting the encrypted data to be verified and the encrypted verification data from the data to be verified; extracting the encryption symbols from the encrypted data to be verified according to a preset combination rule to obtain multiple first verification encryption symbols and multiple second verification encryption symbols; obtaining the receiver's private key input by the receiver; using the receiver's private key to decrypt each first verification encryption symbol to obtain a first verification string; according to a preset corresponding rule, performing character replacement on each second verification encryption symbol to obtain a second verification string; combining multiple first verification strings and multiple second verification strings to obtain verification data; performing a hash operation on the verification data to obtain operation data; if it is determined that the operation data is the same as the encrypted verification data, then determining that the data to be verified is encrypted data.
[0123] Specifically, the receiver needs to verify the received encrypted data to ensure its integrity and authenticity. This process includes decryption operations, character replacement, reassembly of verification data, and a final hash operation to compare data integrity.
[0124] First, the recipient needs to input the data to be verified, which is usually the encrypted data. Then, the encrypted data to be verified and its related encrypted verification data are extracted from the received data to be verified. These data are usually embedded or attached to the encrypted data during the sending process. Then, the encrypted data to be verified is operated according to the preset combination rules to extract multiple first verification encryption symbols and multiple second verification encryption symbols. These rules should match the rules used by the sender when encrypting. Usually, the first verification encryption symbol is the same as the first encryption symbol, and the second verification encryption symbol is the same as the second encryption symbol.
[0125] The receiver then uses its private key to decrypt each first verification encryption symbol to obtain the first verification string. This step ensures that only the correct receiver can interpret the sent data. Then, according to the established corresponding rules, each second verification encryption symbol is replaced with a character to obtain the second verification string. These rules are the same as the rules used by the sender to encrypt the second string. Similarly, usually the first verification string is the same as the first string, and the second verification string is the same as the second string.
[0126] Recombine all the first verification strings and the second verification strings according to the rules when splitting to generate complete verification data. If the data has not been tampered with, the verification data is the data to be encrypted. For verification, perform a hash operation on the recombined verification data to obtain a new operation data. This hash process should be the same as the hash process used by the sender when creating the encrypted verification data. Compare the operation data obtained in step 7 with the encrypted verification data extracted in step 2. If the two are the same, the verification is successful, indicating that the data to be verified is consistent with the original encrypted data when it was sent and has not been tampered with or damaged.
[0127] By adopting the technical solution of the present application, firstly, by extracting and separately encrypting multiple first character strings from the data to be encrypted, and using an encryption method (such as public key encryption) to generate a first encryption symbol, strong confidentiality is provided for the data. Then, the characters of the second character string are replaced, which increases the complexity and randomness of the encryption process, and further resists attempts to crack the encryption through pattern analysis. Finally, by combining these data fragments encrypted in different ways, a multi-level security protection network is created, so that even if part of the data is decrypted, it is difficult for unauthorized individuals to reconstruct the complete original information, thereby significantly improving the overall security of data encryption. In short, it effectively combines the advantages of multiple encryption technologies, resists multiple cracking methods, and provides more comprehensive data protection.
[0128] This embodiment also discloses a string encryption device, referring to Figure 2 The device includes an acquisition module 201, an extraction module 202, an encryption module 203, a replacement module 204 and a processing module 205, wherein:
[0129] The acquisition module 201 is used to acquire data to be encrypted.
[0130] The extraction module 202 is used to extract a plurality of first character strings and a plurality of second character strings from the data to be encrypted.
[0131] The encryption module 203 is configured to encrypt each first character string respectively to obtain a first encryption symbol.
[0132] The replacement module 204 is used to perform character replacement on each second character string to obtain a second encryption symbol.
[0133] The processing module 205 is used to obtain encrypted data based on the combination of the multiple first encryption symbols and the multiple second encryption symbols.
[0134] In a possible implementation, the encryption module 203 is used to generate a first random number and multiple second random numbers based on the length of the data to be encrypted, the value of the first random number is smaller than the length of the data to be encrypted, and the value of the second random number is smaller than the length of the data to be encrypted.
[0135] The extraction module 202 is used to extract multiple strings of the first length in sequence starting from the first count bit to obtain an extracted string, wherein the value of the first count bit is the same as the first random number, and the value of the first length is the same as the second random number and has a one-to-one correspondence.
[0136] The extraction module 202 is configured to randomly select a first number of extraction strings from a plurality of extraction strings to obtain a first string, and randomly select a second number of extraction strings from a plurality of extraction strings to obtain a second string.
[0137] In a possible implementation, the acquisition module 201 is used to acquire the first identity information data of the sender of the data to be encrypted and the receiver public key of the receiver of the encrypted data.
[0138] The processing module 205 is used to split the first identity information data into a first number of sub-data.
[0139] The encryption module 203 is used to encrypt each first character string using the receiver's public key to obtain intermediate encrypted data.
[0140] The processing module 205 is used to embed each sub-data into the intermediate encrypted data in sequence to obtain a first encryption symbol.
[0141] In a possible implementation, the processing module 205 is used to determine a corresponding preset corresponding rule according to the first identity information data of the sender of the data to be encrypted, where the preset corresponding rule is a corresponding relationship between the original character group and the replacement character group.
[0142] The processing module 205 is used to determine the second character group corresponding to the first character group according to a preset corresponding rule, where the first character group is the character group included in the second character string.
[0143] The replacement module 204 is used to replace the first character group with the second character group to obtain a second encryption symbol.
[0144] In a possible implementation, the processing module 205 is configured to perform a hash operation on the data to be encrypted to obtain a data summary.
[0145] The acquisition module 201 is used to acquire the first identity information data of the sender of the data to be encrypted.
[0146] The processing module 205 is used to embed the first identity information data into the data digest to obtain encrypted verification data.
[0147] The processing module 205 is used to combine the multiple first encryption symbols and the multiple second encryption symbols, and embed the encryption verification data to obtain encrypted data.
[0148] In a possible implementation, the acquisition module 201 is used to acquire the data to be verified input by the recipient of the encrypted data.
[0149] The extraction module 202 is used to extract the encrypted data to be verified and the encrypted verification data from the data to be verified.
[0150] The extraction module 202 is used to extract encryption symbols from the encrypted data to be verified according to a preset combination rule to obtain a plurality of first verification encryption symbols and a plurality of second verification encryption symbols.
[0151] The acquisition module 201 is used to acquire the recipient's private key input by the recipient.
[0152] The processing module 205 is used to decrypt each first verification encryption symbol using the receiver's private key to obtain a first verification character string.
[0153] The replacement module 204 is used to replace the characters of each second verification encryption symbol according to a preset corresponding rule to obtain a second verification character string.
[0154] The processing module 205 is used to combine multiple first verification character strings and multiple second verification character strings to obtain verification data.
[0155] The processing module 205 is used to perform a hash operation on the verification data to obtain operation data.
[0156] The processing module 205 is used to determine that the data to be verified is encrypted data if it is determined that the operation data is the same as the encrypted verification data.
[0157] In a possible implementation, the acquisition module 201 is used to acquire second identity information data of a recipient of the encrypted data.
[0158] The processing module 205 is used to determine a corresponding preset combination rule according to the second identity information data.
[0159] The processing module 205 is used to combine the multiple first encryption symbols and the multiple second encryption symbols according to a preset combination rule to obtain encrypted data.
[0160] It should be noted that: when the device provided in the above embodiment realizes its function, only the division of the above functional modules is used as an example. In actual application, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the device and method embodiments provided in the above embodiment belong to the same concept, and the specific implementation process is detailed in the method embodiment, which will not be repeated here.
[0161] This embodiment also discloses an electronic device, referring to Figure 3 The electronic device may include: at least one processor 301 , at least one communication bus 302 , a user interface 303 , a network interface 304 , and at least one memory 305 .
[0162] The communication bus 302 is used to realize the connection and communication between these components.
[0163] The user interface 303 may include a display screen (Display) and a camera (Camera). Optionally, the user interface 303 may also include a standard wired interface and a wireless interface.
[0164] The network interface 304 may optionally include a standard wired interface or a wireless interface (such as a WI-FI interface).
[0165] Among them, the processor 301 may include one or more processing cores. The processor 301 uses various interfaces and lines to connect various parts in the entire server, and executes various functions of the server and processes data by running or executing instructions, programs, code sets or instruction sets stored in the memory 305, and calling data stored in the memory 305. Optionally, the processor 301 can be implemented in at least one hardware form of digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), and programmable logic array (Programmable Logic Array, PLA). The processor 301 can integrate one or a combination of a central processing unit (Central Processing Unit, CPU), a graphics processing unit (Graphics Processing Unit, GPU) and a modem. Among them, the CPU mainly processes the operating system, user interface and application programs; the GPU is responsible for rendering and drawing the content to be displayed on the display screen; the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 301, and it can be implemented separately through a chip.
[0166] The memory 305 may include a random access memory (RAM) or a read-only memory (ROM). Optionally, the memory includes a non-transitory computer-readable storage medium. The memory 305 may be used to store instructions, programs, codes, code sets or instruction sets. The memory 305 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the above-mentioned various method embodiments, etc.; the data storage area may store data involved in the above-mentioned various method embodiments, etc. The memory 305 may also be at least one storage device located away from the aforementioned processor 301. The memory 305 as a computer storage medium may include an operating system, a network communication module, a user interface 303 module, and an application for a string encryption method.
[0167] exist Figure 3 In the electronic device shown, the user interface 303 is mainly used to provide an input interface for the user and obtain data input by the user; and the processor 301 can be used to call an application program storing a string encryption method in the memory 305. When executed by one or more processors 301, the electronic device executes one or more methods in the above-mentioned embodiments.
[0168] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all described as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the order of the actions described, because according to the present application, 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 and modules involved are not necessarily required for the present application.
[0169] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0170] In the several embodiments provided in this application, it should be understood that the disclosed devices can be implemented in other ways. For example, the device embodiments described above are only schematic, such as the division of units, which 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 service interfaces, and the indirect coupling or communication connection of devices or units can be electrical or other forms.
[0171] 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.
[0172] In addition, each functional unit in each embodiment of the present application 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. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0173] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a memory 305 and includes several instructions for a computer device (which can be a personal computer, server or network device, etc.) to execute all or part of the steps of the various embodiments of the present application. The aforementioned memory 305 includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk.
[0174] The present application also discloses a computer-readable storage medium, wherein the computer-readable storage medium stores instructions. When executed by one or more processors 301, the electronic device executes one or more of the methods described in the above embodiments.
[0175] The above is only an exemplary embodiment of the present disclosure, and the scope of the present disclosure cannot be limited thereto. That is, any equivalent changes and modifications made according to the teachings of the present disclosure are still within the scope of the present disclosure. After considering the disclosure of the specification and the truth of practice, it will be easy for those skilled in the art to think of other embodiments of the present disclosure. This application is intended to cover any modification, use or adaptation of the present disclosure, which follows the general principles of the present disclosure and includes common knowledge or customary technical means in the technical field that are not recorded in the present disclosure. The description and examples are regarded as exemplary only, and the scope and spirit of the present disclosure are defined by the claims.
Claims
1. A string encryption method, characterized in that: The method comprises: Obtain the data to be encrypted; Extracting a plurality of first character strings and a plurality of second character strings from the data to be encrypted; Based on encrypting each of the first character strings respectively, a first encryption symbol is obtained; Performing character replacement on each of the second character strings respectively to obtain a second encryption symbol; Obtaining encrypted data based on a combination of the plurality of the first encryption symbols and the plurality of the second encryption symbols; The extracting a plurality of first character strings and a plurality of second character strings from the data to be encrypted specifically includes: Generate a first random number and a plurality of second random numbers based on the length of the data to be encrypted, wherein the value of the first random number is smaller than the length of the data to be encrypted, and the value of the second random number is smaller than the length of the data to be encrypted; Starting from the first count bit, sequentially extracting multiple character strings of the first length to obtain an extracted character string, wherein the value of the first count bit is the same as the first random number, and the value of the first length is the same as the second random number and corresponds one to one; randomly selecting a first number of extracted character strings from the plurality of extracted character strings to obtain a first character string, and randomly selecting a second number of extracted character strings from the plurality of extracted character strings to obtain a second character string; The step of encrypting each of the first character strings to obtain a first encryption symbol specifically includes: Acquire the first identity information data of the sender of the data to be encrypted and the receiver public key of the receiver of the encrypted data; Splitting the first identity information data into the first number of sub-data; Using the receiver's public key, encrypt each of the first character strings to obtain intermediate encrypted data; embedding each of the sub-data into the intermediate encrypted data in sequence to obtain the first encryption symbol; The combining the plurality of the first encryption symbols and the plurality of the second encryption symbols to obtain encrypted data specifically includes: Performing a hash operation on the data to be encrypted to obtain a data summary; Acquire the first identity information data of the sender of the data to be encrypted; Embedding the first identity information data into the data digest to obtain encrypted verification data; Combining the plurality of the first encryption symbols and the plurality of the second encryption symbols, and embedding the encryption verification data to obtain the encrypted data; After obtaining the encrypted data based on the combination of the plurality of the first encryption symbols and the plurality of the second encryption symbols, the method further comprises: Obtaining data to be verified input by a recipient of the encrypted data; Extracting the encrypted data to be verified and the encrypted verification data from the data to be verified; According to a preset combination rule, extracting encryption symbols from the encrypted data to be verified to obtain a plurality of first verification encryption symbols and a plurality of second verification encryption symbols; Obtaining a recipient private key input by the recipient; Decrypting each of the first verification encryption characters using the receiver's private key to obtain a first verification character string; According to a preset corresponding rule, each of the second verification encryption characters is replaced with a character to obtain a second verification character string; Combining a plurality of the first verification character strings and a plurality of the second verification character strings to obtain verification data; Performing a hash operation on the verification data to obtain operation data; If it is determined that the operation data is the same as the encrypted verification data, then the data to be verified is determined to be the encrypted data.
2. A string encryption method according to claim 1, characterized in that: The performing character replacement on each of the second character strings to obtain a second encryption symbol specifically includes: Determine a corresponding preset corresponding rule according to the first identity information data of the sender of the data to be encrypted, wherein the preset corresponding rule is a corresponding relationship between the original character group and the replacement character group; Determine, according to the preset corresponding rule, a second character group corresponding to the first character group, where the first character group is a character group included in the second character string; The first character group is replaced by the second character group to obtain the second encryption symbol.
3. A string encryption method according to claim 1, characterized in that: The step of obtaining encrypted data based on a combination of the plurality of the first encryption symbols and the plurality of the second encryption symbols specifically further includes: Obtaining second identity information data of a recipient of the encrypted data; Determine a corresponding preset combination rule according to the second identity information data; According to the preset combination rule, a plurality of the first encryption symbols and a plurality of the second encryption symbols are combined to obtain the encrypted data.
4. A string encryption device, characterized in that: The device comprises an acquisition module (201), an extraction module (202), an encryption module (203), a replacement module (204) and a processing module (205), wherein: The acquisition module (201) is used to acquire the data to be encrypted; The extraction module (202) is used to extract a plurality of first character strings and a plurality of second character strings from the data to be encrypted; The encryption module (203) is used to encrypt each of the first character strings respectively to obtain a first encryption symbol; The replacement module (204) is used to perform character replacement on each of the second character strings to obtain a second encryption symbol; The processing module (205) is used to obtain encrypted data based on a combination of a plurality of the first encryption symbols and a plurality of the second encryption symbols; The extraction module (202) is also used to extract multiple first character strings and multiple second character strings from the data to be encrypted, specifically comprising: generating a first random number and multiple second random numbers based on the length of the data to be encrypted, wherein the value of the first random number is less than the length of the data to be encrypted, and the value of the second random number is less than the length of the data to be encrypted; starting from the first count bit, sequentially extracting multiple character strings of the first length to obtain an extracted character string, wherein the value of the first count bit is the same as the first random number, and the value of the first length is the same as the second random number and corresponds to each other one by one; randomly selecting a first number of extracted character strings from the multiple extracted character strings to obtain a first character string, and randomly selecting a second number of extracted character strings from the multiple extracted character strings to obtain a second character string; The encryption module (203) is further used for encrypting each of the first character strings to obtain a first encryption symbol, specifically comprising: obtaining first identity information data of a sender of the data to be encrypted and a receiver public key of a receiver of the encrypted data; splitting the first identity information data into the first number of sub-data; using the receiver public key to encrypt each of the first character strings to obtain intermediate encrypted data; and sequentially embedding each of the sub-data into the intermediate encrypted data to obtain the first encryption symbol; The processing module (205) is also used for combining the plurality of the first encryption symbols and the plurality of the second encryption symbols to obtain encrypted data, and specifically includes: performing a hash operation on the data to be encrypted to obtain a data summary; obtaining the first identity information data of the sender of the data to be encrypted; embedding the first identity information data into the data summary to obtain encryption verification data; combining the plurality of the first encryption symbols and the plurality of the second encryption symbols, and embedding the encryption verification data into the encryption verification data to obtain the encrypted data; The processing module (205) is also used for, after obtaining the encrypted data based on the combination of the plurality of the first encryption symbols and the plurality of the second encryption symbols, further comprising: obtaining the data to be verified input by the recipient of the encrypted data; extracting the encrypted data to be verified and the encrypted verification data from the data to be verified; extracting the encryption symbols from the encrypted data to be verified according to a preset combination rule to obtain a plurality of first verification encryption symbols and a plurality of second verification encryption symbols; obtaining the receiver's private key input by the receiver; decrypting each of the first verification encryption symbols using the receiver's private key to obtain a first verification string; performing character replacement on each of the second verification encryption symbols according to a preset corresponding rule to obtain a second verification string; combining the plurality of the first verification strings and the plurality of the second verification strings to obtain verification data; performing a hash operation on the verification data to obtain operation data; if it is determined that the operation data is the same as the encrypted verification data, then determining that the data to be verified is the encrypted data.
5. An electronic device, characterized in that: The electronic device comprises a processor (301), a memory (305), a user interface (303), a network interface (304) and a memory (305), wherein the memory (305) is used to store instructions, the user interface (303) and the network interface (304) are both used to communicate with other devices, and the processor (301) is used to execute the instructions stored in the memory (305) so that the electronic device executes the method according to any one of claims 1 to 3.
6. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores instructions, and when the instructions are executed, the method according to any one of claims 1 to 3 is performed.
Citation Information
Patent Citations
Character string encryption and verification method and apparatus, and computer readable storage medium
CN107634832A
Data encryption method and device, terminal equipment and computer readable storage medium
CN115941304A