CN113946847A - Digital encryption and decryption method and device, terminal equipment and storage medium - Google Patents

Digital encryption and decryption method and device, terminal equipment and storage medium Download PDF

Info

Publication number
CN113946847A
CN113946847A CN202111210290.9A CN202111210290A CN113946847A CN 113946847 A CN113946847 A CN 113946847A CN 202111210290 A CN202111210290 A CN 202111210290A CN 113946847 A CN113946847 A CN 113946847A
Authority
CN
China
Prior art keywords
digit
order
digits
low
encryption
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111210290.9A
Other languages
Chinese (zh)
Inventor
王霄飞
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Jingdong Century Trading Co Ltd
Beijing Wodong Tianjun Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Wodong Tianjun Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Jingdong Century Trading Co Ltd, Beijing Wodong Tianjun Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN202111210290.9A priority Critical patent/CN113946847A/en
Publication of CN113946847A publication Critical patent/CN113946847A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/602Providing cryptographic facilities or services

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Health & Medical Sciences (AREA)
  • Bioethics (AREA)
  • General Health & Medical Sciences (AREA)
  • Computer Hardware Design (AREA)
  • Computer Security & Cryptography (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Storage Device Security (AREA)

Abstract

The embodiment of the invention discloses a digital encryption and decryption method, a device, terminal equipment and a storage medium, wherein the encryption method comprises the following steps: supplementing digits of the digits to be encrypted, and symmetrically dividing the supplemented digits to obtain a first high digit and a first low digit; for each digit in the first high-order digits and the first low-order digits, performing replacement encryption on each digit based on a first digit table to obtain second high-order digits and second low-order digits; determining an original text and a secret key according to the second high-order digit and the second low-order digit, and encrypting the original text by using the secret key to obtain a ciphertext of the original text; and obtaining an encryption result of the number to be encrypted according to the ciphertext and the secret key. On the basis of key encryption, a digital table replacement reversible algorithm is superposed, so that the encryption strength can be enhanced, and the digital security is improved.

Description

Digital encryption and decryption method and device, terminal equipment and storage medium
Technical Field
The embodiment of the invention relates to the technical field of computers, in particular to a digital encryption and decryption method, a digital encryption and decryption device, terminal equipment and a storage medium.
Background
In the prior art, a Virginia cryptographic algorithm may be used to encrypt the numbers.
In the process of implementing the invention, the inventor finds that at least the following technical problems exist in the prior art: the key of the virginia cipher is repeated cyclically, and the length of the key can be obtained by using a cassie-based test and a friedman test. After the length of the key is obtained, the ciphertext can be regarded as an interlaced Kaiser password, and can be easily cracked, so that the security is poor.
Disclosure of Invention
The embodiment of the invention provides a digital encryption and decryption method, a digital encryption and decryption device, terminal equipment and a storage medium, which can improve the security of digital encryption.
In a first aspect, an embodiment of the present invention provides a digital encryption method, including:
supplementing digits of the digits to be encrypted, and symmetrically dividing the supplemented digits to obtain a first high digit and a first low digit;
for each digit in the first high-order digits and the first low-order digits, performing replacement encryption on each digit based on a first digit table to obtain second high-order digits and second low-order digits;
determining an original text and a secret key according to the second high-order digit and the second low-order digit, and encrypting the original text by using the secret key to obtain a ciphertext of the original text;
and obtaining an encryption result of the number to be encrypted according to the ciphertext and the secret key.
In a second aspect, an embodiment of the present invention provides a digital decryption method, including:
determining a cipher text and a key from the number to be decrypted;
decrypting the ciphertext by using the key to obtain an original text of the ciphertext, and determining a second high-order digit and a second low-order digit according to the original text and the key;
performing inverse transformation decryption on the second high-order digit and the second low-order digit based on a first digit table to obtain a first high-order digit and a first low-order digit;
and splicing the first high-order digit and the first low-order digit, and determining a decryption result of the digit to be decrypted according to a splicing result.
In a third aspect, an embodiment of the present invention provides a digital encryption apparatus, including:
the segmentation module is used for conducting digit complement on the digits to be encrypted and symmetrically segmenting the complemented digits to obtain a first high digit and a first low digit;
the first encryption module is used for carrying out replacement encryption on each digit in the first high-order digit and the first low-order digit based on a first digit table to obtain a second high-order digit and a second low-order digit;
the second encryption module is used for determining an original text and a secret key according to the second high-order digit and the second low-order digit, and encrypting the original text by using the secret key to obtain a ciphertext of the original text;
and the result determining module is used for obtaining the encryption result of the number to be encrypted according to the ciphertext and the secret key.
In a fourth aspect, an embodiment of the present invention provides a digital decryption apparatus, including:
the ciphertext key determining module is used for determining a ciphertext and a key from the number to be decrypted;
the first decryption module is used for decrypting the ciphertext by using the key to obtain an original text of the ciphertext and determining a second high-order digit and a second low-order digit according to the original text and the key;
the second decryption module is used for carrying out inverse transformation decryption on the digits in the second high-order digits and the second low-order digits based on the first digit table to obtain first high-order digits and first low-order digits;
and the splicing module is used for splicing the first high-order digit and the first low-order digit and determining a decryption result of the to-be-decrypted digit according to a splicing result.
In a fifth aspect, an embodiment of the present invention provides a terminal device, including:
one or more processors;
a memory for storing one or more programs;
when executed by the one or more processors, cause the one or more processors to implement a digital encryption method as in any embodiment of the invention, or implement a digital decryption method as in any embodiment of the invention.
In a sixth aspect, an embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored, which when executed by a processor implements the digital encryption method according to any embodiment of the present invention, or implements the digital decryption method according to any embodiment of the present invention.
The embodiment of the invention provides a digital encryption and decryption method, a device, terminal equipment and a storage medium, wherein the digital encryption method comprises the following steps: supplementing digits of the digits to be encrypted, and symmetrically dividing the supplemented digits to obtain a first high digit and a first low digit; aiming at each digit in the first high-order digits and the first low-order digits, carrying out replacement encryption on each digit based on a first digit table to obtain second high-order digits and second low-order digits; determining an original text and a secret key according to the second high-order digit and the second low-order digit, and encrypting the original text by using the secret key to obtain a ciphertext of the original text; and obtaining an encryption result of the number to be encrypted according to the ciphertext and the key. On the basis of key encryption, a digital table replacement reversible algorithm is superposed, so that the encryption strength can be enhanced, and the digital security is improved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, a brief description will be given below of the drawings required for the embodiments or the technical solutions in the prior art, and it is obvious that the drawings in the following description are some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to these drawings without creative efforts.
Fig. 1 is a flow chart illustrating a digital encryption method according to an embodiment of the present invention;
fig. 2 is a flowchart illustrating a digital encryption method according to a second embodiment of the present invention;
fig. 3 is a flowchart illustrating a digital encryption method according to a third embodiment of the present invention;
fig. 4 is a flowchart illustrating a digital decryption method according to a fourth embodiment of the present invention;
fig. 5 is a flowchart illustrating a digital decryption method according to a fifth embodiment of the present invention;
fig. 6 is a flowchart illustrating a digital decryption method according to a sixth embodiment of the present invention;
fig. 7 is a schematic flow chart illustrating a digital encryption and decryption method according to a seventh embodiment of the present invention;
fig. 8 is a schematic structural diagram illustrating a digital encryption apparatus according to an eighth embodiment of the present invention;
fig. 9 is a schematic structural diagram of a digital decryption apparatus according to a ninth embodiment of the present invention;
fig. 10 shows a schematic hardware structure diagram of a terminal device according to a tenth embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention clearer, the technical solutions of the present invention will be clearly and completely described through embodiments with reference to the accompanying drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention. In the following embodiments, optional features and examples are provided in each embodiment, and various features described in the embodiments may be combined to form a plurality of alternatives, and each numbered embodiment should not be regarded as only one technical solution.
Example one
Fig. 1 shows a flowchart of a digital encryption method according to an embodiment of the present invention. The digital encryption and decryption method provided by the embodiment of the invention is suitable for the situation of encrypting the digital. The method can be executed by a digital encryption device, which is implemented by software and/or hardware, and is preferably configured in a terminal device, such as a computer.
As shown in fig. 1, the digital encryption method provided in the embodiment of the present invention includes the following steps:
and S110, conducting digit complement on the digits to be encrypted, and symmetrically dividing the complemented digits to obtain a first high-order digit and a first low-order digit.
In the embodiment of the invention, the number to be encrypted can be any number needing to ensure the security in the processes of transmission, display, storage and the like, and can comprise a plurality of digits. For example, in some implementations, the number to be encrypted may include a number in a web site. By encrypting some key numbers in the website, the method can prevent external crawlers from traversing and grabbing the webpage information in the website in a simple mode of exhaustively exhausting the webpage website, thereby protecting the safety of the webpage information of the website to a certain extent.
When the digital encryption method is designed in advance, the bit number condition required to be met by the digital to be encrypted can be set based on the consideration that the encryption algorithm involved in the encryption method can be decrypted stably. Correspondingly, in the process of encrypting the to-be-encrypted digital data according to the encryption method, if the to-be-encrypted digital data does not reach the preset digit condition, the to-be-encrypted digital data can be subjected to left-side zero padding according to the preset digit condition, so that the to-be-encrypted digital data can be subjected to digit padding.
The preset digit condition may be an even digit. Correspondingly, after the filled numbers are symmetrically divided, two groups of numbers with the same digits can be obtained. The two groups of numbers can be divided into a low-order number and a high-order number according to a low-order to high-order of 'one, ten, one hundred and one thousand', and the division of the low-order number and the high-order number is opposite. For example, if two groups of numbers respectively include two digits, the digits of the "one and ten" are low digits, and the digits of the "hundred and thousand" are high digits; if the two groups of divided numbers respectively contain three digits, the digits of 'one, ten and hundred' are low-order digits, and the digits of 'thousand, ten and hundred thousand' are high-order digits.
After the high-order digits and the low-order digits are obtained through division, each group of digits can be combined according to the order from high to low to obtain a first high-order digit and a first low-order digit. For example, if two groups of numbers respectively include two bits, "the number of" ten "bits is" 1, 2 ", and the number of" hundred "and" thousand "bits is" 3, 4 ", respectively, the first low-order number is" 21 "by combining the low-order numbers in the high-order and the first high-order number is" 43 "by combining the high-order numbers in the high-order and the low-order.
And S120, aiming at each digit in the first high-order digits and the first low-order digits, carrying out replacement encryption on each digit based on the first digit table to obtain second high-order digits and second low-order digits.
In this embodiment, each of the first upper digit and the second upper digit may be subjected to permutation encryption based on the first digit table. The replacing encryption of each digit based on the first digit table may be regarded as searching for a digit corresponding to each digit from the first replacing table, and replacing each digit according to the corresponding digit to obtain a replaced digit. After the replaced digit of each digit is obtained, the replaced digits can be combined according to the position of the first high digit or the first low digit where each digit before replacement is located, so that a second high digit and a second low digit are obtained.
The process of the permutation encryption is a reversible process, and the number before the permutation can be determined according to the number after the permutation based on the same first number table. Thereby facilitating stable decryption after digital encryption.
S130, determining the original text and the key according to the second high-order digit and the second low-order digit, and encrypting the original text by using the key to obtain the ciphertext of the original text.
In this embodiment, the second high-order digit may be used as an original text, and the second low-order digit may be used as a secret key; the second low-order digit may be used as the original text and the second high-order digit may be used as the key. The original text may be encrypted by a key based on a reversible encryption algorithm that encrypts the number into a number. The reversible encryption algorithm for encrypting the number into the number may be, for example, an algorithm based on an exclusive or, a kaiser encryption, or a virginia encryption, which is not exhaustive here.
And S140, obtaining an encryption result of the number to be encrypted according to the ciphertext and the secret key.
In this embodiment, the ciphertext and the key may be spliced to obtain an encryption result of the number to be encrypted. Through the replacement confusion encryption by utilizing the first digital table, the combination with the key encryption can realize the stable encryption and decryption process, enhance the encryption strength and improve the digital security.
In some optional embodiments, performing permutation encryption on each number based on the first number table includes: determining a first index position of a first number table according to the current number; indexing the first number table according to the first index position to obtain a complementary digit of the current digit; and utilizing the complementary digit to complement the current digit to obtain the digit of the current digit after replacement encryption.
The first numerical table may be a two-dimensional numerical table. Accordingly, the first index position of the first numeric table may be a two-dimensional coordinate, where the first and second coordinate values may represent the row and column sequence numbers of the table. Since the first index position is determined according to the current number, which may be 0 to 9, the row sequence number may be 0 to 9 and the column sequence number may be 0 to 9 in the two-dimensional coordinates of the first index position, i.e., the first number table may be a 10 × 10 number table.
Wherein, the operation can be carried out according to the current number to determine the first index position. For example, the current number may be directly used as the first dimension coordinate value in the first index position, and the current number minus 1 may be used as the second dimension coordinate value in the first index position; for another example, the current number minus 1 may be used as the first dimension coordinate value in the first index position, and the current number may be directly used as the second dimension coordinate value in the first index position, which is not exhaustive here.
After the first index position is determined, the first number table can be searched according to the first index position to obtain the complementary digit corresponding to the current digit. And the digit with the complement can be complemented on the left side or the right side of the current digit, and the current digit is replaced according to the digit after the complement, so that the digit after the current digit is replaced and encrypted is obtained.
Illustratively, table 1 shows an example table of a first digital table in a digital encryption method provided by an embodiment of the present invention. Referring to Table 1, the first table of numbers is a 10 x 10 table of numbers, and the row index number and the column index number in the first index position may be 0-9.
TABLE 1
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
Assuming that the first high-order digit is 68, encrypting the first high-order digit based on the first digit table of table 1 to obtain a second high-order digit may include:
for the number 6, 6 may be directly used as the first dimension coordinate value in the first index position, and 6 minus 1 may be used as the second dimension coordinate value in the first index position, i.e., the first index position is [6,5 ]. Table 1 can be looked up using [6,5] to get a 8 complementary digit. The complement digit 8 can be complemented on the right side of 6 to obtain 6, namely a digit 68 after replacement encryption;
for the number 8, 8 may be directly used as the first dimension coordinate value in the first index position, and 8 minus 1 may be used as the second dimension coordinate value in the first index position, i.e., the first index position is [8,7 ]. Table 1 can be looked up using [8,7] to get a complement number of 4. The number of complement 4 can be complemented to the right of 8, resulting in 8 being the number 84 after replacement encryption;
the permuted numbers 68, 84 are combined according to the position in the first high-order number of 6, 8, resulting in the second high-order number 6884.
In these alternative embodiments, by replacing encryption with the first digit table, the first upper digit and the first lower digit can be obfuscated and stable and reversible decryption can be achieved.
In some optional embodiments, encrypting the plaintext using the key comprises: judging whether the original text and the secret key are contained in the second digital table; if yes, determining a second index position of the second numerical table according to the original text and the secret key; and indexing the second numerical table according to the second index position to obtain a ciphertext corresponding to the original text.
Wherein, the original text can be encrypted according to the secret key by utilizing a Virginia encryption algorithm. And the encryption process may include: acquiring a second numerical table corresponding to the Virginia algorithm, wherein the row index, the row index and the table content of the second numerical table can be numbers; judging whether the original text and the secret key are respectively contained in the row index and the column index or whether the original text and the secret key are respectively contained in the column index and the row index; if so, the original text can be used as the row index number in the second index position, the key can be used 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 can be used as the row index number in the second index position; and searching a ciphertext corresponding to the original text according to the second index position.
If the original text and the secret key are judged not to be contained in the second digital table, a relevant prompt of encryption failure can be performed so as to prompt the correction of the data to be encrypted.
In these alternative embodiments, the virginia encryption algorithm may be implemented by java, and stable encryption and decryption of the numbers in the original text and the ciphertext can be implemented by using the symmetric key and the corresponding second number table in the virginia algorithm.
According to the digital encryption method provided by the embodiment of the invention, digits of the digits to be encrypted are complemented, and the complemented digits are symmetrically divided to obtain a first high-order digit and a first low-order digit; aiming at each digit in the first high-order digits and the first low-order digits, carrying out replacement encryption on each digit based on a first digit table to obtain second high-order digits and second low-order digits; determining an original text and a secret key according to the second high-order digit and the second low-order digit, and encrypting the original text by using the secret key to obtain a ciphertext of the original text; and obtaining an encryption result of the number to be encrypted according to the ciphertext and the key. On the basis of key encryption, a digital table replacement reversible algorithm is superposed, so that the encryption strength can be enhanced, and the digital security is improved.
Example two
The present embodiment 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, based on the above-described embodiments. The second high digit and the second low digit are converted into binary in a segmented mode, and the binary is converted into a decimal long integer after left shift, so that displacement encryption of the second high digit and the second low digit can be realized. The displacement encryption method is a stable reversible algorithm, and can further improve the difficulty of back calculation of the encrypted numbers, thereby improving the safety of the numbers.
Fig. 2 shows a flowchart of a digital encryption method according to a second embodiment of the present invention. Referring to fig. 2, the digital encryption method provided in the embodiment of the present invention includes the following steps:
s210, conducting digit complement on the digits to be encrypted, and symmetrically dividing the complemented digits to obtain a first high-order digit and a first low-order digit.
S220, aiming at each digit in the first high-order digits and the first low-order digits, carrying out replacement encryption on each digit based on the first digit table to obtain second high-order digits and second low-order digits.
Wherein the second high digit and the second low digit comprise a plurality of decimal digits. For example, in one implementation, in permuting the encryption of each digit based on the first digit table, the permuted encrypted digits corresponding to each digit may be combined with a separator to obtain a second upper digit and a second lower digit comprising a plurality of decimal digits. Illustratively, assuming that the first high-order digit is 68, and the permuted encrypted digits of 6 and 8 are 68 and 84, respectively, 68 and 84 may be combined using a separator ". quadrature." to yield 68.84 as the second high-order digit, where the second high-order digit comprises two decimal digits. Here, the separator is not limited to "-", and may be a space or "/", for example.
And S230, aiming at the second high-order digit and the second low-order digit, converting each decimal digit into a binary digit.
Wherein, for the second high digit and the second low digit, each decimal digit can be determined based on the separator. Moreover, each decimal digit can be converted into a binary digit with a preset digit number, so that a plurality of sections of binary digits are obtained. If the number after binary conversion does not meet the preset digit, 0 can be compensated on the left side to be compensated to the preset digit.
S240, according to the position of each section of binary digit in the whole section of binary digit, each section of binary digit is shifted to the left.
For the second high-order digit and the second low-order digit, the position of each decimal digit in the whole decimal digit before binary conversion can be used as the position of each binary digit in the whole binary digit after binary conversion.
For example, assuming that the second highest digit is 68.84, the binary-converted digit needs to satisfy 8 digits, 68 is 01000100 after conversion, and 84 is 01010100 after conversion. Since the first group of positions before binary conversion 68 is at the left side of the whole decimal number "68.84" and the second group of positions before binary conversion 84 is at the left side of the whole decimal number "68.84", the binary conversion "01000100" will be at the first group of positions at the left side of the whole binary number, and "01010100" will be at the second group of positions at the left side of the whole binary number, so as to obtain the whole binary number "01000100.01010100".
Wherein, according to the position of each binary digit in the whole binary digit, each binary digit is left shifted, which can be: the binary digits of each segment from left to right are respectively shifted to the left by different bits, and the more the right side is, the larger the left shift number is. For example, assuming that the binary translation includes 4 binary digits, the left-to-right digits may be counted, the first binary digit is not left-shifted, the second binary digit is left-shifted by 8 bits, the third binary digit is left-shifted by 16 bits, and the fourth binary digit is left-shifted by 24 bits.
And S250, converting the binary digits spliced by the left-shifted binary digits into decimal digits to obtain a third high digit and a third low digit after displacement encryption of the second high digit and the second low digit.
The left-shifted binary digits can be spliced into new binary digits. For example, assuming that the binary digits of the left-shifted positions from left to right are "01000100" and "01010100", respectively, the two binary digits can be spliced into a new binary digit of "0100010001010100", and the spliced binary digit can be converted into a decimal digit of "17492". Wherein, the decimal number can be a long integer number.
And performing binary conversion, left shift, splicing and decimal conversion on each section of decimal digits in the second high digits and the second low digits to obtain third high digits and third low digits after displacement encryption on the second high digits and the second low digits. The displacement encryption method is a stable reversible algorithm.
And S260, respectively taking the third high-order digit and the third low-order digit as an original text and a secret key, and encrypting the original text by using the secret key to obtain a ciphertext of the original text.
The third high-order digit can be used as an original text, and the third low-order digit can be used as a key; the third lower digit may be used as the original text and the third upper digit may be used as the key.
And S270, obtaining an encryption result of the number to be encrypted according to the ciphertext and the secret key.
The displacement encryption is further superposed on the basis of the key encryption and the digital table replacement encryption, so that the difficulty of back calculation of the encrypted digital can be further improved, and the safety of the digital is improved.
In some alternative implementations, the second high-order digit and the second low-order digit may conform to a website format, i.e., contain four decimal digits. Moreover, in order to ensure that four decimal digits are in the range of 0-255, after each digit is subjected to permutation encryption based on the first digit table, 1 can be added to the left side of the encryption result, and the multiple decimal digits in the range of 0-255 are obtained. The second high digit and the second low digit conforming to the website format can be subjected to binary conversion, left shift, splicing and decimal conversion of 4 decimal digits to obtain a third high digit and a third low digit.
For example, the second highest digit may be "168.184.184.195", assuming that the predetermined number of digits of the binary translation is 8, and the binary translation is counted from left to right, the first segment of binary digits is not left shifted, the second segment of binary digits is left shifted by 8 bits, the third segment of binary digits is left shifted by 16 bits, and the fourth segment of binary digits is left shifted by 24 bits. Then, after the second high-digit number "168.184.184.195" is subjected to binary conversion, left shift, splicing, and decimal conversion of each piece of decimal digit, a third high-digit number "2830678211" can be obtained.
In these optional implementations, if the number to be encrypted is a number in a web address format, the process of bit alignment, symmetric division, and replacement encryption based on the first number table may not be performed, but may be directly used as the second high-order number and the second low-order number to perform the process of displacement encryption and key encryption. Thereby greatly improving the flexibility of digital encryption.
Embodiments of the present invention have described in detail the steps of determining the original text and the key from the second high-order digit and the second low-order digit based on the above-described embodiments. The second high digit and the second low digit are converted into binary in a segmented mode, and the binary is converted into a decimal long integer after left shift, so that displacement encryption of the second high digit and the second low digit can be realized. The displacement encryption method is a stable reversible algorithm, and can further improve the difficulty of back calculation of the numbers, thereby improving the safety of the numbers. In addition, the embodiment of the present invention and the digital encryption method proposed by the above embodiment belong to the same inventive concept, and the technical details that are not described in detail in the embodiment can be referred to the above embodiment, and the embodiment has the same beneficial effects as the above embodiment.
EXAMPLE III
The present embodiment describes in detail the step of determining the seed character based on the second high-order digit and the second low-order digit on the basis of the above-described embodiments. And the seed character is obtained by indexing the seed table according to the operation result by operating the second high-order digit and the second low-order digit, so that seed encryption is realized. Therefore, whether the decryption process is normal or not can be verified according to the seed characters in the decryption process, the difficulty of back calculation of the encrypted numbers is further improved, and the safety of the numbers is improved.
Fig. 3 shows a flowchart of a digital encryption method according to a third embodiment of the present invention. Referring to fig. 3, the digital encryption method provided in the embodiment of the present invention includes the following steps:
s310, conducting digit complement on the digits to be encrypted, and symmetrically dividing the complemented digits to obtain a first high digit and a first low digit.
And S320, aiming at each digit in the first high-order digits and the first low-order digits, carrying out replacement encryption on each digit based on the first digit table to obtain second high-order digits and second low-order digits.
And S331, operating by using the second high-order digit and the second low-order digit to obtain a third index position of the seed table.
Wherein, the seed table can be a one-dimensional table. And the elements of the seed table may contain non-repeating, non-numeric characters such as letters, symbols, etc. for verification and distinction from encrypted and decrypted numbers. Accordingly, the third index position of the seed table may be a one-dimensional index number.
Wherein the determining of the third index position may include: firstly, after converting the second high-order digit and the second low-order digit into binary digits, carrying out arithmetic operation (such as addition operation) or logic operation (such as exclusive-or operation) and the like; then, converting the operation result into decimal digits; finally, the decimal number obtained by conversion is divided by the length of the seed table, and the remainder can be used as a third index position.
And S341, indexing the seed table according to the third indexing position to obtain a seed character.
And searching the seed table according to the third index position to obtain the seed character.
S332, determining the original text and the key according to the second high-order digit and the second low-order digit, and encrypting the original text by using the key to obtain the ciphertext of the original text.
The steps S331 to S341 and the step S332 have no strict timing relationship, and the steps S331 to S341 may be executed first, the step S332 may be executed first, or the steps may be executed simultaneously.
And S350, splicing the ciphertext, the seed character and the secret key to obtain an encryption result of the number to be encrypted.
When the ciphertext, the seed character and the key are spliced, the seed character can be used as a separator to separate the ciphertext from the key. The cipher text, the seed character and the last cipher text can be spliced in sequence, and the cipher text, the seed character and the last cipher text can be spliced in sequence. The concatenation result may be used as an encryption result of the number to be encrypted.
The seed character is obtained by indexing the seed table according to the result of the operation of the second high-order digit and the second low-order digit, so that the encrypted result can carry the confusion seed character. Therefore, whether the current decryption operation is a normal decryption operation or not is verified according to the seed characters in the anti-decryption process, and abnormal forced cracking operation is avoided. By superposing seed character encryption on the basis of digital table replacement encryption and key encryption, the difficulty of back calculation of encrypted numbers can be improved, and the safety of the numbers is improved.
Embodiments of the present invention have been described in detail on the basis of the above embodiments, regarding the step of determining the seed character according to the second high-order digit and the second low-order digit. And the seed character is obtained by indexing the seed table according to the operation result by operating the second high-order digit and the second low-order digit, so that seed encryption is realized. Therefore, whether the decryption process is normal or not can be verified according to the seed characters in the decryption process, the difficulty of back calculation of the encrypted numbers is further improved, and the safety of the numbers is improved.
The embodiment of the present invention and the digital encryption method proposed by the above embodiment belong to the same inventive concept, and the technical details that are not described in detail in the embodiment can be referred to the above embodiment, and the embodiment and the above embodiment have the same beneficial effects. Moreover, it should be noted that the encryption algorithms in the digital table replacement encryption, the displacement encryption, the key encryption and the seed character encryption provided in the embodiments of the present invention may be combined according to different application scenarios, and various combined digital encryption methods all belong to the protection scope of the present invention.
Example four
Fig. 4 shows a flowchart of a digital decryption method according to a fourth embodiment of the present invention. The digital decryption method provided by the embodiment of the invention is suitable for the situation of decrypting the digital. The method can be executed by a digital decryption apparatus, which is implemented by software and/or hardware, and is preferably configured in a terminal device, such as a computer.
As shown in fig. 4, the digital decryption method provided in the embodiment of the present invention includes the following steps:
s410, determining a ciphertext and a key from the number to be decrypted.
In this embodiment, the number to be decrypted may be formed by concatenating the ciphertext and the key. The ciphertext and the key can be extracted according to the positions of the preset ciphertext and the key in the number to be decrypted.
S420, the cipher text is decrypted by using the key, the original text of the cipher text is obtained, and the second high-order digit and the second low-order digit are determined according to the original text and the key.
Wherein the key may be a symmetric key. It can be considered that, if the original text is encrypted by using the key to obtain the ciphertext, the original text can be obtained by decrypting the ciphertext by using the same key, that is, the processes of key encryption and key decryption are symmetrical reverse processes. The ciphertext can be decrypted based on the key by using a reverse decryption algorithm to the encryption algorithm in the key encryption process.
In some embodiments, decrypting the ciphertext using the key to obtain an original text of the ciphertext may include: judging whether the ciphertext and the key are contained in the second numerical table; if yes, the original text corresponding to the ciphertext is searched from the second digital table reversely according to the ciphertext and the secret key.
In these embodiments, the second number table may be a number table corresponding to the Virginia encryption algorithm, and the row index, the column index and the contents of the table of the second number table may all be numbers. Judging whether the ciphertext and the key are respectively contained in the content of the digital table and the row/column index number; if so, the original text corresponding to the cipher text, namely the column/row index number, can be reversely searched according to the cipher text content of the digital table and the row/column index number corresponding to the key. If the ciphertext and the key are judged not to be contained in the second digital table, the related prompt of decryption failure can be performed, and the decryption process is stopped, so that the data security is improved.
S430, performing inverse transformation and decryption on the numbers in the second high-order digits and the second low-order digits based on the first digit table to obtain the first high-order digits and the first low-order digits.
The process of performing reverse substitution decryption on the numbers in the second high-order number and the second low-order number based on the first number table and the process of performing substitution encryption on the numbers based on the same first number table are reverse processes.
Wherein each of the second upper digit and the second lower digit may be a permuted digit. For each permuted digit, the process of determining the number before the permutation may include: firstly, searching a number which is the same as the replaced number in a first number table; then respectively determining the row index number and the column index number corresponding to the same number; because the row and column index numbers can be determined based on the numbers before replacement, the correct numbers before replacement can be solved according to the row and column index numbers of the same numbers.
After the first high-order digit and the second low-order digit are solved, the digits before the substitution may be combined according to the position of the second high-order digit or the second low-order digit in which each digit after the substitution is located, so as to obtain the first high-order digit and the first low-order digit.
In some implementations, inversely transposing the digits of the second upper digit and the second lower digit to decrypt based on the first digit table may include:
grouping the second high-order digits and the second low-order digits respectively, wherein each group of digits comprises pre-replacement digits and corresponding complementary digits; determining a first index position of a first number table according to the number before replacement; indexing the first number table according to the first index position, and verifying the complementary digit according to the index result; and if the check is passed, inversely replacing each group of digits into a pre-replacement digit group to obtain a first high digit and a first low digit. In these embodiments, the step of determining the first index position according to the number before replacement may refer to the above embodiments, which are not described herein again. When the complementary digit is verified according to the index result, if the index result is consistent with the complementary digit, the verification can be considered to be passed; if the index result is not consistent with the complement number, the check may be considered to be failed. And if the verification fails, the related prompt of decryption failure can be carried out, and the decryption process is stopped, so that the data security is improved.
S440, splicing the first high-order digit and the first low-order digit, and determining a decryption result of the digit to be decrypted according to the splicing result.
The process of splicing the first high-order digit and the first low-order digit and the process of symmetrically dividing the complemented digits are reverse processes. After splicing, the numbers with the complement bits can be filtered to obtain a decryption result of the numbers to be decrypted.
The embodiment of the invention provides a digital decryption method, which determines a ciphertext and a key from a number to be decrypted; decrypting the ciphertext by using the key to obtain an original text of the ciphertext, and determining a second high-order digit and a second low-order digit according to the original text and the key; performing inverse transformation decryption on the digits in the second high-order digits and the second low-order digits based on the first digit table to obtain first high-order digits and first low-order digits; and splicing the first high-order digit and the first low-order digit, and determining a decryption result of the digit to be decrypted according to the splicing result. The algorithm for reversely replacing and decrypting the superposed digital table by using the key decryption can realize the reverse decryption of the numbers encrypted by using the key encryption and the digital table replacement encryption. Not only stable encryption and decryption are realized, modification in the digital decryption process is avoided, but also the digital security is improved.
In addition, the processes of key decryption and digital table reverse replacement decryption in the embodiment of the present invention are reverse to the processes of key encryption and digital table replacement encryption in the digital encryption method proposed in the above embodiment. The encryption and decryption process has corresponding technical characteristics, and belongs to the same invention concept. For technical details that are not described in detail in the present embodiment, reference may be made to the above-described embodiments, and the present embodiment has the same beneficial effects as the above-described embodiments.
EXAMPLE five
The present embodiment describes in detail the steps of determining the second upper digit and the second lower digit from the original text and the key, based on the above-described embodiments. The original text and the key are used as a third high-order digit and a third low-order digit, and the third high-order digit and the third low-order digit are converted into binary digits and are segmented to obtain each segment of binary digits; the displacement decryption of the original text and the key can be realized by correspondingly right-shifting each segment of binary digits and converting the binary digits into decimal digits. The displacement decryption method is the inverse operation of the displacement encryption method, can realize the encryption and decryption of stable numbers, further improves the difficulty of the back calculation of encrypted numbers, and improves the safety of the numbers.
Fig. 5 shows a flowchart of a digital decryption method according to a fifth embodiment of the present invention. Referring to fig. 5, the digital decryption method provided in the embodiment of the present invention includes the following steps:
and S510, determining a ciphertext and a key from the number to be decrypted.
S520, the cipher text is decrypted by using the key, and the original text of the cipher text is obtained.
And S530, taking the original text and the key as a third high-order digit and a third low-order digit respectively.
The original text can be used as a third high-order number, and the secret key can be used as a third low-order number; the original text may be the third lowest digit and the key may be the third highest digit.
And S540, respectively converting the third high-order digit and the third low-order digit into a whole segment of binary digits and splitting the binary digits to obtain multiple segments of binary digits.
And S550, right shifting each segment of binary digit according to the position of each segment of binary digit in the whole segment of binary digit.
And S560, converting each segment of binary digits after right shift into decimal digits, and obtaining a second high-order digit and a second low-order digit after displacement decryption of the original text and the secret key according to each segment of decimal digits.
In steps S540-S560, the right shift decryption process of binary conversion, splitting, right shifting, and decimal conversion on the third high-order digit and the third low-order digit is the reverse process to the left shift encryption process of binary conversion, left shifting, splicing, and decimal conversion on each segment of decimal digits in the second high-order digit and the second low-order digit disclosed in the above embodiments.
In the left shift encryption process, when each decimal digit group is converted into a binary digit, the preset digit is required to be met, and in the right shift decryption process, the whole converted binary digit can be split according to the preset digit to obtain each binary digit.
In the left shift encryption process, each binary digit can be left shifted according to the position of each binary digit in the whole binary digit, and in the right shift decryption process, each binary digit can be correspondingly right shifted according to the position of each binary digit in the whole binary digit.
After each section of binary digits is obtained by right shift, each section of decimal digits in the second high-order digits and the second low-order digits can be obtained through decimal conversion.
S570, performing inverse transformation and decryption on the second high-order digit and the second low-order digit based on the first digit table to obtain a first high-order digit and a first low-order digit.
And S580, splicing the first high-order digit and the first low-order digit, and determining a decryption result of the digit to be decrypted according to the splicing result.
Embodiments of the present invention have been described in detail on the basis of the above embodiments, regarding the steps of determining the second upper digit and the second lower digit from the original text and the key. The original text and the key are used as a third high-order digit and a third low-order digit, and the third high-order digit and the third low-order digit are converted into binary digits and are segmented to obtain each segment of binary digits; the displacement decryption of the original text and the key can be realized by correspondingly right-shifting each segment of binary digits and converting the binary digits into decimal digits. The displacement decryption method is the inverse operation of the displacement encryption method, can realize the encryption and decryption of stable numbers, further improves the difficulty of the back calculation of encrypted numbers, and improves the safety of the numbers.
In addition, the process of right shift decryption in the embodiment of the present invention is the reverse process to the process of left shift encryption in the digital encryption method proposed in the above embodiment. The encryption and decryption process has corresponding technical characteristics, and belongs to the same invention concept. For technical details that are not described in detail in the present embodiment, reference may be made to the above-described embodiments, and the present embodiment has the same beneficial effects as the above-described embodiments.
EXAMPLE six
In this embodiment, on the basis of the above-described embodiment, the step of checking whether the decryption process is normal according to the seed character is described in detail. After the second high-order digit and the second low-order digit are determined, the second high-order digit and the second low-order digit can be operated, and the seed character is obtained according to the operation result index seed table. By checking the indexed seed character according to the seed character in the number to be decrypted, whether the current decryption process is normal can be judged, and then the numbers in the second high-order number and the second low-order number can be further subjected to reverse substitution decryption in normal time. The difficulty of the back calculation of the encrypted number is further improved, and therefore the safety of the number is improved.
Fig. 6 shows a flowchart of a digital decryption method according to a sixth embodiment of the present invention. Referring to fig. 6, the digital decryption method provided in the embodiment of the present invention includes the following steps:
s610, according to the seed characters in the numbers to be decrypted, the numbers to be decrypted are segmented to obtain the ciphertext and the secret key.
The number to be decrypted can be formed by splicing 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 the number to be decrypted is segmented, the data to be decrypted can be segmented according to the seed characters, and the segmented ciphertext and the key can be extracted according to the splicing sequence in the splicing process.
S620, the cipher text is decrypted by using the key, the original text of the cipher text is obtained, and the second high-order digit and the second low-order digit are determined according to the original text and the key.
And S630, operating by using the second high-order digit and the second low-order digit to obtain a third index position of the seed table.
The process of determining the third index position by using the second high-order digit and the second low-order digit in the decryption process may be the same as the process of determining the third index position by using the second high-order digit and the second low-order digit in the encryption process.
And S640, indexing the seed table according to the third indexing position, and checking the seed character according to the indexing result.
Wherein, checking 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 the two are the same, the verification is passed, and if the two are different, the verification fails.
And S650, when the verification passes, performing inverse transformation and decryption on the numbers in the second high-order digit and the second low-order digit based on the first digit table to obtain a first high-order digit and a first low-order digit.
And S660, splicing the first high-order digit and the first low-order digit, and determining a decryption result of the digit to be decrypted according to the splicing result.
In the abnormal decryption process, the cipher text can be decrypted by using the key according to the decryption process which does not correspond to the encryption process. At this time, if the decryption process does not correspond to the encryption process, the obtained original text is an erroneous original text. Accordingly, since the characters in the seed table are not repeated, the seed characters indexed based on the wrong original text are largely different from the seed characters in the numbers to be decrypted. Therefore, the decryption process can be identified as an abnormal decryption process, and further the decryption is stopped, so that the difficulty of back calculation of the encrypted number is improved, and the security of the number is improved.
On the basis of the above embodiment, the embodiment of the present invention describes in detail the step of verifying whether the decryption process is normal according to the seed character. After the second high-order digit and the second low-order digit are determined, the second high-order digit and the second low-order digit can be operated, and the seed character is obtained according to the operation result index seed table. By checking the indexed seed character according to the seed character in the number to be decrypted, whether the current decryption process is normal can be judged, and then the numbers in the second high-order number and the second low-order number can be further subjected to reverse substitution decryption in normal time. The difficulty of the back calculation of the encrypted number is further improved, and therefore the safety of the number is improved.
In addition, the process of calculating the seed character in the embodiment of the present invention is the same as the process of calculating the seed character in the digital encryption method proposed in the above embodiment. The encryption and decryption process has corresponding technical characteristics, and belongs to the same invention concept. For technical details that are not described in detail in the present embodiment, reference may be made to the above-described embodiments, and the present embodiment has the same beneficial effects as the above-described embodiments.
Moreover, it should be noted that different digital decryption methods can be formed by correspondingly combining the decryption algorithms in the digital table reverse substitution decryption, the displacement decryption, the key decryption and the seed character decryption provided in the embodiments of the present invention according to the combined encryption algorithm in each digital encryption method, and these digital decryption methods all belong to the protection scope of the present invention.
EXAMPLE seven
The present embodiment combines the encryption method and the decryption method based on the above-described embodiments. In the digital encryption process, the digital table confusion replacement encryption, displacement encryption, key encryption and seed encryption can be used for encrypting the to-be-encrypted digital; correspondingly, the decryption process adopts key decryption, seed verification, displacement decryption and digit table reverse displacement decryption which are reversible with the encryption process to decrypt the digits to be decrypted. The method can realize a stable encryption and decryption process and improve the safety of the numbers.
Fig. 7 is a schematic flow chart illustrating a digital encryption and decryption method according to a seventh embodiment of the present invention. Referring to fig. 7, the digital encryption and decryption method provided in the embodiment of the present invention includes two stages of encryption and decryption:
wherein, the encryption phase may include:
s701, conducting digit complement on the digits to be encrypted, and symmetrically dividing the complemented digits to obtain a first high digit and a first low digit.
Step S701 is a digital processing step, and performs bit number padding and symmetric division on the numbers to be encrypted, and separates out the first high-order digit and the first low-order digit.
S702, aiming at each digit in the first high-order digits and the first low-order digits, carrying out replacement encryption on each digit based on a first digit table to obtain second high-order digits and second low-order digits.
In step S702, the first encryption is performed, that is, the first high-order digit and the first low-order digit are subjected to obfuscating, replacing and encrypting by using the first digit replacing table, so as to obtain a second high-order digit and a second low-order digit. Wherein the second high digit and the second low digit may comprise multiple segments of decimal digits.
And S703, converting each decimal digit into a binary digit aiming at the second high digit and the second low digit.
S704, according to the position of each binary digit in the whole binary digit, each binary digit is shifted to the left.
S705, converting the binary digits spliced by the left-shifted binary digits into decimal digits, and obtaining a third high digit and a third low digit after displacement encryption of the second high digit and the second low digit.
The steps S703 to S705 are second encryption, that is, long-integer third high-order digits and third low-order digits are obtained by performing binary conversion, left shift, concatenation, and displacement encryption of the decimal conversion on each segment of decimal digits in the second high-order digits and the second low-order digits.
And S706, respectively taking the third high-order digit and the third low-order digit as an original text and a secret key, and encrypting the original text by using the secret key to obtain a ciphertext of the original text.
Step S706 is a third encryption, that is, the third high-order digit and the third low-order digit are respectively used as the original text and the key, and the original text is encrypted by using the key.
S707, operating by using the third high-order digit and the third low-order digit to obtain a third index position of the seed table; and indexing the seed table according to the third indexing position to obtain the seed character.
And S708, splicing the ciphertext, the seed character and the secret key to obtain an encryption result of the number to be encrypted.
Wherein, S707-708 is fourth encryption, that is, seed encryption can be implemented by indexing seed characters according to the third high-order digit and the third low-order digit and splicing encryption results by using the seed characters.
After the number is encrypted in the encryption stage, the corresponding decryption stage may include:
and S709, segmenting the number to be decrypted according to the seed character in the number to be decrypted to obtain a ciphertext and a secret key.
Step S709 begins to decrypt, and may find out the seed character in the number to be decrypted, and perform segmentation to obtain the key, the seed character, and the ciphertext.
And S710, decrypting the ciphertext by using the key to obtain an original text of the ciphertext, and taking the original text and the key as a third high-order digit and a third low-order digit respectively.
Step S710 is a first decryption, that is, the cipher text is decrypted by using the key, so as to obtain a third high-order digit and a third low-order digit.
S711, performing operation by using the third high-order digit and the third low-order digit to obtain a third index position of the seed table; and indexing the seed table according to the third indexing position, and checking the seed character according to the indexing result.
Step S711 is a second decryption, that is, the seed character in the to-be-decrypted number is verified according to the indexing result by indexing the seed character according to the third high-order number and the third low-order number, so that seed decryption can be realized, and abnormal decryption operations are filtered.
And S712, when the verification is passed, respectively converting the third high-order digit and the third low-order digit into the whole binary digits and splitting the binary digits to obtain multiple binary digits.
S713, each segment of binary digit is shifted to the right according to the position of each segment of binary digit in the whole segment of binary digit.
And S714, converting each section of binary digits after right shift into decimal digits, and obtaining a second high-order digit and a second low-order digit after displacement decryption of the original text and the secret key according to each section of decimal digits.
The third decryption in steps S712-S714 is performed by performing binary conversion, splitting, right shifting, and decimal conversion on the third high-order digit and the third low-order digit to obtain a second high-order digit and a second low-order digit.
And S715, performing inverse transformation and decryption on 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.
In step S715, the fourth decryption is performed, that is, the second high-order digit and the second low-order digit are decrypted by inverse permutation through the first digit permutation table, so as to obtain the first high-order digit and the first low-order digit.
And S716, splicing the first high-order digit and the first low-order digit, and determining a decryption result of the digit to be decrypted according to the splicing result.
Finally, the first high-low digit is spliced to restore the original plaintext.
The embodiment of the invention combines the encryption method and the decryption method on the basis of the embodiment. In the digital encryption process, the digital table confusion replacement encryption, displacement encryption, key encryption and seed encryption can be used for encrypting the to-be-encrypted digital; correspondingly, the decryption process adopts key decryption, seed verification, displacement decryption and digit table reverse displacement decryption which are reversible with the encryption process to decrypt the digits to be decrypted. The method can realize a stable encryption and decryption process and improve the safety of the numbers. In addition, the embodiments of the present invention and the digital encryption/decryption method and the digital decryption method proposed in the above embodiments belong to the same inventive concept, and the technical details that are not described in detail in the present embodiment can be referred to the above embodiments, and the present embodiment has the same beneficial effects as the above embodiments.
Example eight
Fig. 8 is a schematic structural diagram illustrating a digital encryption apparatus according to an eighth embodiment of the present invention. The embodiment of the invention is suitable for encrypting the number.
As shown in fig. 8, the digital encryption apparatus according to the embodiment of the present invention includes:
the dividing module 810 is configured to complete digits of the digits to be encrypted, and symmetrically divide the completed digits to obtain a first high-order digit and a first low-order digit;
a first encryption module 820, configured to perform permutation encryption on each digit in the first high-order digit and the first low-order digit based on the first digit table to obtain a second high-order digit and a second low-order digit;
the second encryption module 830 is configured to determine an original text and a secret key according to the second high-order number and the second low-order number, and encrypt the original text by using the secret key to obtain a ciphertext of the original text;
and the result determining module 840 is used for obtaining an encryption result of the number to be encrypted according to the ciphertext and the key.
In some optional embodiments, the first encryption module may be specifically configured to:
determining a first index position of a first number table according to the current number; indexing the first number table according to the first index position to obtain a complementary digit of the current digit; and utilizing the complementary digit to complement the current digit to obtain the digit of the current digit after replacement encryption.
In some optional embodiments, the second encryption module may be specifically configured to:
judging whether the original text and the secret key are contained in the second digital table; if yes, determining a second index position of the second numerical table according to the original text and the secret key; and indexing the second numerical table according to the second index position to obtain a ciphertext corresponding to the original text.
In some alternative embodiments, the second high digit and the second low digit comprise multiple segments of decimal digits;
correspondingly, the second encryption module is specifically configured to:
converting each decimal digit into a binary digit aiming at a second high digit and a second low digit; according to the position of each section of binary digit in the whole section of binary digit, each section of binary digit is shifted to the left; converting the binary digits spliced by the binary digits of the left-shifted sections into decimal digits to obtain a third high digit and a third low digit after displacement encryption of the second high digit and the second low digit; and respectively taking the third high-order digit and the third low-order digit as an original text and a secret key.
In some optional embodiments, the second encryption module may be further configured to:
after the second high-order digit and the second low-order digit are obtained, the second high-order digit and the second low-order digit are used for operation, and a third index position of the seed table is obtained; indexing the seed table according to the third indexing position to obtain seed characters;
correspondingly, the result determination module may be specifically configured to:
and splicing the ciphertext, the seed character and the secret key to obtain an encryption result of the number to be encrypted.
In some alternative embodiments, the number to be encrypted comprises a number in a web site.
The digital encryption device provided by the embodiment of the invention belongs to the same inventive concept as the digital encryption method provided by the embodiment, and technical details which are not described in detail in the embodiment of the invention can be referred to the embodiment, and the embodiment of the invention has the same beneficial effects as the embodiment.
Example nine
Fig. 9 is a schematic structural diagram of a digital decryption apparatus according to a ninth embodiment of the present invention. The embodiment of the invention is suitable for the condition of decrypting the number.
As shown in fig. 9, the digital decryption apparatus according to the embodiment of the present invention includes:
a ciphertext key determining module 910, configured to determine a ciphertext and a key from a number to be decrypted;
the first decryption module 920 is configured to decrypt the ciphertext with the key to obtain an original text of the ciphertext, and determine a second high-order digit and a second low-order digit according to the original text and the key;
a second decryption module 930, configured to perform inverse transform decryption on the numbers in the second high-order digits and the second low-order digits based on the first digital table to obtain the first high-order digits and the first low-order digits;
and a splicing module 940, configured to splice the first high-order digit and the first low-order digit, and determine a decryption result of the to-be-decrypted digit according to the splicing result.
The first decryption module may be specifically configured to: judging whether the ciphertext and the key are contained in the second numerical table; if yes, the original text corresponding to the ciphertext is searched from the second digital table reversely according to the ciphertext and the secret key.
The second decryption module may be specifically configured to: grouping the second high-order digits and the second low-order digits respectively, wherein each group of digits comprises pre-replacement digits and corresponding complementary digits; determining a first index position of a first number table according to the number before replacement; indexing the first number table according to the first index position, and verifying the complementary digit according to the index result; and if the check is passed, inversely replacing each group of digits into a pre-replacement digit group to obtain a first high digit and a first low digit.
In some optional embodiments, the first decryption module may be specifically configured to:
respectively taking the original text and the key as a third high-order digit and a third low-order digit;
respectively converting the third high-order digit and the third low-order digit into a whole segment of binary digits and splitting the whole segment of binary digits to obtain a plurality of segments of binary digits;
right shifting each section of binary digit according to the position of each section of binary digit in the whole section of binary digit;
and converting each section of binary digits after right shift into decimal digits, and obtaining a second high-order digit and a second low-order digit of the original text and the key after displacement decryption according to each section of decimal digits.
In some optional embodiments, the ciphertext key determination module may be specifically configured to:
according to the seed character in the number to be decrypted, segmenting the number to be decrypted to obtain a ciphertext and a secret key;
correspondingly, the first decryption module may be further configured to:
after determining a second high-order digit and a second low-order digit according to the original text and the key, operating by using the second high-order digit and the second low-order digit to obtain a third index position of the seed table;
and indexing the seed table according to the third indexing position, and checking the seed character according to the indexing result.
The digital decryption device provided by the embodiment of the invention belongs to the same inventive concept as the digital decryption method provided by the above embodiment, and technical details which are not described in detail in the embodiment of the invention can be referred to the above embodiment, and the embodiment of the invention has the same beneficial effects as the above embodiment.
Example ten
Fig. 10 shows a schematic hardware structure diagram of a terminal device according to a tenth embodiment of the present invention. The terminal device in the embodiments of the present invention may include, but is not limited to, a mobile terminal such as a mobile phone, a notebook computer, a digital broadcast receiver, a PDA (personal digital assistant), a PAD (tablet computer), a PMP (portable multimedia player), a vehicle terminal (e.g., a car navigation terminal), and the like, and a fixed terminal such as a digital TV, a desktop computer, and the like. The terminal device shown in fig. 10 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present invention.
As shown in fig. 10, terminal device 1000 may include a processing means (e.g., a central processing unit, a graphic processor, etc.) 1001 that may 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 means 1008 into a Random Access Memory (RAM) 1003. In the RAM1003, various programs and data necessary for the operation of the terminal apparatus 1000 are also stored. The processing device 1001, the ROM 1002, and the RAM1003 are connected to each other by a bus 1004. An input/output (I/O) interface 1005 is also connected to bus 1004.
Generally, the following devices may be connected to the I/O interface 1005: input devices 1006 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; an output device 1007 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage devices 1008 including, for example, magnetic tape, hard disk, and the like; and a communication device 1009. The communication means 1009 may allow the terminal apparatus 1000 to perform wireless or wired communication with other apparatuses to exchange data. While fig. 10 illustrates a terminal apparatus 1000 having various means, it is to be understood that not all illustrated means are required to be implemented or provided. More or fewer devices may alternatively be implemented or provided.
In particular, according to an embodiment of the present invention, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the invention include a computer program product comprising a computer program embodied on a computer-readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication means 1009, or installed from the storage means 1008, or installed from the ROM 1002. When executed by the processing device 1001, the computer program can execute the digital encryption method provided by the embodiment of the present invention or execute the above-described functions defined in the digital decryption method provided by the embodiment of the present invention.
The terminal provided by the embodiment of the present invention and the digital encryption method or the digital decryption method provided by the above embodiment belong to the same inventive concept, and technical details that are not described in detail 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.
EXAMPLE eleven
An embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the digital encryption and decryption method or the digital decryption method provided in the above-mentioned embodiment.
It should be noted that the computer readable storage medium mentioned above in the embodiments of the present invention may be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, 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 disc Read-Only Memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In embodiments of the invention, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In yet another embodiment of the invention, a computer readable signal medium may comprise a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
In some embodiments, the clients, servers may communicate using any currently known or future developed network Protocol, such as HTTP (Hyper Text Transfer Protocol), and may interconnect with any form or medium of digital data communication (e.g., a communications network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), the Internet (e.g., the Internet), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future developed network.
The computer-readable storage medium may be included in the terminal device or may be separately present without being incorporated in the terminal device.
The terminal device stores one or more programs, and when the one or more programs are executed by the terminal device, the terminal device is enabled to:
supplementing digits of the digits to be encrypted, and symmetrically dividing the supplemented digits to obtain a first high digit and a first low digit; aiming at each digit in the first high-order digits and the first low-order digits, carrying out replacement encryption on each digit based on a first digit table to obtain second high-order digits and second low-order digits; determining an original text and a secret key according to the second high-order digit and the second low-order digit, and encrypting the original text by using the secret key to obtain a ciphertext of the original text; and obtaining an encryption result of the number to be encrypted according to the ciphertext and the key.
Or, the terminal device stores one or more programs, and when the one or more programs are executed by the terminal device, the terminal device is enabled to:
determining a cipher text and a key from the number to be decrypted; decrypting the ciphertext by using the key to obtain an original text of the ciphertext, and determining a second high-order digit and a second low-order digit according to the original text and the key; performing inverse transformation decryption on the digits in the second high-order digits and the second low-order digits based on the first digit table to obtain first high-order digits and first low-order digits; and splicing the first high-order digit and the first low-order digit, and determining a decryption result of the digit to be decrypted according to the splicing result.
Computer program code for carrying out operations for aspects of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of 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 the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functional pages noted in the blocks may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units described in the embodiments of the present invention may be implemented by software or hardware. Where the name of an element does not in some cases constitute a limitation on the element itself.
The functions described herein above may be performed, at least in part, by one or more hardware logic components. For example, without limitation, exemplary types of 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 a chip (SOCs), Complex Programmable Logic Devices (CPLDs), and the like.
It is to be noted that the foregoing is only illustrative of the preferred embodiments of the present invention and the technical principles employed. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments illustrated herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, although the present invention has been described in greater detail by the above embodiments, the present invention is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims (13)

1. A digital encryption method, comprising:
supplementing digits of the digits to be encrypted, and symmetrically dividing the supplemented digits to obtain a first high digit and a first low digit;
for each digit in the first high-order digits and the first low-order digits, performing replacement encryption on each digit based on a first digit table to obtain second high-order digits and second low-order digits;
determining an original text and a secret key according to the second high-order digit and the second low-order digit, and encrypting the original text by using the secret key to obtain a ciphertext of the original text;
and obtaining an encryption result of the number to be encrypted according to the ciphertext and the secret key.
2. The method of claim 1, wherein said permuting encrypting each of said digits based on a first table of digits comprises:
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 complementary digit of the current digit;
and utilizing the bit complementing number to complement the current number to obtain the number of the current number after replacement and encryption.
3. The method of claim 1, wherein said encrypting said plaintext using said key comprises:
judging whether the original text and the secret key are contained in a second numerical table or not;
if yes, determining a second index position of the second digital table according to the original text and the secret key;
and indexing the second digital table according to the second index position to obtain a ciphertext corresponding to the original text.
4. The method of claim 1, wherein the second high digit and the second low digit comprise a plurality of decimal digits;
the determining the original text and the key according to the second high-order digit and the second low-order digit comprises:
for the second high-order digit and the second low-order digit, converting each decimal digit into a binary digit;
according to the position of each section of binary digit in the whole section of binary digit, left shifting each section of binary digit;
converting the binary digits spliced by the binary digits after left shift into decimal digits to obtain a third high digit and a third low digit after displacement encryption of the second high digit and the second low digit;
and respectively taking the third high-order digit and the third low-order digit as an original text and a secret key.
5. The method of claim 1, further comprising, after said obtaining the second high digit and the second low digit:
performing operation by 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 indexing position to obtain seed characters;
correspondingly, the obtaining an encryption result of the number to be encrypted according to the ciphertext and the key includes:
and splicing the ciphertext, the seed character and the secret key to obtain an encryption result of the number to be encrypted.
6. The method according to any one of claims 1 to 5, wherein the number to be encrypted comprises a number in a web address.
7. A digital decryption method, comprising:
determining a cipher text and a key from the number to be decrypted;
decrypting the ciphertext by using the key to obtain an original text of the ciphertext, and determining a second high-order digit and a second low-order digit according to the original text and the key;
performing inverse transformation decryption on the second high-order digit and the second low-order digit based on a first digit table to obtain a first high-order digit and a first low-order digit;
and splicing the first high-order digit and the first low-order digit, and determining a decryption result of the digit to be decrypted according to a splicing result.
8. The method of claim 7, wherein determining the second high-order digit and the second low-order digit from the plaintext and the key comprises:
respectively taking the original text and the key as a third high-order digit and a third low-order digit;
respectively converting the third high-order digit and the third low-order digit into a whole binary digit and splitting the whole binary digit to obtain a plurality of sections of binary digits;
right shifting each section of the binary digits according to the position of each section of the binary digits in the whole section of the binary digits;
and converting each section of the binary digits after the right shift into decimal digits, and obtaining a second high-order digit and a second low-order digit after the displacement decryption of the original text and the key according to each section of the decimal digits.
9. The method of claim 7, wherein determining the ciphertext and the key from the number to be decrypted comprises:
according to the seed character in the number to be decrypted, segmenting the number to be decrypted to obtain a ciphertext and a secret key;
correspondingly, after the determining the second high digit and the second low digit according to the original text and the secret key, the method further comprises the following steps:
performing operation by using the second high-order digit and the second low-order digit to obtain a third index position of the seed table;
and indexing the seed table according to the third indexing position, and checking the seed character according to an indexing result.
10. A digital encryption apparatus, comprising:
the segmentation module is used for conducting digit complement on the digits to be encrypted and symmetrically segmenting the complemented digits to obtain a first high digit and a first low digit;
the first encryption module is used for carrying out replacement encryption on each digit in the first high-order digit and the first low-order digit based on a first digit table to obtain a second high-order digit and a second low-order digit;
the second encryption module is used for determining an original text and a secret key according to the second high-order digit and the second low-order digit, and encrypting the original text by using the secret key to obtain a ciphertext of the original text;
and the result determining module is used for obtaining the encryption result of the number to be encrypted according to the ciphertext and the secret key.
11. A digital decryption apparatus, comprising:
the ciphertext key determining module is used for determining a ciphertext and a key from the number to be decrypted;
the first decryption module is used for decrypting the ciphertext by using the key to obtain an original text of the ciphertext and determining a second high-order digit and a second low-order digit according to the original text and the key;
the second decryption module is used for carrying out inverse transformation decryption on the digits in the second high-order digits and the second low-order digits based on the first digit table to obtain first high-order digits and first low-order digits;
and the splicing module is used for splicing the first high-order digit and the first low-order digit and determining a decryption result of the to-be-decrypted digit according to a splicing result.
12. A terminal device, characterized in that the terminal comprises:
one or more processors;
a memory for storing one or more programs;
when executed by the one or more processors, cause the one or more processors to implement a digital encryption method as claimed in any one of claims 1 to 6, or a digital decryption method as claimed in any one of claims 7 to 9.
13. A computer-readable storage medium on which a computer program is stored, which program, when executed by a processor, implements the digital encryption method of any one of claims 1 to 6, or the digital decryption method of any one of claims 7 to 9.
CN202111210290.9A 2021-10-18 2021-10-18 Digital encryption and decryption method and device, terminal equipment and storage medium Pending CN113946847A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111210290.9A CN113946847A (en) 2021-10-18 2021-10-18 Digital encryption and decryption method and device, terminal equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111210290.9A CN113946847A (en) 2021-10-18 2021-10-18 Digital encryption and decryption method and device, terminal equipment and storage medium

Publications (1)

Publication Number Publication Date
CN113946847A true CN113946847A (en) 2022-01-18

Family

ID=79331134

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111210290.9A Pending CN113946847A (en) 2021-10-18 2021-10-18 Digital encryption and decryption method and device, terminal equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113946847A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114598470A (en) * 2022-03-17 2022-06-07 北京启明星辰信息安全技术有限公司 Encryption method, decryption method, device and computer readable storage medium
CN115171247A (en) * 2022-06-24 2022-10-11 广东汇泰龙科技股份有限公司 Intelligent lock, storage method, decryption method and storage medium

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114598470A (en) * 2022-03-17 2022-06-07 北京启明星辰信息安全技术有限公司 Encryption method, decryption method, device and computer readable storage medium
CN114598470B (en) * 2022-03-17 2023-12-19 北京启明星辰信息安全技术有限公司 Encryption method, decryption method, device, and computer-readable storage medium
CN115171247A (en) * 2022-06-24 2022-10-11 广东汇泰龙科技股份有限公司 Intelligent lock, storage method, decryption method and storage medium

Similar Documents

Publication Publication Date Title
EP3916604A1 (en) Method and apparatus for processing privacy data of block chain, device, storage medium and coputer program product
CN113946847A (en) Digital encryption and decryption method and device, terminal equipment and storage medium
US20160321958A1 (en) Secret calculation method, secret calculation system, sorting device, and program
CN110516462B (en) Method and apparatus for encrypting data
WO2019114122A1 (en) Encryption method for login information, device, electronic device, and medium
US20240080209A1 (en) Chosen-plaintext secure cryptosystem and authentication
CN114175572A (en) System and method for performing equality and subordination operations on encrypted data using quasigroup operations
CN115065555A (en) Information security processing method and system
CN114124359A (en) Method and device for preserving format encrypted data, electronic equipment and storage medium
CN111130791B (en) Data signature method, electronic device and computer readable storage medium
CN112329044A (en) Information acquisition method and device, electronic equipment and computer readable medium
CN116010678B (en) Method, device and equipment for inquiring trace
CN115834025A (en) Data encryption method, equipment and storage medium for automobile diagnosis platform
CN114611120A (en) Data encryption method, device, equipment and medium
CN114491421A (en) File encryption method, file processing method, file encryption device, file processing device, readable medium and electronic equipment
Parikibandla et al. Low area field‐programmable gate array implementation of PRESENT image encryption with key rotation and substitution
CN112836239A (en) Method and device for cooperatively determining target object data by two parties for protecting privacy
JP5578422B2 (en) ENCRYPTED COMMUNICATION SYSTEM, TRANSMISSION DEVICE, RECEPTION DEVICE, ENCRYPTION / DECRYPTION METHOD, AND PROGRAM THEREOF
CN108075889B (en) Data transmission method and system for reducing complexity of encryption and decryption operation time
US20230336327A1 (en) Batch encryption methods, related apparatuses, systems, devices, mediums, and program products
CN110619218B (en) Method and apparatus for generating information
CN111949627B (en) Method, device, electronic equipment and medium for tabulating log files
CN117579392B (en) Reliable data transmission method, device, equipment and medium based on encryption processing
CN113742774B (en) Data processing method and device, readable medium and electronic equipment
CN116226888B (en) Power data interactive encryption method, system and equipment based on privacy protection

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination