Encryption method and device
By encrypting the encrypted number using a large prime number set and a target hash value, the problem of low data encryption security in the existing encryption methods is solved, and the effect of improving encryption randomness and security is achieved.
Patent Information
- Application Number
- CN202211641054.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-20
- Publication Date
- 2025-02-28
- Estimated Expiration
- 2042-12-20
AI Technical Summary
Data encryption in existing encryption methods is low in security, especially symmetric encryption algorithms have shortcomings in key management and randomness.
By obtaining a set of large prime numbers composed of multiple large prime numbers and a plaintext to be encrypted, the plaintext to be encrypted is converted into a number to be encrypted, and multiple target large prime numbers are randomly selected to determine their corresponding target hash values, and the encrypted numbers are encrypted using these large prime numbers and hash values.
It improves the randomness and security of encryption, increases the difficulty of cracking, and effectively solves the problem of low security of data encryption.
Smart Images

Figure CN115955344B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data encryption, and more specifically, to an encryption method and device. Background Art
[0002] Encryption is to hide plain text information so that it is unreadable without special information. The security of encryption is reflected in the fact that the encryption key is absolutely hidden. The popular RSA encryption algorithm and AES encryption algorithm are completely public. If one party obtains the encrypted data, it cannot open the encrypted information without the encryption key. Among them, symmetric encryption is an encryption and decryption method using a single-key cryptographic system. The same secret key can be used for both encryption and decryption of information. It is characterized by fast encryption and decryption speed and is usually used in scenarios where large amounts of data need to be transmitted. Summary of the invention
[0003] The embodiments of the present application provide an encryption method and device to at least solve the technical problem of low security of data encryption.
[0004] According to one aspect of an embodiment of the present application, an encryption method is provided, including: obtaining a large prime number set consisting of multiple large prime numbers and a plaintext to be encrypted, wherein the large prime numbers in the large prime number set are mutually prime; converting the plaintext to be encrypted into a number to be encrypted, and randomly selecting multiple target large prime numbers from the large prime number set; determining target hash values corresponding to the multiple target large prime numbers; and completing the encryption of the number to be encrypted using the multiple target large prime numbers, the number to be encrypted and the target hash value.
[0005] Optionally, encryption of the number to be encrypted is completed using multiple target large prime numbers, the number to be encrypted and the target hash value, including: taking the modulus of the number to be encrypted with multiple target large prime numbers to obtain multiple remainders; substituting the multiple remainders and the multiple target large prime numbers into a preset formula to determine the minimum solution of the preset formula; performing an XOR operation on the minimum solution and the number to be encrypted to obtain a target offset corresponding to the number to be encrypted; concatenating the multiple remainders with the target offset to obtain a first ciphertext number; concatenating the first ciphertext number with the target hash value to obtain a second ciphertext number; encoding the second ciphertext data to obtain an encrypted plaintext to be encrypted, and determining the encrypted plaintext to be encrypted as the ciphertext.
[0006] Optionally, multiple remainders are concatenated with a target offset to obtain a first ciphertext number, including: determining the number of digits of the multiple remainders and the corresponding target large prime number in sequence; determining a target remainder whose median is smaller than the corresponding target large prime number, and padding a prefix of the target remainder with zeros to make the number of digits of the target remainder consistent with that of the corresponding target large prime number; and sequentially splicing the multiple remainders that have been padded with zeros to the target offset in order of the corresponding target large prime numbers to obtain the first ciphertext number, wherein the corresponding target large prime numbers are sorted in ascending order.
[0007] Optionally, concatenating the first ciphertext number with the target Hash value to obtain the second ciphertext number includes: converting the first ciphertext number into a hexadecimal number to obtain an initial ciphertext number; and concatenating the target Hash value to the initial ciphertext number to obtain the second ciphertext number.
[0008] Optionally, encoding the second ciphertext data to obtain encrypted plaintext to be encrypted includes: converting the second ciphertext data into a first byte stream; encoding the first byte stream according to a preset format to complete the encryption of the plaintext to be encrypted.
[0009] Optionally, determining a hash value corresponding to the product of multiple target large prime numbers includes: determining the product of multiple target large prime numbers, and determining a target hash value corresponding to the product of the multiple target large prime numbers; and recording the product of the multiple target large prime numbers and the target hash value in the form of a key-value pair.
[0010] Optionally, converting the plaintext to be encrypted into the number to be encrypted includes: converting the plaintext to be encrypted into a second byte stream; converting the second byte stream into a hexadecimal value; converting the hexadecimal value into a decimal value to obtain the number to be encrypted.
[0011] According to another aspect of an embodiment of the present application, a decryption method is also provided, including: receiving a ciphertext to be decrypted, truncating the last thirty-two bits of the ciphertext, and determining them as a target hash value; determining multiple target large prime numbers corresponding to the target hash value; converting the remaining ciphertext after truncation into decimal, and determining multiple remainders in turn; removing the multiple remainders from the remaining ciphertext after truncation to obtain a target offset; and determining the plaintext corresponding to the ciphertext to be decrypted based on the multiple target large prime numbers, the multiple remainders, and the target offset.
[0012] According to another aspect of the embodiment of the present application, an encryption device is also provided, including: an acquisition module, used to obtain a large prime number set consisting of multiple large prime numbers and a plaintext to be encrypted, wherein the large prime numbers in the large prime number set are mutually prime; a conversion module, used to convert the plaintext to be encrypted into a number to be encrypted, and randomly select multiple target large prime numbers from the large prime number set; a determination module, used to determine the target hash values corresponding to the multiple target large prime numbers; an encryption module, used to complete the encryption of the number to be encrypted using the multiple target large prime numbers, the number to be encrypted and the target hash value.
[0013] According to another aspect of the embodiments of the present application, a non-volatile storage medium is provided, in which a program is stored, wherein when the program is running, the device where the non-volatile storage medium is located is controlled to execute the above encryption method.
[0014] According to another aspect of the embodiments of the present application, a computer device is provided, including: a memory and a processor, the processor being used to run a program stored in the memory, wherein the above encryption method is executed when the program is run.
[0015] In an embodiment of the present application, a large prime number set consisting of multiple large prime numbers and a plaintext to be encrypted are obtained, wherein the large prime numbers in the large prime number set are mutually prime; the plaintext to be encrypted is converted into a number to be encrypted, and multiple target large prime numbers are randomly selected from the large prime number set; target hash values corresponding to the multiple target large prime numbers are determined; a method of encrypting the number to be encrypted is completed using the multiple target large prime numbers, the number to be encrypted and the target hash values, and the plaintext to be encrypted is encrypted by the randomly determined target large prime number and the target hash values corresponding to the multiple target large prime numbers, thereby achieving the purpose of increasing the randomness of the encryption, realizing the technical effect of improving the encryption security, and thus solving the technical problem of low data encryption security. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0017] Figure 1 It is a hardware structure block diagram of a computer terminal (or mobile device) for an encryption method according to an embodiment of the present application;
[0018] Figure 2 is a schematic diagram of a flow chart of an encryption method according to the present application;
[0019] Figure 3 This is a flowchart of a decryption method according to the present application.
[0020] Figure 4 It is a schematic diagram of the structure of an optional encryption device according to an embodiment of the present application. DETAILED DESCRIPTION
[0021] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.
[0022] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0023] The embodiment of the present application provides a method embodiment of an encryption method. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0024] The method embodiments provided in the embodiments of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Figure 1 FIG. 1 shows a hardware structure block diagram of a computer terminal (or mobile device) for implementing an encryption method. Figure 1 As shown, the computer terminal 10 (or mobile device 10) may include one or more (102a, 102b, ..., 102n are used to illustrate) processors 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 104 for storing data, and a transmission module 106 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the BUS bus), a network interface, a power supply and / or a camera. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above electronic device. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown.
[0025] It should be noted that the one or more processors 102 and / or other data processing circuits described above may generally be referred to herein as "data processing circuits". The data processing circuits may be embodied in whole or in part as software, hardware, firmware, or any other combination thereof. In addition, the data processing circuit may be a single independent processing module, or may be incorporated in whole or in part into any of the other components in the computer terminal 10 (or mobile device). As described in the embodiments of the present application, the data processing circuit acts as a processor control (e.g., selection of a variable resistor terminal path connected to an interface).
[0026] The memory 104 can be used to store software programs and modules of application software, such as program instructions / data storage devices corresponding to the encryption method in the embodiment of the present application. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, that is, implementing the above-mentioned encryption method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the computer terminal 10 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0027] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the computer terminal 10. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0028] The display may be, for example, a touch screen liquid crystal display (LCD) that enables a user to interact with a user interface of the computer terminal 10 (or mobile device).
[0029] In the above operating environment, the present application embodiment provides an encryption method, such as Figure 2 As shown, the method comprises the following steps:
[0030] Step S202, obtaining a large prime number set consisting of a plurality of large prime numbers and a plaintext to be encrypted, wherein the large prime numbers in the large prime number set are mutually prime;
[0031] Step S204, converting the plaintext to be encrypted into a number to be encrypted, and randomly selecting a plurality of target large prime numbers from a large prime number set;
[0032] Step S206, determining target hash values corresponding to multiple target large prime numbers;
[0033] Step S208, using multiple target large prime numbers, the number to be encrypted and the target hash value, complete the encryption of the number to be encrypted.
[0034] Through the above steps, it is possible to encrypt the plaintext to be encrypted by using a randomly determined target large prime number and target hash values corresponding to multiple target large prime numbers, thereby achieving the purpose of increasing encryption randomness, achieving the technical effect of improving encryption security, and thus solving the technical problem of low data encryption security.
[0035] It should be noted that the encryption method provided in the embodiment of the present application can be Figure 1 The computer terminal shown is used to encrypt the plaintext data to be transmitted, thereby achieving the purpose of improving the security of data transmission.
[0036] It is understandable that hash signature is a digital signature method, also known as digital digest or digital fingerprint. Digital digest is to use a one-way hash function to "summarize" the plaintext to be encrypted into a string of ciphertext of fixed length (128 bits). This string of ciphertext is also called digital fingerprint. It has a fixed length, and different plaintext summaries into ciphertexts always have different results, while the same plaintext must have the same summary.
[0037] In step S202, a set of large prime numbers consisting of a plurality of large prime numbers is obtained, and the large prime numbers are arranged in ascending order, which can be recorded as m1, m2, ..., m u .
[0038] In step S206, the specific encryption process can be implemented in the following manner: taking the modulus of the number to be encrypted with multiple target large prime numbers to obtain multiple remainders; substituting the multiple remainders and the multiple target large prime numbers into a preset formula to determine the minimum solution of the preset formula; performing an XOR operation on the minimum solution and the number to be encrypted to obtain a target offset corresponding to the number to be encrypted; concatenating the multiple remainders with the target offset to obtain a first ciphertext number; concatenating the first ciphertext number with the target hash value to obtain a second ciphertext number; encoding the second ciphertext data to obtain the encrypted plaintext to be encrypted, and determining the encrypted plaintext to be encrypted as the ciphertext.
[0039] In actual application scenarios, we can randomly select n large prime numbers from a large prime number set and arrange them in ascending order, denoted as: m1, m2…m n, the numbers to be encrypted are respectively m1,m2…m n Take the remainder and get multiple remainders a1, a2…a n ,
[0040] It is understandable that the number to be encrypted can be regarded as m1, m2…m n Based on remainder a1, a2…a n A special solution of .
[0041] Multiple remainders a1, a2…a n Substituting into the preset formula, we get the value based on the encrypted numbers m1, m2…m n The minimum solution of .
[0042] It should be noted that the preset formula is a linear congruence equation system determined by the remainder theorem formula, which converts multiple target large prime numbers m1, m2…m n and multiple remainders a1, a2…a n Substituting into the linear congruence equations of one variable, the minimum value in the solution set obtained by the general solution formula of the linear congruence equations of one variable is the minimum solution.
[0043] Perform an XOR operation on the minimum solution and the number to be encrypted to obtain the target offset.
[0044] In an optional manner, the first ciphertext number is obtained by splicing: determining the number of digits of multiple remainders and the corresponding target large prime number in sequence; determining a target remainder whose median is smaller than the corresponding target large prime number, and padding the prefix of the target remainder with zeros to make the number of digits of the target remainder consistent with the number of digits of the corresponding target large prime number; and splicing the multiple remainders that have been padded with zeros to the target offset in sequence according to the order of the corresponding target large prime numbers to obtain the first ciphertext number, wherein the order of the corresponding target large prime numbers is in ascending order.
[0045] Taking the target large prime number as 11,613 as an example, the number to be encrypted 54091677185334 is divided and multiple remainders are obtained: 8, 20. Substitute the remainder and the target large prime number as parameters and coprime prime numbers into the remainder theorem, and the minimum solution is 998. The minimum solution is XORed with the number to be encrypted 54091677185334 to obtain the target offset 54091677185774.
[0046] It can be understood that the target large prime number corresponding to remainder 8 is 11, and the target large prime number corresponding to remainder 20 is 613. The digits of remainder 8 and remainder 20 are both smaller than the corresponding target large prime numbers. Remainder 8 and remainder 20 are determined as target remainders, and 0 is added to the prefix of the target remainder 8 to obtain 08, and 0 is added to the prefix of the target remainder 20 to obtain 020. 08 and 020 are respectively spliced to the target offset 54091677185774 to obtain the first ciphertext number: 5409167718574408020.
[0047] The target hash values corresponding to the multiple target large prime numbers can be determined by: determining the product of the multiple target large prime numbers, and determining the target hash value corresponding to the product of the multiple target large prime numbers; recording the product of the multiple target large prime numbers and the target hash value in the form of a key-value pair. Taking the target large prime number as 11,613 as an example, the target hash value is md5(11*163)=c8cbd669cfb2f016574e9d147092b5bb.
[0048] In an optional manner, a method for concatenating a first ciphertext number with a target Hash value to obtain a second ciphertext number includes: converting the first ciphertext number into a hexadecimal number to obtain an initial ciphertext number; and concatenating the target Hash value to the initial ciphertext number to obtain a second ciphertext number.
[0049] Specifically, the first ciphertext number: 5409167718574408020 is converted into a hexadecimal number to obtain the initial ciphertext number 4b1139618c234000, which is then concatenated with the target hash value to obtain the second ciphertext number 4b1139618c234000c8cbd669cfb2f016574e9d147092b5bb.
[0050] In the above steps, the second ciphertext data is encoded to obtain the encrypted plaintext to be encrypted, including: converting the second ciphertext data into a first byte stream; encoding the first byte stream according to a preset format to complete the encryption of the plaintext to be encrypted.
[0051] Specifically, the second ciphertext number 4b1139618c234000c8cbd669cfb2f016574e9d147092b5bb is converted into a first byte stream, and then the first byte stream is encoded in base64 format to obtain a ciphertext: NGIxMTM5NjE4YzIzNDAwMGM4Y2JkNjY5Y2ZiMmYwMTY1NzRlOWQxNDcwOTJi NWJi.
[0052] In the above steps, the method for converting the plaintext to be encrypted into the number to be encrypted includes: converting the plaintext to be encrypted into a second byte stream; converting the second byte stream into a hexadecimal value; converting the hexadecimal value into a decimal value to obtain the number to be encrypted.
[0053] Taking the plaintext to be encrypted as 123456 as an example, the plaintext to be encrypted 123456 is converted into a second byte stream, and then converted into a hexadecimal number to obtain the number to be encrypted 54091677185334.
[0054] It should be noted that traditional symmetric encryption algorithms are generally fixed groupings, such as the AES algorithm, which is grouped in 16 bytes, and the key length is independent of the grouping. The encryption method provided by this application, the grouping size depends on a random set of coprime large prime numbers, the lengths of each group can be inconsistent, and there is no causal relationship between the ciphertexts of the groups. The ciphertext also introduces an offset, and multiple encryptions of the same plaintext will result in different encryption results, which greatly increases the difficulty of cracking.
[0055] At the same time, during encryption, the remainder set is obtained in parallel based on the plaintext and the random target large prime number set, and then the remainder set and the random target large prime number set are substituted into the remainder theorem, and the operation of solving the univariate linear equation is performed once to obtain the minimum solution, and then the minimum solution and the plaintext are XORed to obtain the target offset, and finally the target offset, remainder set, and target hash value are assembled into ciphertext.
[0056] The present application also provides a decryption method for decrypting the ciphertext encrypted by the above encryption method. Figure 3 As shown, including:
[0057] Step S302, receiving the ciphertext to be decrypted, intercepting the last thirty-two bits of the ciphertext, and determining them as the target hash value;
[0058] Step S304, determining multiple target large prime numbers corresponding to the target hash value;
[0059] Step S306, converting the remaining ciphertext after truncation into decimal, and determining a plurality of remainders in sequence;
[0060] Step S308, removing multiple remainders from the remaining ciphertext after truncation to obtain a target offset;
[0061] Step S310, determining the plaintext corresponding to the ciphertext to be decrypted based on multiple target large prime numbers, multiple remainders and target offsets.
[0062] Specifically, (1) the secret key is agreed to be a set of large prime numbers U, the size of U is denoted as u, and the large prime numbers in U are mutually prime and arranged in ascending order, denoted as: m1,m2…m u ;
[0063] (2) Pick any two prime numbers from the large prime number set, arrange m1 and m2 in ascending order, calculate the hash value of m1*m2, and so on until you pick any u prime numbers and calculate the hash value of m1*m2…m u The hash value is recorded in the form of key-value pairs <multiple prime product hashes, multiple prime numbers>, the total number is C(2,u)+...+C(u,u), that is, 2 u -u pieces;
[0064] (3) Decode the ciphertext in base64 and convert it to hexadecimal to obtain the ciphertext to be decrypted;
[0065] (4) Extract the last 32 bits of the ciphertext to be decrypted from the back to the front as the target hash value, and obtain the large prime number set m1, m2…m from the key-value pair. n ;
[0066] (5) determining the corresponding target large prime number from the key-value pair according to the target hash value;
[0067] (6) Convert the remaining ciphertext after truncation into decimal, determine multiple remainders in sequence, and obtain the target offset;
[0068] (7) determining a minimum solution based on multiple remainders, and performing an XOR operation on the minimum solution and the target offset to obtain a number to be encrypted;
[0069] (8) Convert the number to be encrypted into a hexadecimal number, and then convert it into a byte stream to finally obtain the plaintext to be encrypted.
[0070] The decryption method provided by the present application extracts the target hash value according to the ciphertext during decryption, finds the large prime number set corresponding to the target hash value, and then extracts the ciphertext in parallel to obtain the remainder set and the target offset, and then substitutes the remainder set and the target large prime number set into the remainder theorem, performs a one-variable linear equation operation, obtains the minimum solution, and then XORs the minimum solution and the target offset to obtain the plaintext.
[0071] The present application embodiment provides an encryption device, such as Figure 4 As shown, it includes: an acquisition module 40, used to obtain a large prime number set composed of multiple large prime numbers and a plaintext to be encrypted, wherein the large prime numbers in the large prime number set are mutually prime; a conversion module 42, used to convert the plaintext to be encrypted into a number to be encrypted, and randomly select a plurality of target large prime numbers from the large prime number set; a determination module 44, used to determine the target hash values corresponding to the plurality of target large prime numbers; an encryption module 46, used to complete the encryption of the number to be encrypted using the plurality of target large prime numbers, the number to be encrypted and the target hash value.
[0072] The encryption module 46 includes: an encryption submodule, which is used to take the modulus of the number to be encrypted with multiple target large prime numbers to obtain multiple remainders; substitute the multiple remainders and the multiple target large prime numbers into a preset formula to determine the minimum solution of the preset formula; perform an XOR operation on the minimum solution and the number to be encrypted to obtain a target offset corresponding to the number to be encrypted; concatenate the multiple remainders with the target offset to obtain a first ciphertext number; concatenate the first ciphertext number with the target hash value to obtain a second ciphertext number; encode the second ciphertext data to obtain an encrypted plaintext to be encrypted, and determine the encrypted plaintext to be encrypted as the ciphertext.
[0073] The encryption submodule includes: a first ciphertext unit, a second ciphertext unit, a third ciphertext unit and a target hash value unit, wherein the first ciphertext unit is used to sequentially determine the number of digits of multiple remainders and corresponding target large prime numbers; determine a target remainder whose median is smaller than the corresponding target large prime number, and fill the prefix of the target remainder with zeros to make the number of digits of the target remainder consistent with the number of digits of the corresponding target large prime number; sequentially splice the multiple remainders that have been filled with zeros to the target offset according to the order of the corresponding target large prime numbers to obtain a first ciphertext number, wherein the order of the corresponding target large prime numbers is in ascending order.
[0074] The second ciphertext unit is used to convert the first ciphertext number into a hexadecimal number to obtain an initial ciphertext number; and to concatenate the target hash value to the initial ciphertext number to obtain a second ciphertext number.
[0075] The third ciphertext unit is used to convert the second ciphertext data into a first byte stream; encode the first byte stream according to a preset format to complete the encryption of the plaintext to be encrypted.
[0076] The target hash value unit is used to determine the product of multiple target large prime numbers and determine the target hash value corresponding to the product of the multiple target large prime numbers; the product of the multiple target large prime numbers and the target hash value are recorded in the form of key-value pairs.
[0077] The conversion module 42 includes: a conversion submodule, which is used to convert the plaintext to be encrypted into the number to be encrypted, including: converting the plaintext to be encrypted into a second byte stream; converting the second byte stream into a hexadecimal value; converting the hexadecimal value into a decimal value to obtain the number to be encrypted.
[0078] According to another aspect of the embodiments of the present application, a non-volatile storage medium is provided, in which a program is stored, wherein when the program is running, the device where the non-volatile storage medium is located is controlled to execute the above encryption method.
[0079] According to another aspect of the embodiments of the present application, a computer device is provided, including: a memory and a processor, the processor being used to run a program stored in the memory, wherein the above encryption method is executed when the program is run.
[0080] It should be noted that the various modules in the above-mentioned encryption device can be program modules (for example, a set of program instructions that implement a certain specific function) or hardware modules. For the latter, it can be expressed in the following forms, but is not limited to this: the expression form of each of the above-mentioned modules is a processor, or the functions of each of the above-mentioned modules are implemented by a processor.
[0081] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0082] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.
[0083] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of units can be a logical function division. There may be other division methods in actual implementation. For example, 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 units or modules, which can be electrical or other forms.
[0084] 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 over multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0085] 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.
[0086] 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 storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the relevant technology or all or part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes 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 each embodiment method of the present application. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk, etc. Various media that can store program codes.
[0087] The above are only preferred implementations of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. An encryption method, characterized in that: include: Obtain a large prime number set consisting of a plurality of large prime numbers and a plaintext to be encrypted, wherein the large prime numbers in the large prime number set are mutually prime; Converting the plaintext to be encrypted into a number to be encrypted, and randomly selecting a plurality of target large prime numbers from the large prime number set; Determining target hash values corresponding to the multiple target large prime numbers includes: determining the product of the multiple target large prime numbers, and determining the target hash value corresponding to the product of the multiple target large prime numbers; encrypting the number to be encrypted using the multiple target large prime numbers, the number to be encrypted, and the target hash value; Using the multiple target large prime numbers, the number to be encrypted and the target hash value, encrypting the number to be encrypted includes: Taking the modulo of the number to be encrypted and the multiple target large prime numbers to obtain multiple remainders; Substituting the multiple remainders and the multiple target large prime numbers into a preset formula to determine a minimum solution of the preset formula; Performing an XOR operation on the minimum solution and the number to be encrypted to obtain a target offset corresponding to the number to be encrypted; Concatenate the multiple remainders with the target offset to obtain a first ciphertext number; Concatenate the first ciphertext number and the target Hash value to obtain a second ciphertext number; The second ciphertext data is encoded to obtain encrypted plaintext to be encrypted, and the encrypted plaintext to be encrypted is determined as ciphertext, and the preset formula is a univariate linear congruential equation group determined by a remainder theorem formula.
2. The method according to claim 1, characterized in that: The plurality of remainders are concatenated with the target offset to obtain a first ciphertext number, including: Determining in sequence the number of digits of the plurality of remainders and the corresponding target large prime number; Determine a target remainder whose median of the multiple remainders is smaller than the corresponding target large prime number, and fill a prefix of the target remainder with zeros so that the number of digits of the target remainder is consistent with the number of digits of the corresponding target large prime number; The multiple remainders after zero padding are sequentially spliced to the target offset according to the order of the corresponding target large prime numbers to obtain the first ciphertext number, wherein the order of the corresponding target large prime numbers is in ascending order.
3. The method according to claim 1, characterized in that The first ciphertext number and the target Hash value are concatenated to obtain a second ciphertext number, including: Convert the first ciphertext number into a hexadecimal number to obtain an initial ciphertext number; The target Hash value is concatenated with the initial ciphertext number to obtain the second ciphertext number.
4. The method according to claim 1, characterized in that Encoding the second ciphertext data to obtain encrypted plaintext to be encrypted includes: Converting the second ciphertext data into a first byte stream; The first byte stream is encoded according to a preset format to complete the encryption of the plaintext to be encrypted.
5. The method according to claim 1, characterized in that Determining a hash value corresponding to the product of the plurality of target large prime numbers includes: The product of the multiple target large prime numbers and the target hash value are recorded in a key-value pair format.
6. The method according to claim 1, characterized in that Converting the plaintext to be encrypted into a number to be encrypted includes: Converting the plaintext to be encrypted into a second byte stream; Convert the second byte stream into a hexadecimal value; The hexadecimal value is converted into a decimal value to obtain the number to be encrypted.
7. A decryption method, characterized in that: include: Receiving a ciphertext to be decrypted, intercepting the last thirty-two bits of the ciphertext, and determining them as a target hash value, wherein the ciphertext is generated by the encryption method of any one of claims 1 to 6; Determine a plurality of target large prime numbers corresponding to the target hash value; Convert the remaining ciphertext after truncation into decimal, and determine the multiple remainders in sequence; The ciphertext remaining after the truncation is removed by removing the multiple remainders to obtain a target offset; The plaintext corresponding to the ciphertext to be decrypted is determined based on the multiple target large prime numbers, the multiple remainders and the target offset.
8. An encryption device, characterized in that: include: An acquisition module, used for acquiring a large prime number set consisting of a plurality of large prime numbers and a plaintext to be encrypted, wherein the large prime numbers in the large prime number set are mutually prime; A conversion module, used for converting the plaintext to be encrypted into a number to be encrypted, and randomly selecting a plurality of target large prime numbers from the large prime number set; A determination module, configured to determine target hash values corresponding to the plurality of target large prime numbers, comprising: determining a product of the plurality of target large prime numbers, and determining a target hash value corresponding to the product of the plurality of target large prime numbers; An encryption module, used to encrypt the number to be encrypted using the multiple target large prime numbers, the number to be encrypted and the target hash value; Using the multiple target large prime numbers, the number to be encrypted and the target hash value, encrypting the number to be encrypted includes: Taking the modulo of the number to be encrypted and the multiple target large prime numbers to obtain multiple remainders; Substituting the multiple remainders and the multiple target large prime numbers into a preset formula to determine a minimum solution of the preset formula; Performing an XOR operation on the minimum solution and the number to be encrypted to obtain a target offset corresponding to the number to be encrypted; Concatenate the multiple remainders with the target offset to obtain a first ciphertext number; Concatenate the first ciphertext number and the target Hash value to obtain a second ciphertext number; The second ciphertext data is encoded to obtain encrypted plaintext to be encrypted, and the encrypted plaintext to be encrypted is determined as ciphertext, and the preset formula is a univariate linear congruential equation group determined by a remainder theorem formula.
9. A non-volatile storage medium, characterized in that: The non-volatile storage medium stores a program, wherein when the program is running, the device where the non-volatile storage medium is located is controlled to execute the encryption method according to any one of claims 1 to 6.
10. A computer device, characterized in that: include: A memory and a processor, wherein the processor is used to run a program stored in the memory, wherein the encryption method described in any one of claims 1 to 6 is executed when the program is run.
Citation Information
Patent Citations
AMI wireless sensor network security data aggregation method, electronic equipment and medium
CN108834094A
Privacy protection set intersection solving method based on DH encryption and Hash table
CN111552978A