Digital encryption and decryption method, device, terminal equipment and storage medium
By performing bit-complement and symmetric segmentation of encrypted numbers, and using digital tables to replace encryption and key encryption, the problem of Virginia passwords being easily cracked is solved, achieving higher encryption strength and security.
Patent Information
- Application Number
- CN202111210290.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-18
- Publication Date
- 2025-08-19
- Estimated Expiration
- 2041-10-18
AI Technical Summary
The key loop of existing Virginia passwords is repeated, which is easy to crack and has poor security.
By filling in the digits to be encrypted and symmetrically segmenting, the first digital table uses the permutation encryption of the high and low digits, combining key encryption, superimposing the digital table permutation reversible algorithm to improve the encryption strength.
Enhanced the security of digital encryption, improve the stability and difficulty of cracking of digital.
Smart Images

Figure CN113946847B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of computer technology, and in particular to a digital encryption and decryption method, apparatus, terminal device, and storage medium. Background Art
[0002] In the prior art, the Virginia cipher encryption algorithm can be used to encrypt numbers.
[0003] During the implementation of the present invention, the inventors discovered that the prior art suffers from at least the following technical issues: The key of the Vigenère cipher is cyclically repeated, and the key length can be determined using the Kasiski test or the Friedman test. Once the key length is determined, the ciphertext can be viewed as an interwoven Caesar cipher, making it easily crackable and resulting in poor security. Summary of the Invention
[0004] The embodiments of the present invention provide a digital encryption and decryption method, apparatus, terminal equipment and storage medium, which can improve the security of digital encryption.
[0005] In a first aspect, an embodiment of the present invention provides a digital encryption method, comprising:
[0006] The number to be encrypted is padded, and the padded number is symmetrically divided to obtain the first high-order digit and the first low-order digit;
[0007] For each digit in the first high-order digit and the first low-order digit, performing permutation encryption on each digit based on the first number table to obtain a second high-order digit and a second low-order digit;
[0008] Determining an original text and a key based on the second high-order digit and the second low-order digit, and encrypting the original text using the key to obtain a ciphertext of the original text;
[0009] An encryption result of the number to be encrypted is obtained according to the ciphertext and the key.
[0010] In a second aspect, an embodiment of the present invention provides a digital decryption method, comprising:
[0011] Determining the ciphertext and key from the number to be decrypted;
[0012] Decrypting the ciphertext using the key to obtain the original text of the ciphertext, and determining the second most significant digit and the second least significant digit based on the original text and the key;
[0013] Perform reverse permutation decryption on the digits in the second high-order digit and the second low-order digit based on the first digital table to obtain the first high-order digit and the first low-order digit;
[0014] The first high-order digit and the first low-order digit are concatenated, and a decryption result of the number to be decrypted is determined according to the concatenation result.
[0015] In a third aspect, an embodiment of the present invention provides a digital encryption device, comprising:
[0016] A segmentation module is used to pad the digits of the number to be encrypted and symmetrically split the padded number to obtain the first high-order digit and the first low-order digit;
[0017] a first encryption module, configured to perform permutation encryption on each of the first high-order digits and the first low-order digits based on a first number table to obtain a second high-order digit and a second low-order digit;
[0018] a second encryption module, configured to determine an original text and a key according to the second high-order digit and the second low-order digit, and encrypt the original text using the key to obtain a ciphertext of the original text;
[0019] The result determination module is used to obtain the encryption result of the number to be encrypted according to the ciphertext and the key.
[0020] In a fourth aspect, an embodiment of the present invention provides a digital decryption device, comprising:
[0021] A ciphertext key determination module, used to determine the ciphertext and key from the number to be decrypted;
[0022] a first decryption module, configured to decrypt the ciphertext using the key to obtain the original text of the ciphertext, and determine the second high-order digit and the second low-order digit based on the original text and the key;
[0023] a second decryption module, configured to perform reverse permutation decryption on the digits in the second high-order digit and the second low-order digit based on the first digital table to obtain a first high-order digit and a first low-order digit;
[0024] The splicing module is used to splice the first high-order digit and the first low-order digit, and determine the decryption result of the number to be decrypted according to the splicing result.
[0025] In a fifth aspect, an embodiment of the present invention provides a terminal device, including:
[0026] one or more processors;
[0027] a memory for storing one or more programs;
[0028] When the one or more programs are executed by the one or more processors, the one or more processors implement the digital encryption method as described in any embodiment of the present invention, or implement the digital decryption method as described in any embodiment of the present invention.
[0029] In a sixth aspect, an embodiment of the present invention provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, it implements the digital encryption method as described in any embodiment of the present invention, or implements the digital decryption method as described in any embodiment of the present invention.
[0030] Embodiments of the present invention provide a digital encryption and decryption method, apparatus, terminal device, and storage medium. The digital encryption method includes: padding a number to be encrypted and symmetrically splitting the padded number to obtain a first high-order digit and a first low-order digit; performing permutation encryption on each digit in the first high-order digit and the first low-order digit based on a first number table to obtain a second high-order digit and a second low-order digit; determining an original text and a key based on the second high-order digit and the second low-order digit, and encrypting the original text using the key to obtain a ciphertext of the original text; and obtaining an encryption result of the number to be encrypted based on the ciphertext and the key. By superimposing a reversible permutation algorithm for the number table on key encryption, encryption strength can be enhanced and digital security can be improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following is a brief introduction to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0032] Figure 1 A flowchart of a digital encryption method provided by the first embodiment of the present invention is shown;
[0033] Figure 2 A flowchart of a digital encryption method provided by the second embodiment of the present invention is shown;
[0034] Figure 3 A flowchart of a digital encryption method provided in Embodiment 3 of the present invention is shown;
[0035] Figure 4 A flowchart of a digital decryption method provided by a fourth embodiment of the present invention is shown;
[0036] Figure 5 A flowchart of a digital decryption method provided in Embodiment 5 of the present invention is shown;
[0037] Figure 6 A flowchart of a digital decryption method provided by embodiment 6 of the present invention is shown;
[0038] Figure 7A flowchart of a digital encryption and decryption method provided in Embodiment 7 of the present invention is shown;
[0039] Figure 8 A schematic structural diagram of a digital encryption device provided in an eighth embodiment of the present invention is shown;
[0040] Figure 9 A schematic structural diagram of a digital decryption device provided in a ninth embodiment of the present invention is shown;
[0041] Figure 10 A schematic diagram of the hardware structure of a terminal device provided in the tenth embodiment of the present invention is shown. DETAILED DESCRIPTION
[0042] In order to make the purpose, technical solutions and advantages of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below through implementation methods with reference to the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention. In the following embodiments, each embodiment provides optional features and examples at the same time. The various features recorded in the embodiments can be combined to form multiple optional solutions. Each numbered embodiment should not be regarded as just one technical solution.
[0043] Example 1
[0044] Figure 1 A flowchart of a digital encryption method provided in Embodiment 1 of the present invention is shown. The digital encryption and decryption method provided in this embodiment of the present invention is applicable to situations where digital data is encrypted. The method can be performed by a digital encryption device, which is implemented in software and / or hardware and is preferably configured in a terminal device, such as a computer.
[0045] like Figure 1 As shown, the digital encryption method provided in the embodiment of the present invention includes the following steps:
[0046] S110 , padding the number to be encrypted, and symmetrically dividing the padded number to obtain the first high-order digit and the first low-order digit.
[0047] In embodiments of the present invention, the encrypted number can be any number that requires security during transmission, display, or storage, and can include multiple digits. For example, in some implementations, the encrypted number can include numbers in a website address. By encrypting key digits in a website address, it is possible to prevent external crawlers from traversing and crawling the website's webpage information by simply exhaustively enumerating the page URLs, thereby protecting the security of the website's webpage information to a certain extent.
[0048] When pre-designing a digital encryption method, a number of digits that the encrypted number must meet can be set based on the consideration that the encryption algorithm involved in the encryption method can stably decrypt. Accordingly, during the encryption process of the encrypted number according to the encryption method, if the encrypted number does not meet the preset number of digits, the encrypted number can be padded with zeros on the left to complete the number of digits.
[0049] The preset digit condition can be an even digit. Accordingly, after symmetrically dividing the padded digits, two groups of digits with the same digits can be obtained. The two groups of digits can be divided into low-order digits and high-order digits according to the order of "ones, tens, hundreds, thousands..." from low to high, and the division of low-order digits and high-order digits is relative. For example, if the two groups of digits each contain two digits, the "ones" and "tens" digits are low-order digits, and the "hundreds" and "thousands" digits are high-order digits; if the two groups of digits after division each contain three digits, the "ones" and "tens" digits are low-order digits, and the "thousands" and "hundreds" digits are high-order digits.
[0050] After the high-order digits and low-order digits are obtained, each group of digits can be combined in descending order to obtain the first high-order digit and the first low-order digit. For example, if the two groups of digits each contain two digits, the digits in the "units" and "tens" digits are "1" and "2" respectively, and the digits in the "hundreds" and "thousands" digits are "3" and "4" respectively, then the low-order digits can be combined in descending order to obtain the first low-order digit "21", and the high-order digits can be combined in descending order to obtain the first high-order digit "43".
[0051] S120 , performing permutation encryption on each digit in the first high-order digit and the first low-order digit based on the first number table to obtain a second high-order digit and a second low-order digit.
[0052] In this embodiment, each digit in the first high-order digit and the second high-order digit can be permuted and encrypted based on the first digital table. Permuting and encrypting each digit based on the first digital table can be considered as searching the first permutation table for the number corresponding to each digit, and permuting each digit according to the corresponding number to obtain a permuted digit. After obtaining the permuted digit for each digit, the permuted digits can be combined according to the position of each digit in the first high-order digit or the first low-order digit before the permutation, thereby obtaining the second high-order digit and the second low-order digit.
[0053] The permutation encryption process is a reversible process, and the numbers before permutation can be determined based on the numbers after permutation based on the same first digital table, thereby facilitating stable decryption after digital encryption.
[0054] S130. Determine the original text and the key according to the second highest digit and the second lowest digit, and encrypt the original text using the key to obtain a ciphertext of the original text.
[0055] In this embodiment, the second most significant digit can be used as the original text and the second least significant digit as the key; alternatively, the second least significant digit can be used as the original text and the second most significant digit as the key. The original text can be encrypted using the key using a reversible encryption algorithm that encrypts numbers into numbers. The reversible encryption algorithm that encrypts numbers into numbers can be, for example, based on XOR, Caesar cipher, or Vigenère cipher, and the examples are not exhaustive.
[0056] S140. Obtain an encryption result of the number to be encrypted according to the ciphertext and the key.
[0057] In this embodiment, the ciphertext and the key can be concatenated to obtain the encrypted result of the number to be encrypted. By utilizing the permutation obfuscation encryption of the first digital table and combining it with key encryption, a stable encryption and decryption process can be achieved, and the encryption strength is enhanced, thereby improving the digital security.
[0058] In some optional embodiments, each number is permuted and encrypted based on the first number table, including: determining the first index position of the first number table according to the current number; indexing the first number table according to the first index position to obtain the supplementary digits of the current number; and using the supplementary digits to supplement the current number to obtain the number after the current number is permuted and encrypted.
[0059] The first digital table can be a two-dimensional digital table. Accordingly, the first index position of the first digital table can be a two-dimensional coordinate, where the first-dimensional coordinate value and the second-dimensional coordinate value can represent the row number and column number of the table. Since the first index position is determined based on the current number, which can be 0-9, the row number and column number of the two-dimensional coordinate of the first index position can be 0-9, and the column number can be 0-9, that is, the first digital table can be a 10×10 digital table.
[0060] The first index position can be determined by performing an operation based on the current number. For example, the current number can be directly used as the first-dimensional coordinate value of the first index position, and the current number minus 1 can be used as the second-dimensional coordinate value of the first index position. For another example, the current number minus 1 can be used as the first-dimensional coordinate value of the first index position, and the current number can be directly used as the second-dimensional coordinate value of the first index position. This is not exhaustive.
[0061] After determining the first index position, the first number table can be searched according to the first index position to obtain a place-filling digit corresponding to the current number. The place-filling digit can then be added to the left or right side of the current number, and the current number can be replaced with the place-filled digit to obtain a replacement encrypted number of the current number.
[0062] For example, Table 1 shows an example of a first digital table in a digital encryption method provided by an embodiment of the present invention. Referring to Table 1, the first digital table is a 10×10 digital table, and the row index number and column index number in the first index position can be 0-9.
[0063] Table 1
[0064] 6 1 3 5 2 0 8 4 7 9 3 7 2 9 0 5 8 4 6 1 7 1 5 8 9 2 0 6 3 4 3 2 8 7 1 0 5 6 4 9 0 9 5 7 3 1 2 8 4 6 6 4 0 7 9 3 8 5 1 2 6 3 7 4 1 8 0 2 9 5 0 1 3 2 7 9 6 8 5 4 1 8 7 0 5 9 5 4 3 6 4 7 2 9 0 8 3 1 5 6
[0065] Assuming that the first high-order digit is 68, the process of encrypting the first high-order digit based on the first digital table in Table 1 to obtain the second high-order digit may include:
[0066] For the number 6, 6 can be directly used as the first-dimensional coordinate value in the first index position, and 6 minus 1 can be used as the second-dimensional coordinate value in the first index position, that is, the first index position is [6,5]. You can use [6,5] to search Table 1 and get the padding digit 8. The padding digit 8 can be added to the right side of 6 to get the number 68 after the permutation encryption of 6;
[0067] For the number 8, 8 can be directly used as the first-dimensional coordinate value in the first index position, and 8 minus 1 can be used as the second-dimensional coordinate value in the first index position, that is, the first index position is [8,7]. You can use [8,7] to search Table 1 and get the padding digit 4. The padding digit 4 can be added to the right side of 8 to get the number 84 after permutation encryption;
[0068] According to the positions of 6 and 8 in the first high-order digit, the replaced digits 68 and 84 are combined to obtain the second high-order digit 6884.
[0069] In these optional implementations, by performing permutation encryption on the first digital table, the first high-order digit and the first low-order digit can be obfuscated and encrypted, and stable reversible decryption can be achieved.
[0070] In some optional embodiments, encrypting the original text using a key includes: determining whether the original text and the key are included in the second digital table; if so, determining the second index position of the second digital table based on the original text and the key; indexing the second digital table based on the second index position to obtain ciphertext corresponding to the original text.
[0071] The original text can be encrypted using a key using a Virginia cipher algorithm. The encryption process can include: obtaining a second digital table corresponding to the Virginia cipher algorithm, wherein the row index, column index, and table contents of the second digital table can all be numbers; determining whether the original text and the key are respectively contained in the row index and column index, or determining whether the original text and the key are respectively contained in the column index and row index; if so, the original text can be used as the row index number in the second index position and the key as the column index number in the second index position, or the original text can be used as the column index number in the second index position and the key as the row index number in the second index position; and searching for ciphertext corresponding to the original text based on the second index position.
[0072] If it is determined that the original text and the key are not included in the second digital table, a prompt related to encryption failure can be given to prompt the encrypted data to be corrected.
[0073] In these optional implementations, the Virginia encryption algorithm can be implemented by Java, and stable encryption and decryption of numbers in the original text and ciphertext can be achieved based on the symmetric key and the corresponding second number table in the Virginia algorithm.
[0074] An embodiment of the present invention provides a digital encryption method that pads the number to be encrypted and symmetrically splits the padded number to obtain a first high-order digit and a first low-order digit. For each digit in the first high-order digit and the first low-order digit, encryption is performed based on a first digital table to obtain a second high-order digit and a second low-order digit. The original text and a key are determined based on the second high-order digit and the second low-order digit, and the original text is encrypted using the key to obtain a ciphertext of the original text. The encryption result of the number to be encrypted is obtained based on the ciphertext and the key. By superimposing a reversible digital table permutation algorithm on key encryption, encryption strength can be enhanced and digital security can be improved.
[0075] Example 2
[0076] This embodiment, building on the previous embodiment, details the steps for determining the original text and key from the second-highest digit and the second-lowest digit. By converting the second-highest digit and the second-lowest digit into binary, shifting them left, and converting them into decimal long integers, we can implement shift encryption of the second-highest digit and the second-lowest digit. This shift encryption method is a stable and reversible algorithm that further increases the difficulty of decrypting the encrypted number, thereby enhancing digital security.
[0077] Figure 2 FIG2 shows a flow chart of a digital encryption method provided by the second embodiment of the present invention. Figure 2 The digital encryption method provided in the embodiment of the present invention includes the following steps:
[0078] S210 , padding the number to be encrypted, and symmetrically dividing the padded number to obtain the first high-order digit and the first low-order digit.
[0079] S220 , performing substitution encryption on each digit in the first high-order digit and the first low-order digit based on the first number table to obtain a second high-order digit and a second low-order digit.
[0080] The second highest digit and the second lowest digit contain multiple segments of decimal digits. For example, in one implementation, during the permutation encryption process of each digit based on the first digital table, the permutation encrypted digits corresponding to each digit can be combined using a separator to obtain the second highest digit and the second lowest digit containing multiple segments of decimal digits. For example, assuming that the first highest digit is 68, and the permutation encrypted digits of 6 and 8 are 68 and 84 respectively, 68 and 84 can be combined using the separator "." to obtain 68.84 as the second highest digit. In this case, the second highest digit includes two segments of decimal digits. The separator is not limited to ".", and can also be, for example, a space or " / ".
[0081] S230 , converting each segment of decimal digits into binary digits for the second highest digit and the second lowest digit.
[0082] For both the second highest digit and the second lowest digit, each segment of decimal digits can be determined based on the separator. Furthermore, each segment of decimal digits can be converted into a binary digit with a preset number of digits to obtain multiple segments of binary digits. If the binary-converted digits do not meet the preset number of digits, zeros can be added to the left to complete the number of digits to the preset number of digits.
[0083] S240 , shifting each segment of binary digits left according to the position of each segment of binary digits in the entire segment of binary digits to which it belongs.
[0084] Among them, for the second highest digit and the second lowest digit, the position of each decimal digit before binary conversion in the entire decimal digit segment to which it belongs can be used as the position of each binary digit after binary conversion in the entire binary digit segment to which it belongs.
[0085] For example, assuming the second highest digit is 68.84, and the binary conversion requires an 8-digit number, 68 is converted to 01000100, and 84 is converted to 01010100. Because, before binary conversion, 68 is located in the first group of positions to the left of the entire segment of decimal digits "68.84," and 84 is located in the second group of positions to the left of the entire segment of decimal digits "68.84," after binary conversion, "01000100" will be located in the first group of positions to the left of the entire segment of binary digits, and "01010100" will be located in the second group of positions to the left of the entire segment of binary digits, resulting in the entire segment of binary digits being "01000100.01010100."
[0086] Each segment of binary digits is left-shifted based on its position within the entire segment of binary digits. Each segment of binary digits, from left to right, may be left-shifted by a different number of bits, and the number of bits shifted left may be larger the closer to the right. For example, assuming the binary conversion contains four segments of binary digits, the first segment of binary digits may not be left-shifted, the second segment may be left-shifted by 8 bits, the third segment may be left-shifted by 16 bits, and the fourth segment may be left-shifted by 24 bits.
[0087] S250, converting the binary number obtained by splicing the left-shifted binary digits into a decimal number to obtain the third highest digit and the third lowest digit after the second highest digit and the second lowest digit are encrypted by the bit shift.
[0088] The left-shifted binary digits can be concatenated to form a new binary digit. For example, assuming that the left-shifted binary digits are "01000100" and "01010100" respectively, the two binary digits can be concatenated to form a new binary digit "0100010001010100", which can then be converted into a decimal digit "17492". The decimal digit can be a long integer.
[0089] By performing binary conversion, left shifting, concatenation, and decimal conversion on each decimal segment of the second highest digit and the second lowest digit, the third highest digit and the third lowest digit after the second highest digit and the second lowest digit are obtained through bit shift encryption. This bit shift encryption method is a stable and reversible algorithm.
[0090] S260. Use the third highest digit and the third lowest digit as the original text and the key respectively, and use the key to encrypt the original text to obtain the ciphertext of the original text.
[0091] Among them, the third highest digit can be used as the original text and the third lowest digit can be used as the key; or the third lowest digit can be used as the original text and the third highest digit can be used as the key.
[0092] S270. Obtain an encryption result of the number to be encrypted based on the ciphertext and the key.
[0093] By further superimposing displacement encryption on the basis of key encryption and digital table permutation encryption, the difficulty of decomposing the encrypted number can be further increased, thereby improving the security of the number.
[0094] In some optional implementations, the second-highest digit and the second-lowest digit may conform to a URL format, i.e., comprise four decimal digits. Furthermore, to ensure that the four decimal digits are within the range of 0-255, each digit may be permutation-encrypted based on the first number table, and the encrypted result may be padded to the left with 1s to obtain multiple decimal digits within the range of 0-255. The second-highest digit and the second-lowest digit that conform to the URL format may be subjected to binary conversion, left shift, concatenation, and decimal conversion of the four decimal digits to obtain the third-highest digit and the third-lowest digit.
[0095] For example, the second highest digit could be "168.184.184.195." Assuming the preset number of bits for binary conversion is 8, and counting from left to right after binary conversion, the first segment of binary digits is not left-shifted, the second segment of binary digits is left-shifted 8 bits, the third segment of binary digits is left-shifted 16 bits, and the fourth segment of binary digits is left-shifted 24 bits. Then, after binary conversion, left shifting, concatenating, and converting the decimal segments of the second highest digit "168.184.184.195," the third highest digit can be obtained as "2830678211."
[0096] In these optional implementations, if the number to be encrypted is in the URL format, the process of digit padding, symmetric segmentation, and permutation encryption based on the first number table can be omitted. Instead, the number can be directly used as the second-highest and second-lowest digits for shift encryption and key encryption. This greatly increases the flexibility of digital encryption.
[0097] Based on the above embodiment, the embodiment of the present invention describes in detail the steps of determining the original text and the key from the second high-order digit and the second low-order digit. By converting the second high-order digit and the second low-order digit into binary in segments, shifting them left and converting them into a decimal long integer, it is possible to implement displacement encryption of the second high-order digit and the second low-order digit. This displacement encryption method is a stable and reversible algorithm that can further increase the difficulty of reversing the digit, thereby improving the security of the digit. In addition, the digital encryption method proposed in the embodiment of the present invention and the above embodiment belongs to the same inventive concept. The technical details not fully described in this embodiment can be referred to the above embodiment, and this embodiment has the same beneficial effects as the above embodiment.
[0098] Example 3
[0099] This embodiment, building on the previous embodiment, details the steps for determining a seed character based on the second-highest digit and the second-lowest digit. Seed encryption is achieved by performing a calculation on the second-highest digit and the second-lowest digit, and then indexing a seed table based on the calculation result to obtain the seed character. This allows verification of the decryption process using the seed character, further increasing the difficulty of reverse-calculating the encrypted number and thus enhancing the security of the number.
[0100] Figure 3 FIG1 shows a flow chart of a digital encryption method provided by the third embodiment of the present invention. Figure 3 The digital encryption method provided in the embodiment of the present invention includes the following steps:
[0101] S310: pad the number to be encrypted, and symmetrically divide the padded number to obtain the first high-order digit and the first low-order digit.
[0102] S320: For each digit in the first high-order digit and the first low-order digit, perform substitution encryption on each digit based on the first number table to obtain a second high-order digit and a second low-order digit.
[0103] S331. Perform an operation using the second highest digit and the second lowest digit to obtain a third index position of the seed table.
[0104] The seed table can be a one-dimensional table. The elements of the seed table can include unique, non-numeric characters such as letters and symbols for verification and to distinguish them from encrypted and decrypted numbers. Accordingly, the third index position of the seed table can be a one-dimensional index number.
[0105] Among them, the steps for determining the third index position may include: first, converting the second high-order digit and the second low-order digit into binary digits, and then performing arithmetic operations (such as addition operations) or logical operations (such as exclusive OR operations) and the like; then, converting the operation result into a decimal number; finally, dividing the converted decimal number by the length of the seed table, and the remainder can be used as the third index position.
[0106] S341. Index the seed table according to the third index position to obtain a seed character.
[0107] The seed character can be obtained by searching the seed table according to the third index position.
[0108] S332. Determine the original text and the key according to the second highest digit and the second lowest digit, and encrypt the original text using the key to obtain a ciphertext of the original text.
[0109] There is no strict time sequence relationship between steps S331 - S341 and step S332 . Steps S331 - S341 may be executed first, step S332 may be executed first, or they may be executed simultaneously.
[0110] S350: Concatenate the ciphertext, the seed character, and the key to obtain an encryption result of the number to be encrypted.
[0111] When concatenating the ciphertext, seed character, and key, the seed character can be used as a separator to separate the ciphertext and key. Concatenation can be performed in the order of ciphertext first, seed character, and key, or key first, seed character, and ciphertext. The concatenation result can be used as the encryption result of the number to be encrypted.
[0112] By indexing the seed table based on the result of the second-highest digit and the second-lowest digit calculation and obtaining the seed character, the encrypted result can be obfuscated with the seed character. This facilitates verifying the normal decryption operation based on the seed character during the decryption process, thus avoiding abnormal forced cracking operations. By superimposing seed character encryption on top of digital table permutation encryption and key encryption, the difficulty of reverse calculation of the encrypted number can be increased, thereby enhancing the security of the number.
[0113] This embodiment of the present invention, based on the above-described embodiment, details the steps for determining a seed character based on the second-highest digit and the second-lowest digit. Seed encryption is achieved by performing a calculation on the second-highest digit and the second-lowest digit, and indexing a seed table based on the calculation result to obtain the seed character. This allows verification of the decryption process using the seed character during the decryption process, further increasing the difficulty of reverse-calculating the encrypted number and thus enhancing the security of the number.
[0114] The digital encryption methods proposed in the embodiments of the present invention and the above-mentioned embodiments are based on the same inventive concept. For technical details not fully described in this embodiment, please refer to the above-mentioned embodiments. This embodiment has the same beneficial effects as the above-mentioned embodiments. Furthermore, it is worth noting that the encryption algorithms for digital table permutation encryption, bit shift encryption, key encryption, and seed character encryption provided in the various embodiments of the present invention can be combined according to different application scenarios. The digital encryption methods formed by various combinations are all within the scope of protection of the present invention.
[0115] Example 4
[0116] Figure 4 A flowchart of a digital decryption method provided in accordance with a fourth embodiment of the present invention is shown. The digital decryption method provided in this embodiment of the present invention is applicable to decrypting digital data. This method can be performed by a digital decryption device implemented in software and / or hardware, preferably configured in a terminal device, such as a computer.
[0117] like Figure 4 As shown, the digital decryption method provided in the embodiment of the present invention includes the following steps:
[0118] S410: Determine the ciphertext and key from the number to be decrypted.
[0119] In this embodiment, the number to be decrypted can be composed of a ciphertext and a key. The ciphertext and the key can be extracted according to their positions in the number to be decrypted.
[0120] S420. Decrypt the ciphertext using the key to obtain the original ciphertext, and determine the second highest digit and the second lowest digit based on the original text and the key.
[0121] The key can be a symmetric key. If the original text is encrypted using the key to obtain ciphertext, the ciphertext can be decrypted using the same key to obtain the original text. This means that the key encryption and key decryption processes are symmetric reverse processes. The ciphertext can be decrypted using the key using a decryption algorithm that is the reverse of the encryption algorithm used during the key encryption process.
[0122] In some embodiments, decrypting the ciphertext using the key to obtain the original ciphertext may include: determining whether the ciphertext and the key are included in the second digital table; if so, reversing the search for the original text corresponding to the ciphertext from the second digital table based on the ciphertext and the key.
[0123] In these embodiments, the second digital table can be a digital table corresponding to the Virginia cipher algorithm, and the row index, column index, and table contents of the second digital table can all be numbers. A determination is made as to whether the ciphertext and key are contained in the contents of the digital table and the row / column indexes, respectively. If so, a reverse lookup can be performed on the original text corresponding to the ciphertext based on the ciphertext contents and the row / column indexes corresponding to the key, i.e., the column / row indexes can be searched. If it is determined that the ciphertext and key are not contained in the second digital table, a decryption failure notification can be displayed, and the decryption process can be stopped to improve data security.
[0124] S430 , performing reverse permutation decryption on the digits in the second high-order digit and the second low-order digit based on the first digit table to obtain the first high-order digit and the first low-order digit.
[0125] Among them, the process of performing reverse permutation decryption on the digits in the second high-order digit and the second low-order digit based on the first digital table is the reverse process of the process of performing permutation encryption on each digit based on the same first digital table.
[0126] The second highest digit and the second lowest digit may be used as the replaced digits. For each replaced digit, determining the digit before replacement may include: first searching for digits in the first number table that are identical to the replaced digits; then determining the row and column indexes corresponding to the identical digits; and finally, determining the correct digit before replacement based on the row and column indexes of the identical digits, since the row and column indexes can be determined based on the replaced digits.
[0127] After solving the digits before replacement of each digit in the second highest digit and the second lowest digit, the digits before replacement can be combined according to the position of each digit after replacement in the second highest digit or the second lowest digit to obtain the first highest digit and the first lowest digit.
[0128] In some implementations, performing reverse permutation decryption on the digits in the second high-order digit and the second low-order digit based on the first digit table may include:
[0129] The second highest digit and the second lowest digit are grouped separately, each group of digits including the digits before replacement and the corresponding digits for the replacement digits; the first index position of the first digit table is determined according to the digits before replacement; the first digit table is indexed according to the first index position, and the digits for the replacement digits are verified according to the index result; if the verification passes, each group of digits is reversely replaced with the array before replacement to obtain the first highest digit and the first lowest digit. In these embodiments, the step of determining the first index position according to the digits before replacement can refer to the above embodiment and will not be repeated here. Wherein, when the digits for the replacement digits are verified according to the index result, if the index result is consistent with the digits for the replacement digits, it can be considered that the verification has passed; if the index result is inconsistent with the digits for the replacement digits, it can be considered that the verification has failed. Wherein, if the verification fails, a prompt indicating the decryption failure can be given and the decryption process can be stopped to improve data security.
[0130] S440: Concatenate the first high-order digit and the first low-order digit, and determine a decryption result of the number to be decrypted according to the concatenation result.
[0131] The process of concatenating the first high-order digit and the first low-order digit is the reverse process of symmetrically dividing the padded digit. After concatenation, the padded digit can be filtered to obtain the decryption result of the digit to be decrypted.
[0132] An embodiment of the present invention provides a digital decryption method that determines a ciphertext and a key from a number to be decrypted; decrypts the ciphertext using the key to obtain the original ciphertext, and determines the second highest digit and the second lowest digit based on the original text and the key; performs reverse permutation decryption on the digits in the second highest digit and the second lowest digit based on a first digital table to obtain the first highest digit and the first lowest digit; concatenates the first highest digit and the first lowest digit, and determines the decryption result of the number to be decrypted based on the concatenation result. By using a key decryption algorithm superimposed on a digital table reverse permutation decryption algorithm, it is possible to reversely decrypt numbers encrypted using a key and a digital table permutation algorithm. This method not only achieves stable encryption and decryption, preventing digital modifications during decryption, but also improves the security of the number.
[0133] Furthermore, the key decryption and number table reverse permutation decryption processes in the embodiments of the present invention are the reverse of the key encryption and number table permutation encryption processes in the digital encryption methods proposed in the aforementioned embodiments. The encryption and decryption processes possess corresponding technical features and fall under the same inventive concept. Technical details not fully described in this embodiment can be found in the aforementioned embodiments, and this embodiment has the same beneficial effects as the aforementioned embodiments.
[0134] Example 5
[0135] This embodiment, building on the previous embodiment, details the steps for determining the second-highest digit and second-lowest digit based on the original text and key. By using the original text and key as the third-highest digit and third-lowest digit, converting the third-highest digit and third-lowest digit into binary digits and segmenting them, each binary digit segment can be obtained. By right-shifting each binary digit segment and converting it into decimal, the original text and key can be decrypted using a shift operation. This shift decryption method, the inverse of the shift encryption method, achieves stable digital encryption and decryption, further increasing the difficulty of reverse-calculating the encrypted digit, thereby enhancing digital security.
[0136] Figure 5 FIG1 shows a flow chart of a digital decryption method provided by Embodiment 5 of the present invention. Figure 5 The digital decryption method provided in the embodiment of the present invention includes the following steps:
[0137] S510: Determine the ciphertext and key from the number to be decrypted.
[0138] S520. Decrypt the ciphertext using the key to obtain the original ciphertext.
[0139] S530: Use the original text and the key as the third highest digit and the third lowest digit respectively.
[0140] Among them, the original text can be used as the third highest digit and the key as the third lowest digit; or the original text can be used as the third lowest digit and the key as the third highest digit.
[0141] S540: Convert the third highest digit and the third lowest digit into whole segments of binary digits respectively and split them into segments to obtain multiple segments of binary digits.
[0142] S550 , right-shifting each segment of binary digits according to its position in the entire segment of binary digits.
[0143] S560. Convert each segment of binary digits after right shift into a decimal digit, and obtain the second highest digit and the second lowest digit of the original text and the key after decryption by bit shift according to each segment of decimal digits.
[0144] Among them, in steps S540-S560, the right-shift decryption process of binary conversion, splitting, right shift, and decimal conversion of the third high-order digit and the third low-order digit is a reverse process of the left-shift encryption process of binary conversion, left shift, splicing, and decimal conversion of each segment of decimal digits in the second high-order digit and the second low-order digit disclosed in the above embodiment.
[0145] Among them, since each segment of the decimal array must meet the preset number of bits when converted into binary numbers during the left-shift encryption process, the entire segment of binary numbers after conversion can also be split according to the preset number of bits during the right-shift decryption process to obtain each segment of binary numbers.
[0146] Among them, since in the left-shift encryption process, each segment of binary digits can be left-shifted according to its position in the entire segment of binary digits to which it belongs, in the right-shift decryption process, each segment of binary digits can be right-shifted accordingly according to its position in the entire segment of binary digits to which it belongs.
[0147] After right shifting to obtain each segment of binary digits, decimal conversion can be performed to obtain each segment of decimal digits in the second highest digit and the second lowest digit.
[0148] S570 . Perform reverse permutation decryption on the digits in the second high-order digit and the second low-order digit based on the first digit table to obtain the first high-order digit and the first low-order digit.
[0149] S580: Concatenate the first high-order digit and the first low-order digit, and determine a decryption result of the number to be decrypted according to the concatenation result.
[0150] Based on the above-mentioned embodiments, the present invention further describes in detail the steps for determining the second-highest digit and the second-lowest digit based on the original text and the key. By using the original text and the key as the third-highest digit and the third-lowest digit, converting the third-highest digit and the third-lowest digit into binary digits and segmenting them, each segment of binary digits can be obtained. By right-shifting each segment of binary digits and converting them into decimal digits, the original text and the key can be decrypted using a shift operation. This shift decryption method, which is the inverse of the shift encryption method, achieves stable digital encryption and decryption, further increasing the difficulty of reverse-calculating the encrypted digit, thereby enhancing digital security.
[0151] Furthermore, the right-shift decryption process in this embodiment of the present invention is the reverse of the left-shift encryption process in the digital encryption method proposed in the above embodiment. The encryption and decryption processes possess corresponding technical features and fall under the same inventive concept. Technical details not fully described in this embodiment can be found in the above embodiment, and this embodiment has the same beneficial effects as the above embodiment.
[0152] Example 6
[0153] This embodiment, based on the above embodiment, describes in detail the steps for verifying the normality of the decryption process based on the seed character. After determining the second-highest digit and the second-lowest digit, an operation can be performed on the second-highest digit and the second-lowest digit, and the seed character can be obtained by indexing the seed table based on the operation result. By verifying the indexed seed character based on the seed character in the number to be decrypted, it is possible to determine whether the current decryption process is normal. If normal, the digits in the second-highest digit and the second-lowest digit can be further decrypted by reverse permutation. This further increases the difficulty of reversely calculating the encrypted number, thereby improving the security of the number.
[0154] Figure 6 FIG1 shows a flow chart of a digital decryption method provided by embodiment 6 of the present invention. Figure 6 The digital decryption method provided in the embodiment of the present invention includes the following steps:
[0155] S610: Segment the number to be decrypted according to the seed character in the number to be decrypted to obtain the ciphertext and the key.
[0156] The number to be decrypted can be composed of a ciphertext, a seed character, and a key, and the seed character can be used as a separator to separate the ciphertext and the key. When segmenting the number to be decrypted, the data to be decrypted can be segmented based on the seed character, and the segmented ciphertext and key can be extracted based on the order of the segmentation process.
[0157] S620. Decrypt the ciphertext using the key to obtain the original ciphertext, and determine the second highest digit and the second lowest digit based on the original text and the key.
[0158] S630: Perform an operation using the second highest digit and the second lowest digit to obtain a third index position of the seed table.
[0159] The process of determining the third index position using the second highest digit and the second lowest digit during the decryption process may be the same as the process of determining the third index position using the second highest digit and the second lowest digit during the encryption process.
[0160] S640: Index the seed table according to the third index position, and verify the seed character according to the index result.
[0161] Among them, verifying the seed character according to the index result may include: judging whether the character of the current index is the same as the seed character in the number to be decrypted; if they are the same, the verification passes, and if they are different, the verification fails.
[0162] S650. When the verification passes, perform reverse permutation decryption on the digits in the second high-order digit and the second low-order digit based on the first digital table to obtain the first high-order digit and the first low-order digit.
[0163] S660: Concatenate the first high-order digit and the first low-order digit, and determine a decryption result of the number to be decrypted according to the concatenation result.
[0164] During an abnormal decryption process, the ciphertext can be decrypted using a key based on a decryption process that does not correspond to the encryption process. In this case, if the decryption process does not correspond to the encryption process, the resulting original text is incorrect. Accordingly, since characters in the seed table are not repeated, the seed characters indexed based on the incorrect original text are largely different from the seed characters in the number to be decrypted. This allows the decryption process to be identified as abnormal, and further decryption is stopped, making it more difficult to reverse-calculate the encrypted number and improving the security of the number.
[0165] Based on the above embodiment, the present invention further describes in detail the steps for verifying whether the decryption process is normal based on the seed character. After determining the second highest digit and the second lowest digit, an operation can be performed on the second highest digit and the second lowest digit, and the seed character can be obtained by indexing the seed table based on the operation result. By verifying the indexed seed character based on the seed character in the number to be decrypted, it is possible to determine whether the current decryption process is normal. If normal, the digits in the second highest digit and the second lowest digit can be further decrypted by reverse permutation. This further increases the difficulty of reverse calculating the encrypted number, thereby improving the security of the number.
[0166] Furthermore, the seed character calculation process in this embodiment of the present invention is identical to the seed character calculation process in the digital encryption method proposed in the aforementioned embodiment. The encryption and decryption processes possess corresponding technical features and fall under the same inventive concept. Technical details not fully described in this embodiment can be found in the aforementioned embodiment, and this embodiment has the same beneficial effects as the aforementioned embodiment.
[0167] Furthermore, it is worth noting that, according to the encryption algorithms combined in each digital encryption method, the decryption algorithms in the digital table inverse permutation decryption, displacement decryption, key decryption and seed character decryption provided in each embodiment of the present invention can be correspondingly combined to form different digital decryption methods, and these digital decryption methods all fall within the scope of protection of the present invention.
[0168] Example 7
[0169] This embodiment combines encryption and decryption methods based on the above embodiments. The digital encryption process utilizes digital table obfuscation permutation encryption, bit shift encryption, key encryption, and seed encryption to encrypt the number to be encrypted. Correspondingly, the decryption process utilizes key decryption, seed verification, bit shift decryption, and digital table reverse permutation decryption, all of which are reversible from the encryption process. This achieves a stable encryption and decryption process and improves digital security.
[0170] Figure 7 FIG1 shows a flow chart of a digital encryption and decryption method provided by Embodiment 7 of the present invention. Figure 7 The digital encryption and decryption method provided in the embodiment of the present invention includes two stages: encryption and decryption:
[0171] The encryption phase may include:
[0172] S701. Pad the number to be encrypted, and symmetrically divide the padded number to obtain the first high-order digit and the first low-order digit.
[0173] Among them, step S701 is a digital processing step, which performs digit padding and symmetrical division of the number to be encrypted, and separates the first high-order digit and the first low-order digit.
[0174] S702 . For each digit in the first high-order digit and the first low-order digit, perform substitution encryption on each digit based on the first number table to obtain a second high-order digit and a second low-order digit.
[0175] Step S702 is the first encryption, i.e., performing obfuscation permutation encryption on the first high-order digit and the first low-order digit using the first digital permutation table to obtain the second high-order digit and the second low-order digit. The second high-order digit and the second low-order digit may include multiple decimal digits.
[0176] S703 : For the second highest digit and the second lowest digit, convert each segment of decimal digits into binary digits.
[0177] S704 , shifting each segment of binary digits to the left according to the position of each segment of binary digits in the entire segment of binary digits to which it belongs.
[0178] S705 , converting the binary number obtained by splicing the left-shifted binary digits into a decimal number to obtain the third highest digit and the third lowest digit after the second highest digit and the second lowest digit are encrypted by the bit shifting.
[0179] Among them, steps S703-705 are the second encryption, that is, the third high-order digit and the third low-order digit of the long integer are obtained by binary conversion, left shift, splicing, and decimal conversion of each decimal digit in the second high-order digit and the second low-order digit.
[0180] S706. Use the third highest digit and the third lowest digit as the original text and the key respectively, and use the key to encrypt the original text to obtain the ciphertext of the original text.
[0181] Among them, step S706 is the third encryption, that is, the third high-order digit and the third low-order digit are used as the original text and the key respectively, and the original text is encrypted using the key.
[0182] S707 . Perform an operation using the third high-order digit and the third low-order digit to obtain a third index position of the seed table; and index the seed table according to the third index position to obtain a seed character.
[0183] S708: Concatenate the ciphertext, the seed character, and the key to obtain an encryption result of the number to be encrypted.
[0184] Among them, S707-708 is the fourth encryption, that is, seed encryption can be achieved by indexing the seed character according to the third high-order digit and the third low-order digit, and using the seed character to splice the encryption result.
[0185] After the number is encrypted in the above encryption stage, the corresponding decryption stage may include:
[0186] S709: Segment the number to be decrypted according to the seed character in the number to be decrypted to obtain the ciphertext and the key.
[0187] Among them, step S709 starts decryption, which can find the seed character in the number to be decrypted and split it to obtain the key, seed character and ciphertext.
[0188] S710. Decrypt the ciphertext using the key to obtain the original ciphertext, and use the original text and the key as the third highest digit and the third lowest digit, respectively.
[0189] Among them, step S710 is the first decryption, that is, using the key to decrypt the ciphertext to obtain the third high-order digit and the third low-order digit.
[0190] S711. Perform an operation using the third high-order digit and the third low-order digit to obtain a third index position of the seed table; index the seed table according to the third index position, and verify the seed character according to the index result.
[0191] Among them, step S711 is the second decryption, that is, by indexing the seed character according to the third high-order digit and the third low-order digit, and verifying the seed character in the decrypted number according to the index result, seed decryption can be achieved and abnormal decryption operations can be filtered.
[0192] S712. When the verification passes, convert the third highest digit and the third lowest digit into whole segments of binary digits and split them into segments to obtain multiple segments of binary digits.
[0193] S713. Shift each segment of binary digits right according to its position in the entire segment of binary digits.
[0194] S714. Convert each right-shifted binary digit into a decimal digit, and obtain the second highest digit and the second lowest digit of the original text and the key after decryption by bit shifting according to each decimal digit.
[0195] Among them, steps S712-S714 are the third decryption, that is, the second highest digit and the second lowest digit are obtained by performing binary conversion, splitting, right shifting, and decimal conversion on the third highest digit and the third lowest digit.
[0196] S715 . Perform reverse permutation decryption on the digits in the second high-order digit and the second low-order digit based on the first digit table to obtain the first high-order digit and the first low-order digit.
[0197] Among them, step S715 is the fourth decryption, that is, the second high-order digit and the second low-order digit are decrypted by reverse substitution through the first digital substitution table to obtain the first high-order digit and the first low-order digit.
[0198] S716: Concatenate the first high-order digit and the first low-order digit, and determine a decryption result of the number to be decrypted based on the concatenation result.
[0199] Finally, the first high and low digits are concatenated to restore the original plaintext.
[0200] The embodiment of the present invention combines the encryption method and the decryption method based on the above embodiment. In the digital encryption process, digital table obfuscation permutation encryption, displacement encryption, key encryption, and seed encryption can be used to encrypt the number to be encrypted; correspondingly, the decryption process uses key decryption, seed verification, displacement decryption, and digital table inverse permutation decryption that are reversible with the encryption process to decrypt the number to be decrypted. A stable encryption and decryption process can be achieved, and the security of the number can be improved. In addition, the digital encryption and decryption method and the digital decryption method proposed in the embodiment of the present invention and the above embodiment belong to the same inventive concept. The technical details not fully described in this embodiment can be referred to the above embodiment, and this embodiment has the same beneficial effects as the above embodiment.
[0201] Example 8
[0202] Figure 8 FIG2 shows a schematic diagram of the structure of a digital encryption device provided by an eighth embodiment of the present invention. The embodiment of the present invention is applicable to the case of encrypting numbers.
[0203] like Figure 8 As shown, the digital encryption device provided by the embodiment of the present invention includes:
[0204] A segmentation module 810 is configured to pad the number to be encrypted and symmetrically split the padded number to obtain a first high-order digit and a first low-order digit;
[0205] A first encryption module 820 is configured to perform permutation encryption on each digit in the first high-order digit and the first low-order digit based on the first number table to obtain a second high-order digit and a second low-order digit;
[0206] The second encryption module 830 is used to determine the original text and the key according to the second high-order digit and the second low-order digit, and encrypt the original text using the key to obtain the ciphertext of the original text;
[0207] The result determination module 840 is used to obtain the encryption result of the number to be encrypted according to the ciphertext and the key.
[0208] In some optional implementations, the first encryption module may be specifically configured to:
[0209] Determine a first index position of a first number table according to the current number; index the first number table according to the first index position to obtain a place-filling digit of the current number; and use the place-filling digit to fill the current number to obtain a number after substitution and encryption of the current number.
[0210] In some optional implementations, the second encryption module may be specifically configured to:
[0211] Determine whether the original text and the key are included in the second digital table; if so, determine the second index position of the second digital table based on the original text and the key; index the second digital table based on the second index position to obtain the ciphertext corresponding to the original text.
[0212] In some optional embodiments, the second most significant digit and the second least significant digit comprise multiple segments of decimal digits;
[0213] Accordingly, the second encryption module is specifically configured to:
[0214] For the second highest digit and the second lowest digit, each segment of decimal digits is converted into a binary digit; each segment of binary digits is left-shifted according to its position in the entire segment of binary digits to which it belongs; the binary digits of the left-shifted segments of binary digits are concatenated into a decimal digit to obtain the third highest digit and the third lowest digit after the second highest digit and the second lowest digit are encrypted by shifting; the third highest digit and the third lowest digit are used as the original text and the key, respectively.
[0215] In some optional implementations, the second encryption module may also be used to:
[0216] After obtaining the second highest digit and the second lowest digit, performing an operation using the second highest digit and the second lowest digit to obtain a third index position of the seed table; indexing the seed table according to the third index position to obtain a seed character;
[0217] Accordingly, the result determination module can be specifically used to:
[0218] The ciphertext, seed character and key are concatenated to obtain the encryption result of the number to be encrypted.
[0219] In some optional implementations, the numbers to be encrypted include numbers in a URL.
[0220] The digital encryption device provided in the embodiment of the present invention belongs to the same inventive concept as the digital encryption method provided in the above embodiment. Technical details not fully described in the embodiment of the present invention can be referred to the above embodiment, and the embodiment of the present invention has the same beneficial effects as the above embodiment.
[0221] Embodiment 9
[0222] Figure 9 FIG2 shows a schematic diagram of the structure of a digital decryption device provided by Embodiment 9 of the present invention. The embodiment of the present invention is applicable to the case of decrypting digital data.
[0223] like Figure 9 As shown, the digital decryption device provided by the embodiment of the present invention includes:
[0224] A ciphertext key determination module 910 is used to determine the ciphertext and key from the number to be decrypted;
[0225] A first decryption module 920 is configured to decrypt the ciphertext using the key to obtain the original ciphertext and determine the second most significant digit and the second least significant digit based on the original ciphertext and the key;
[0226] A second decryption module 930 is configured to perform reverse permutation decryption on the digits in the second high-order digit and the second low-order digit based on the first digital table to obtain the first high-order digit and the first low-order digit;
[0227] The splicing module 940 is used to splice the first high-order digit and the first low-order digit, and determine the decryption result of the number to be decrypted according to the splicing result.
[0228] The first decryption module may be specifically configured to determine whether the ciphertext and the key are contained in the second digital table; if so, to search the second digital table for the original text corresponding to the ciphertext based on the ciphertext and the key.
[0229] Among them, the second decryption module can be specifically used to: group the second high-order digit and the second low-order digit respectively, each group of numbers includes the digits before replacement and the corresponding supplementary digits; determine the first index position of the first number table according to the digits before replacement; index the first number table according to the first index position, and verify the supplementary digits according to the index result; if the verification passes, reversely replace each group of numbers into the array before replacement to obtain the first high-order digit and the first low-order digit.
[0230] In some optional implementations, the first decryption module may be specifically configured to:
[0231] The original text and the key are respectively the third highest digit and the third lowest digit;
[0232] Convert the third highest digit and the third lowest digit into whole segments of binary digits respectively and split them to obtain multiple segments of binary digits;
[0233] Shift each segment of binary digits right according to their position in the entire segment of binary digits;
[0234] Convert each segment of binary digits after right shift into decimal digits, and obtain the second highest digit and the second lowest digit of the original text and the key after bit shift decryption based on each segment of decimal digits.
[0235] In some optional implementations, the ciphertext key determination module may be specifically configured to:
[0236] According to the seed character in the number to be decrypted, the number to be decrypted is split to obtain the ciphertext and key;
[0237] Accordingly, the first decryption module can also be used to:
[0238] After determining the second highest digit and the second lowest digit according to the original text and the key, performing an operation using the second highest digit and the second lowest digit to obtain a third index position of the seed table;
[0239] The seed table is indexed according to the third index position, and the seed character is verified according to the index result.
[0240] The digital decryption device provided in the embodiment of the present invention belongs to the same inventive concept as the digital decryption method provided in the above embodiment. Technical details not fully described in the embodiment of the present invention can be referred to the above embodiment, and the embodiment of the present invention has the same beneficial effects as the above embodiment.
[0241] Example 10
[0242] Figure 10 The following is a schematic diagram showing the hardware structure of a terminal device provided in Embodiment 10 of the present invention. The terminal device in this embodiment of the present invention may include, but is not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), and in-vehicle terminals (e.g., in-vehicle navigation terminals), as well as fixed terminals such as digital TVs and desktop computers. Figure 10 The terminal device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0243] like Figure 10 As shown, the terminal device 1000 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 1001, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1002 or a program loaded from a storage device 1008 into a random access memory (RAM) 1003. Various programs and data required for the operation of the terminal device 1000 are also stored in the RAM 1003. The processing device 1001, the ROM 1002, and the RAM 1003 are connected to each other via a bus 1004. An input / output (I / O) interface 1005 is also connected to the bus 1004.
[0244] Typically, the following devices may be connected to the I / O interface 1005: an input device 1006 including, for example, a touch screen, a touchpad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 1007 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 1008 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 may allow the terminal device 1000 to communicate with other devices wirelessly or by wire to exchange data. Figure 10 The terminal device 1000 is shown as having various devices, but it should be understood that it is not required to implement or possess all the devices shown, and more or fewer devices may be implemented or possessed instead.
[0245] In particular, according to an embodiment of the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present invention includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network via the communication device 1009, or installed from the storage device 1008, or installed from the ROM 1002. When the computer program is executed by the processing device 1001, it can execute the digital encryption method provided by the embodiment of the present invention, or execute the above-mentioned functions defined in the digital decryption method provided by the embodiment of the present invention.
[0246] The terminal provided by the embodiment of the present invention and the digital encryption method or digital decryption method provided by the above embodiment belong to the same inventive concept. Technical details not fully described in the embodiment of the present invention can be referred to the above embodiment, and the embodiment of the present invention has the same beneficial effects as the above embodiment.
[0247] Example 11
[0248] An embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon. When the program is executed by a processor, the digital encryption and decryption method or the digital decryption method provided in the above embodiment is implemented.
[0249] It should be noted that the computer-readable storage medium described above in the embodiments of the present invention may be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or component, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to, an electrical connection having one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM) or flash memory (FLASH), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the embodiments of the present invention, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, device, or component. In the embodiments of the present invention, the computer-readable signal medium may include a data signal transmitted in baseband or as part of a carrier wave, which carries computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium may be transmitted using any suitable medium, including but not limited to wires, optical cables, RF (radio frequency), etc., or any suitable combination thereof.
[0250] In some embodiments, the client and server can communicate using any currently known or future developed network protocol, such as HTTP (Hypertext Transfer Protocol), and can be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.
[0251] The computer-readable storage medium may be included in the terminal device, or may exist independently without being incorporated into the terminal device.
[0252] The terminal device stores and carries one or more programs. When the one or more programs are executed by the terminal device, the terminal device:
[0253] The number to be encrypted is padded, and the padded numbers are symmetrically divided to obtain the first high-order digit and the first low-order digit; for each digit in the first high-order digit and the first low-order digit, each digit is permuted and encrypted based on the first number table to obtain the second high-order digit and the second low-order digit; the original text and the key are determined according to the second high-order digit and the second low-order digit, and the original text is encrypted with the key to obtain the ciphertext of the original text; based on the ciphertext and the key, the encryption result of the number to be encrypted is obtained.
[0254] Alternatively, the terminal device stores and carries one or more programs, and when the one or more programs are executed by the terminal device, the terminal device:
[0255] Determine the ciphertext and key from the number to be decrypted; use the key to decrypt the ciphertext to obtain the original text of the ciphertext, and determine the second highest digit and the second lowest digit based on the original text and the key; perform reverse permutation decryption on the numbers in the second highest digit and the second lowest digit based on the first number table to obtain the first highest digit and the first lowest digit; splice the first highest digit and the first lowest digit, and determine the decryption result of the number to be decrypted based on the splicing result.
[0256] Computer program code for performing the operations of the present invention may be written in one or more programming languages, or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on the remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0257] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present invention. In this regard, each box in the flowchart or block diagram can represent a module, program segment, or a part of code, and the module, program segment, or a part of code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the function pages marked in the box can occur in a different order than that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of the boxes in the block diagram and / or flowchart, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or can be implemented using a combination of dedicated hardware and computer instructions.
[0258] The units involved in the embodiments of the present invention may be implemented in software or hardware, wherein the name of a unit does not necessarily limit the unit itself.
[0259] The functions described above herein may be performed, at least in part, by one or more hardware logic components. For example, and without limitation, exemplary hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chip (SOCs), complex programmable logic devices (CPLDs), and the like.
[0260] Note that the above are only preferred embodiments of the present invention and the technical principles employed. Those skilled in the art will appreciate that the present invention is not limited to the specific embodiments herein, and that various obvious changes, readjustments, and substitutions are possible for those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in detail through the above embodiments, the present invention is not limited to the above embodiments and may include many other equivalent embodiments without departing from the scope of the present invention. The scope of the present invention is determined by the scope of the appended claims.
Claims
1. A digital encryption method, characterized in that: include: The number to be encrypted is padded, and the padded number is symmetrically divided to obtain the first high-order digit and the first low-order digit; For each digit in the first high-order digit and the first low-order digit, performing permutation encryption on each digit based on the first number table to obtain a second high-order digit and a second low-order digit; Determining an original text and a key based on the second high-order digit and the second low-order digit, and encrypting the original text using the key to obtain a ciphertext of the original text; Obtaining an encryption result of the number to be encrypted according to the ciphertext and the key; The second high-order digit and the second low-order digit include multiple segments of decimal digits; The determining of the original text and the key according to the second high-order digit and the second low-order digit includes: For the second high-order digit and the second low-order digit, convert each segment of decimal digits into a binary digit; Left shifting the binary digits in each segment according to the position of the binary digits in the entire segment to which they belong; Converting the concatenated binary digit of each segment of the left-shifted binary digit into a decimal digit to obtain a third high-order digit and a third low-order digit after the second high-order digit and the second low-order digit are encrypted by the shift operation; The third high-order digit and the third low-order digit are used as the original text and the key respectively.
2. The method according to claim 1, characterized in that The performing permutation encryption on each of the numbers based on the first number table includes: determining a first index position of the first number table according to the current number; Indexing the first number table according to the first index position to obtain a placeholder for the current number; The current number is padded with the padded digit to obtain a number after the current number is replaced and encrypted.
3. The method according to claim 1, characterized in that The encrypting the original text by using the key includes: determining whether the original text and the key are included in the second digital table; If yes, determining a second index position of the second digital table according to the original text and the key; The second digital table is indexed according to the second index position to obtain a ciphertext corresponding to the original text.
4. The method according to claim 1, wherein After obtaining the second highest digit and the second lowest digit, the method further includes: Performing an operation using the second high-order digit and the second low-order digit to obtain a third index position of the seed table; Indexing the seed table according to the third index position to obtain a seed character; Accordingly, obtaining the encryption result of the number to be encrypted based on the ciphertext and the key includes: The ciphertext, the seed character and the key are concatenated to obtain an encryption result of the number to be encrypted.
5. The method according to any one of claims 1 to 4, characterized in that: The numbers to be encrypted include numbers in a website address.
6. A digital decryption method, characterized in that: include: Determining the ciphertext and key from the number to be decrypted; Decrypting the ciphertext using the key to obtain the original text of the ciphertext, and determining the second most significant digit and the second least significant digit based on the original text and the key; Perform reverse permutation decryption on the digits in the second high-order digit and the second low-order digit based on the first digital table to obtain the first high-order digit and the first low-order digit; Concatenate the first high-order digit and the first low-order digit, and determine a decryption result of the number to be decrypted according to the concatenation result; Determining the second highest digit and the second lowest digit according to the original text and the key includes: The original text and the key are respectively used as the third highest digit and the third lowest digit; Converting the third high-order digit and the third low-order digit into whole segments of binary digits and splitting them into segments to obtain multiple segments of binary digits; Right shifting the binary digits in each segment according to the position of the binary digits in the entire segment to which they belong; The binary numbers in each segment after right shift are converted into decimal numbers, and the second highest digit and the second lowest digit of the original text and the key after bit shift decryption are obtained according to the decimal numbers in each segment.
7. The method according to claim 6, characterized in that Determining the ciphertext and the key from the number to be decrypted includes: Splitting the number to be decrypted according to the seed character in the number to be decrypted to obtain a ciphertext and a key; Accordingly, after determining the second high-order digit and the second low-order digit according to the original text and the key, the method further includes: Performing an operation using the second high-order digit and the second low-order digit to obtain a third index position of the seed table; The seed table is indexed according to the third index position, and the seed character is verified according to the index result.
8. A digital encryption device, characterized in that: include: A segmentation module is used to pad the digits of the number to be encrypted and symmetrically split the padded number to obtain the first high-order digit and the first low-order digit; a first encryption module, configured to perform permutation encryption on each of the first high-order digits and the first low-order digits based on a first number table to obtain a second high-order digit and a second low-order digit; a second encryption module, configured to determine an original text and a key according to the second high-order digit and the second low-order digit, and encrypt the original text using the key to obtain a ciphertext of the original text; A result determination module, configured to obtain an encryption result of the number to be encrypted based on the ciphertext and the key; The second high-order digit and the second low-order digit include multiple segments of decimal digits; Accordingly, the second encryption module is specifically configured to: For the second high-order digit and the second low-order digit, convert each segment of decimal digits into a binary digit; Left shifting the binary digits in each segment according to the position of the binary digits in the entire segment to which they belong; Converting the concatenated binary digit of each segment of the left-shifted binary digit into a decimal digit to obtain a third high-order digit and a third low-order digit after the second high-order digit and the second low-order digit are encrypted by the shift operation; The third high-order digit and the third low-order digit are used as the original text and the key respectively.
9. A digital decryption device, characterized in that: include: A ciphertext key determination module, used to determine the ciphertext and key from the number to be decrypted; a first decryption module, configured to decrypt the ciphertext using the key to obtain the original text of the ciphertext, and determine the second high-order digit and the second low-order digit based on the original text and the key; a second decryption module, configured to perform reverse permutation decryption on the digits in the second high-order digit and the second low-order digit based on the first digital table to obtain a first high-order digit and a first low-order digit; a splicing module, configured to splice the first high-order digit and the first low-order digit, and determine a decryption result of the number to be decrypted according to the splicing result; The first decryption module is specifically configured to: The original text and the key are respectively used as the third highest digit and the third lowest digit; Converting the third high-order digit and the third low-order digit into whole segments of binary digits and splitting them into segments to obtain multiple segments of binary digits; Right shifting the binary digits in each segment according to the position of the binary digits in the entire segment to which they belong; The binary numbers in each segment after right shift are converted into decimal numbers, and the second highest digit and the second lowest digit of the original text and the key after bit shift decryption are obtained according to the decimal numbers in each segment.
10. A terminal device, characterized in that: The terminal includes: one or more processors; a memory for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the digital encryption method as described in any one of claims 1-5, or the digital decryption method as described in any one of claims 6-7.
11. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the digital encryption method according to any one of claims 1 to 5 or the digital decryption method according to any one of claims 6 to 7 is implemented.
Citation Information
Patent Citations
Password encryption method and device and ciphertext decryption method and device
CN110941817A