Method for sequentially encrypting and decrypting doubly linked lists based on double key stream ciphers
11184154 · 2021-11-23
Assignee
Inventors
Cpc classification
H04L9/065
ELECTRICITY
International classification
H04L9/06
ELECTRICITY
H04L9/00
ELECTRICITY
Abstract
A method for sequentially encrypting and decrypting doubly linked lists based on double key stream ciphers comprises: establishing a plaintext set M according to a plaintext file; using the plaintext set M as an initial value and performing iterative decryption to obtain a ciphertext set C, wherein a key set P and an algorithm set A are used during the iterative decryption; for the ciphertext set C, performing multiple decryptions by calling the key set P and keys in the key set P, wherein a key set P and an algorithm set A are used during the decryptions; and, converting the obtained result of decryption into a plaintext file.
Claims
1. A method for sequentially encrypting and decrypting doubly linked lists based on double key stream ciphers, comprising: establishing a plaintext set M according to a plaintext file, wherein the plaintext can be any resolvable file; using the plaintext set Mas an initial set and performing sequentially iterative encryption to obtain a ciphertext set C, wherein a reference string, a key set P and an algorithm set A are used jointly in the iterative encryption, and the reference string has 2.sup.m bytes, where m>=0 and m is a positive integer; the iterative encryption carried out by a network computer comprises: acquiring any values of the plaintext set M, the ciphertext set C and the key set P as initial values and pointers corresponding to the initial values, performing two iterative encryptions on the plaintext set M through the pointers, the reference string and the algorithm set A to obtain a ciphertext set C, wherein the plaintext set M and the key set P are not even numbers or odd numbers simultaneously as for a pointer used for encryption; and for the ciphertext set C, performing multiple decryptions by calling the key set P, wherein the key set P and the algorithm set A are used during the encryption, wherein the key set P and the algorithm set A are shared by the encryption and the decryption, and the sets M and C are doubly circular linked lists, wherein the plaintext set M and the key set P are not even numbers or odd numbers simultaneously as for a pointer used for encryption; wherein the decryption carried out by a network computer comprises: retrieving the iteratively encrypted initial values, establishing pointers corresponding to the initial values, performing two decryptions on the ciphertext set C in combination with the reference string and an encryption algorithm in the algorithm set A to obtain the plaintext set M, and converting the plaintext set M into the plaintext file.
2. The method for sequentially encrypting and decrypting doubly linked lists based on double key stream ciphers according to claim 1, wherein all the plaintext set M, the ciphertext set C, the key set P and the algorithm set A are character sets consisting of binary code elements.
3. The method for sequentially encrypting and decrypting doubly linked lists based on double key stream ciphers according to claim 1, wherein establishing a plaintext set M according to a plaintext file comprises: reading a plaintext file to obtain the number of bytes n of the plaintext file; and establishing a plaintext set M that is an ordered set, wherein M={X.sub.0X.sub.1 {circumflex over ( )} X.sub.8n−1}, where x.sub.i={0,1} and i satisfies the condition of 0<=i<=8n−1, and as a doubly circular linked list, for the set M, x.sub.n−1 is followed by x.sub.0.
4. The method for sequentially encrypting and decrypting doubly linked lists based on double key stream ciphers according to claim 3, wherein the method further comprises: the key set P comprises a first key subset and a second key subset, wherein the first key subset is P.sub.0={y0.sub.0 y0.sub.1 {circumflex over ( )} y0.sub.8n−1}, where y0.sub.j0={0,1}, j0 satisfies the condition of 0<=j0<=8n−1, and P.sub.0 is an ordered set; the second key subset is P.sub.1={y1.sub.0y1.sub.1, {circumflex over ( )} y1.sub.8n−1}, where y1.sub.j1={0,1}, j1 satisfies the condition of 0<=j1<=8n−1, and P.sub.1 is an ordered set; the first key subset P.sub.0 and the second key subset P.sub.1 are singly circular linked lists; for P.sub.0, y0.sub.8n−1 is followed by y0.sub.0; and for P.sub.1, y1.sub.8n−1 is followed by y1.sub.0.
5. The method for sequentially encrypting and decrypting doubly linked lists based on double key stream ciphers according to claim 4, wherein the method further comprises: the ciphertext set C comprises a first ciphertext subset and a second ciphertext subset, wherein the first ciphertext subset is C.sub.0={z0.sub.0z0.sub.1 {circumflex over ( )}z0.sub.8n−1}, where y0.sub.k0={0,1}, k0 satisfies the condition of 0<=k0<=8n−1, and C.sub.0 is an ordered set; the second key subset is C.sub.1={z1.sub.0z1.sub.1 {circumflex over ( )} z1.sub.8n−1}, where z1.sub.k1={0,1}, k1 satisfies the condition of 0<=k1<=8n−1, and C.sub.1 is an ordered set; the first key C.sub.0 and the second key are doubly circular linked lists; for C.sub.0, z0.sub.8n−1 is followed by z0.sub.0; and for C.sub.1, z1.sub.8n−1 is followed by z1.sub.0.
6. The method for sequentially encrypting and decrypting doubly linked lists based on double key stream ciphers according to claim 5, wherein the method further comprises: using any initial value i.sub.0 (where 0<=i.sub.0<=8n−1) as an initial value of the set M, and reserving this initial value; using any initial value i.sub.1 (where 0<=i.sub.1<=8n−1) as an initial value of the set C.sub.0, and reserving this initial value; using any initial value j.sub.0 (where 0<=j.sub.0<=8n−1) as an initial value of the set P.sub.0, and reserving this initial value; using any initial value j.sub.1 (where 0<=j.sub.1<=8n−1) as an initial value of the set P.sub.1, and reserving this initial value; using any initial value k.sub.0 (where 0<=k.sub.0<=8n−1) as an initial value of the set C.sub.0, and reserving this initial value; and using any initial value k.sub.1 (where 0<=k.sub.1<=8n−1) as an initial value of the set C.sub.1, and reserving this initial value.
7. The method for sequentially encrypting and decrypting doubly linked lists based on double key stream ciphers according to claim 6, wherein the double-key encryption methods further comprise: a first encryption method, comprising a first encryption step and a second encryption step, wherein the first encryption step comprises: establishing a pointer p1 to point to an x.sub.i0 bit of the plaintext set M, and setting p1 as 8n−1 when p1 is 0; establishing a pointer p2 to point to an x.sub.i0+1 bit of the plaintext set M, and setting p2 as 0 when p2 is 8n−1; establishing a pointer q to point to a y0.sub.j0 bit of the first key subset P.sub.0; establishing a pointer r to point to a z0.sub.k0 bit of the first ciphertext subset C.sub.0; and sequentially executing encryption, comprising judging whether *q or !(*q) is true, letting *r=*p2 and letting p2, q and r to increase progressively if *q or !(*q) is true, and letting *r=*p1 and letting q and r to increase progressively and p1 to decrease progressively if *q or !(*q) is not true, wherein, in the first encryption step, p1 and p2 are even numbers, and r is an odd number; and the second encryption step comprises: establishing a pointer p1 to point to a z0.sub.i1 bit of the first ciphertext subset C.sub.0, and setting p1 as 8n−1 when p1 is 0; establishing a pointer p2 to point to a z0.sub.i1+1 bit of the second key subset P.sub.1, and setting p2 as 0 when p2 is 8n−1; establishing a pointer q to point to a y1.sub.j1 bit of the second key subset P.sub.1; establishing a pointer r to point to a z1.sub.k1 bit of the second ciphertext subset C.sub.1; and sequentially executing encryption, comprising judging whether *q or !(*q) is true, letting *r=*p2 and letting p2, q and r to increase progressively if *q or !(*q) is true, and letting *r=*p2 and letting q and r to increase progressively and p1 to decrease progressively if *q or !(*q) is not true, wherein, in the second encryption step, p1 and p2 are even numbers, and r is an odd number.
8. The method for sequentially encrypting and decrypting doubly linked lists based on double key stream ciphers according to claim 7, further comprising decryption methods corresponding to the double-key encryption methods, wherein the decryption methods comprise: retrieving initial values i.sub.0, i.sub.1, j.sub.0, j.sub.1, k.sub.0 and k.sub.1 for encryption; a first decryption method comprising a first decryption step and a second decryption step, wherein the first decryption step comprises: establishing a pointer p1 to point to a z0.sub.i1 bit of the first ciphertext set C.sub.0, and setting p1 as 8n−1 when p1 is 0; establishing a pointer p2 to point to a z0.sub.i1+1 bit of the first ciphertext set C.sub.0, and setting p2 as 0 when p2 is 8n−1; establishing a pointer q to point to a y1.sub.j1 bit of the set P.sub.1; establishing a pointer r to point to a bit z1.sub.k1 of the set C.sub.1; and sequentially executing decryption, comprising judging whether *q or !(*q) is true, letting *r=*p2 and letting p2, q and r to increase progressively if *q or !(*q) is true, and letting *r=*p1 and letting q and r to increase progressively and p1 to decrease progressively if *q or !(*q) is not true, wherein, in the first decryption step, p1 and p2 are even numbers, and r is an odd number; and the second decryption step comprises: establishing a pointer p1 to point to an x.sub.i0 bit of the plaintext set M, and setting p1 as 8n−1 when p1 is 0; establishing a pointer p2 to point to an x.sub.i0+1 bit of the plaintext set M, and setting p2 as 0 when p2 is 8n−1; establishing a pointer q to point to a y0.sub.j0 bit of the first key subset P.sub.0; establishing a pointer r to point to a z0.sub.k0 bit of the first ciphertext subset C.sub.0; and sequentially executing encryption, comprising judging whether *q or !(*q) is true, letting *r=*p2 and letting p2, q and r to increase progressively if *q or !(*q) is true, and letting *r=*p1 and letting q and r to increase progressively and p1 to decrease progressively if *q or !(*q) is not true, wherein, in the first encryption step, p1 and p2 are even numbers, and r is an odd number.
9. The method for sequentially encrypting and decrypting doubly linked lists based on double key stream ciphers according to claim 6, wherein the double-key encryption methods further comprise: a second encryption method, comprising a first encryption step and a second encryption step, wherein the first encryption step comprises: establishing a pointer p1 to point to an x.sub.i0 bit of the plaintext set M, and setting p1 as 8n−1 when p1 is 0; establishing a pointer p2 to point to an x.sub.i0+1 bit of the plaintext set M, and setting p2 as 0 when p2 is 8n−1; establishing a pointer q to point to a y0.sub.j0 bit of the first key subset P.sub.0; establishing a pointer r to point to a z0.sub.k0 bit of the first ciphertext subset C.sub.0; and sequentially executing encryption, comprising judging whether *q or !(*q) is true, letting *r=*p2 and letting p2, q and r to increase progressively if *q or !(*q) is true, and letting *r=*p1 and letting q and r to increase progressively and p1 to decrease progressively if *q or !(*q) is not true, wherein, in the first encryption step, p1 and p2 are even numbers, and r is an odd number; and the second encryption step comprises: establishing a pointer p1 to point to a z0.sub.i1 bit of the first ciphertext subset C.sub.0; establishing a pointer p2 to point to a y1.sub.j1 bit of the second key subset P.sub.1; establishing a pointer r1 to point to a z0.sub.k0 bit of the second key subset P.sub.1, and setting r1 as 8n−1 when r1 is 0; establishing a pointer r2 to point to a z1.sub.k1 bit of the first ciphertext set C.sub.0, and setting r2 as 0 when r2 is 8n−1; and sequentially executing encryption, comprising judging whether *q or !(*q) is true, letting *r2=*p and letting p, q and r2 to increase progressively if *q or !(*q) is true, and letting *r1=*p and letting p and q to increase progressively and r1 to decrease progressively if *q or !(*q) is not true, wherein, in the second encryption step, p is an odd number, and r1 and r2 is even numbers.
10. The method for sequentially encrypting and decrypting doubly linked lists based on double key stream ciphers according to claim 9, further comprising decryption methods corresponding to the double-key encryption methods, wherein the decryption methods comprise: retrieving initial values i.sub.0, i.sub.1, j.sub.0, j.sub.1, k.sub.0 and k.sub.1 for decryption; a second decryption method comprising a first decryption step and a second decryption step, wherein the first decryption step comprises: establishing a pointer p1 to point to a z0.sub.i1 bit of the first ciphertext subset C.sub.0; establishing a pointer p2 to point to a y1.sub.j1 bit of the second key subset P.sub.1; establishing a pointer r1 to point to a z0.sub.k0 bit of the second key subset P.sub.1, and setting r1 as 8n−1 when r1 is 0; establishing a pointer r2 to point to a z1.sub.k1 bit of the first ciphertext set C.sub.0, and setting r2 as 0 when r2 is 8n−1; and sequentially executing decryption, comprising judging whether *q or !(*q) is true, letting *r2=*p and letting p, q and r2 to increase progressively if *q or !(*q) is true, and letting *r1=*p and letting p and q to increase progressively and r1 to decrease progressively if *q or !(*q) is not true, wherein, in the second encryption step, p is an odd number, and r1 and r2 is even numbers; and the second decryption step comprises: establishing a pointer p1 to point to an x.sub.i0 bit of the plaintext set M, and setting p1 as 8n−1 when p1 is 0; establishing a pointer p2 to point to an xi0+1 bit of the plaintext set M, and setting p2 as 0 when p2 is 8n−1; establishing a pointer q to point to a y0.sub.j0 bit of the first key subset P.sub.0; establishing a pointer r to point to a z0.sub.k0 bit of the first ciphertext subset C.sub.0; and sequentially executing decryption, comprising judging whether *q or !(*q) is true, letting *r=*p2 and letting p2, q and r to increase progressively if *q or !(*q) is true, and letting *r=*p1 and letting q and r to increase progressively and p1 to decrease progressively if *q or !(*q) is not true, wherein, in the first decryption step, p1 and p2 are even numbers, and r is an odd number.
11. The method for sequentially encrypting and decrypting doubly linked lists based on double key stream ciphers according to claim 6, wherein the double-key encryption methods further comprise: a third encryption method, comprising a first encryption step and a second encryption step, wherein the first encryption step comprises: establishing a pointer p to point to a z0.sub.i1 bit of the first ciphertext subset C.sub.0; establishing a pointer q to point to a y1.sub.j1 bit of the second key subset P.sub.1; establishing a pointer r1 to point to a z0.sub.k0 bit of the second ciphertext subset and setting r1 as 8n−1 when r1 is 0; establishing a pointer r2 to point to a z0.sub.k0+1 bit of the second ciphertext set and setting r2 as 0 when r2 is 8n−1; and sequentially executing encryption, comprising judging whether *q or !(*q) is true, letting *r=*p2 and letting p2, q and r to increase progressively if *q or !(*q) is true, and letting *r=*p1 and letting q and r to increase progressively and p1 to decrease progressively if *q or !(*q) is not true, wherein, in the first encryption step, p is an odd number, and r1 and r2 is even numbers; and the second encryption step comprises: establishing a pointer p1 to point to a z0.sub.i1 bit of the first ciphertext set C.sub.1, and setting p1 as 8n−1 when p1 is 0; establishing a pointer p2 to point to a z0.sub.i1+1 bit of the second key set C.sub.1, and setting p2 as 0 when p2 is 8n−1; establishing a pointer q to point to a y0.sub.j0 bit of the first key subset P.sub.0; establishing a pointer r to point to a z1.sub.k1 bit of the first ciphertext subset C.sub.0; and sequentially executing encryption, comprising judging whether *q or !(*q) is true, letting *r=*p2 and letting p2, q and r to increase progressively if *q or !(*q) is true, and letting *r=*p2 and letting q and r to increase progressively and p1 to decrease progressively if *q or !(*q) is not true, wherein, in the second encryption step, p1 and p2 are even numbers, and r is an odd number.
12. The method for sequentially encrypting and decrypting doubly linked lists based on double key stream ciphers according to claim 11, further comprising decryption methods corresponding to the double-key decryption methods, wherein the decryption methods comprise: retrieving initial values i.sub.0, i.sub.1, j.sub.0, j.sub.1, k.sub.0 and k.sub.1 for decryption; a third decryption method comprising a first decryption step and a second decryption step, wherein the first decryption step comprises: establishing a pointer p1 to point to a z0.sub.i1 bit of the first ciphertext set C.sub.1, and setting p1 as 8n−1 when p1 is 0; establishing a pointer p2 to point to a z0.sub.i1+1 bit of the second key set C.sub.1, and setting p2 as 0 when p2 is 8n−1; establishing a pointer q to point to a y0.sub.j0 bit of the first key subset P.sub.0; establishing a pointer r to point to a z1.sub.k1 bit of the first ciphertext subset C.sub.0; and sequentially executing decryption, comprising judging whether *q or !(*q) is true, letting *r=*p2 and letting p2, q and r to increase progressively if *q or !(*q) is true, and letting *r=*p2 and letting q and r to increase progressively and p1 to decrease progressively if *q or !(*q) is not true, wherein, in the second decryption step, p1 and p2 are even numbers, and r is an odd number; and the second decryption step comprises: establishing a pointer p to point to a z0.sub.i1 bit of the first ciphertext subset C.sub.0; establishing a pointer q to point to a y1.sub.j1 bit of the second key subset P.sub.1; establishing a pointer r1 to point to a z0.sub.k0 bit of the second ciphertext subset and setting r1 as 8n−1 when r1 is 0; establishing a pointer r2 to point to a z0.sub.k0+1 bit of the second ciphertext set and setting r2 as 0 when r2 is 8n−1; and sequentially executing decryption, comprising judging whether *q or !(*q) is true, letting *r=*p2 and letting p2, q and r to increase progressively if *q or !(*q) is true, and letting *r=*p1 and letting q and r to increase progressively and p1 to decrease progressively if *q or !(*q) is not true, wherein, in the first decryption step, p is an odd number, and r1 and r2 is even numbers.
13. The method for sequentially encrypting and decrypting doubly linked lists based on double key stream ciphers according to claim 6, wherein the double-key encryption methods further comprise: a fourth encryption method, comprising a first encryption step and a second encryption step, wherein the first encryption step comprises: establishing a pointer p to point to an x.sub.i0 bit of the plaintext set M; establishing a pointer q to point to a y0.sub.j0 bit of the second key subset P.sub.0; establishing a pointer r1 to point to a z0.sub.k0 bit of the second ciphertext subset C.sub.0, and setting r1 as 8n−1 when r1 is 0; establishing a pointer r2 to point to a z0.sub.k0+1 bit of the second ciphertext set C.sub.0, and setting r2 as 0 when r2 is 8n−1; and sequentially executing encryption, comprising judging whether *q or !(*q) is true, letting *r=*p2 and letting p2, q and r to increase progressively if *q or !(*q) is true, and letting *r=*p1 and letting q and r to increase progressively and p1 to decrease progressively if *q or !(*q) is not true, wherein, in the second encryption step, p is an odd number, and r1 and r2 is even numbers; and the second encryption step comprises: establishing a pointer p to point to a z0.sub.i1 bit of the plaintext set C.sub.0; establishing a pointer q to point to a y1.sub.j1 bit of the second key subset P.sub.1; establishing a pointer r1 to point to a z1.sub.k1 bit of the second ciphertext subset and setting r1 as 8n−1 when r1 is 0; establishing a pointer r2 to point to a z1.sub.k1+1 bit of the second ciphertext set and setting r1 as 0 when r2 is 8n−1; and sequentially executing encryption, comprising judging whether *q or !(*q) is true, letting *r=*p2 and letting p2, q and r to increase progressively if *q or !(*q) is true, and letting *r=*p2 and letting q and r to increase progressively and p1 to decrease progressively if *q or !(*q) is not true, wherein, in the second encryption step, p is an odd number, and r1 and r2 is even numbers.
14. The method for sequentially encrypting and decrypting doubly linked lists based on double key stream ciphers according to claim 13, further comprising decryption methods corresponding to the double-key decryption methods, wherein the decryption methods comprise: retrieving initial values i.sub.0, i.sub.1, j.sub.0, j.sub.1, k.sub.0 and k.sub.1 for decryption; a fourth decryption method comprising a first decryption step and a second decryption step, wherein the first decryption step comprises: establishing a pointer p to point to a z0.sub.i1 bit of the plaintext set C.sub.0; establishing a pointer q to point to a y1.sub.j1 bit of the second key subset P.sub.1; establishing a pointer r1 to point to a z1.sub.k1 bit of the second ciphertext subset and setting r1 as 8n−1 when r1 is 0; establishing a pointer r2 to point to a z1k1+1 bit of the second ciphertext set and setting r1 as 0 when r2 is 8n−1; and sequentially executing decryption, comprising judging whether *q or !(*q) is true, letting *r=*p2 and letting p2, q and r to increase progressively if *q or !(*q) is true, and letting *r=*p2 and letting q and r to increase progressively and p1 to decrease progressively if *q or !(*q) is not true, wherein, in the second decryption step, p is an odd number, and r1 and r2 is even numbers; and the second decryption step comprises: establishing a pointer p to point to an x.sub.i0 bit of the plaintext set M; establishing a pointer q to point to a y0.sub.j0 bit of the second key subset P.sub.0; establishing a pointer r1 to point to a z0.sub.k0 bit of the second ciphertext subset C.sub.0, and setting r1 as 8n−1 when r1 is 0; establishing a pointer r2 to point to a z0.sub.k0+1 bit of the second ciphertext set C.sub.0, and setting r2 as 0 when r2 is 8n−1; and sequentially executing decryption, comprising judging whether *q or !(*q) is true, letting *r=*p2 and letting p2, q and r to increase progressively if *q or !(*q) is true, and letting *r=*p1 and letting q and r to increase progressively and p1 to decrease progressively if *q or !(*q) is not true, wherein, in the first decryption step, p is an odd number, and r1 and r2 is even numbers.
15. The method for sequentially encrypting and decrypting doubly linked lists based on double key stream ciphers according to claim 1, wherein the method further comprises: encryption step of using the plaintext set Mas an initial value and performing iterative encryption to obtain a ciphertext set C comprises four failed encryption methods, eight half-encryption methods and four double-key encryption methods, all the failed encryption methods and the half-encryption methods are discarded, and the four double-key encryption method are executed, wherein the four double-key encryption methods comprise sequentially encrypting according to a pointer of a circular linked list.
16. The method for sequentially encrypting and decrypting doubly linked lists based on double key stream ciphers according to claim 1, wherein the algorithm set A comprises at least one pair of encryption algorithm and corresponding decryption algorithm; and, the number of elements in the algorithm set A is denoted as sum(A), and sum(A) mod 2=0.
17. The method for sequentially encrypting and decrypting doubly linked lists based on double key stream ciphers according to claim 1, wherein a key file corresponding to the key set P comprises, but not limited to: a piece of audio, a video, a picture, an image, a graph, a pseudorandom code and a chaotic value.
Description
BRIEF DESCRIPTION OF THE DRAWINGS
(1)
(2)
(3)
(4)
(5)
(6)
DETAILED DESCRIPTION OF THE DISCLOSURE
(7) To make the objectives, technical solutions and advantages of the disclosure clearer, the disclosure will be further described below in details by specific embodiments with reference to the accompanying drawings. The method for sequentially encrypting and decrypting doubly linked lists based on double key stream ciphers in the disclosure is suitable for encryption and decryption.
(8)
(9) In this method, in order to realize decipherment, the following four conditions must be satisfied: 1. an algorithm program; 2. a ciphertext file (one cipher corresponding to one key); 3. a key file 1 (also referred to as a key); 4. a key file 2 (also referred to as a key). However, it is impossible to obtain the four files simultaneously. The method specifically includes definition, encryption and decryption.
(10) The technical solutions of the disclosure further disclose the following technical features: quadruple sets of encryption system (M,C,P,A), and the sets M, C, P and A have the following characteristics.
(11) The information {0,1} in each set is a byte character set consisting of binary code elements, which is applied to ASCII codes.
(12) The plaintext set M has n bytes, and the number of code elements is denoted as sum(M)=8n, then sum(M) mod 8=0.
(13) For the number of elements in the ciphertext set C, c.sub.1, c.sub.21, . . . , c.sub.jc1, c2, c3, . . . , cr are obtained by r iterations of the set M used as initial values. For a subset c.sub.j (j=1, 2, 3, . . . , r), the number of code elements is denoted as sum(c.sub.j), then sum(c.sub.j) mod 8=0. If the number of bytes in the subset c.sub.j is assumed as m, then:
(14) when m<n, it is referred to as compressed encryption;
(15) when m=n, it is referred to as one-to-one encryption or equidensite encryption; and
(16) when m>n, it is referred to as redundant encryption.
(17) The number of code elements in the key set P is denoted as sum(P), then sum(P) mod 8=0. If the number of bytes in the set P is assumed as m, then m≤n. The number of bytes in the set P is preliminarily defined as 1. The encryption and the decryption share the key set P. There are no codes 0x00 and 0xff in this set.
(18) The algorithms in the algorithm set A have feasibility, definiteness, finiteness, input uniqueness and output uniqueness.
(19) The algorithm set A is a set of computer-executable codes, also referred to as a set of functions. If the number of elements in the set A is denoted as sum(A), then sum(A) mod 2=0.
(20) The algorithm set is characterized in that: if there is an algorithm a for encrypting c.sub.i into c.sub.j, there must be an algorithm b for reverting c.sub.j to c.sub.i, that is, there is an inverse algorithm or a reverting algorithm.
(2) Encryption
(21) 1. A plaintext set is set as follows: M={x.sub.0x.sub.1 . . . x.sub.8n−1}, where x.sub.i={0,1} and i satisfies the condition of 0≤i≤8n−1. This set is an ordered set. And n represents the number of bytes of the plaintext. 2. Key sets are set as follows: P.sub.0={y0.sub.0y0.sub.1 . . . y0.sub.8n−1}, where y0.sub.j0={0,1}, j0 satisfies the condition of 0≤j0≤8n−1, and this set is an ordered set; and P.sub.1={y1.sub.0y1.sub.1 . . . y1.sub.8n−1}, where y1.sub.j1={0,1}, j1 satisfies the condition of 0≤j1≤8n−1, and this set is an ordered set. 3. Ciphertext sets are set as follows: C.sub.0={z0.sub.0z0.sub.1 . . . z0.sub.8n−1}, where z0.sub.k0={0,1}, k0 satisfies the condition of 0≤k0≤8n−1, and this set is an ordered set; and C.sub.1={z1.sub.0z.sub.11 . . . z1.sub.8n−1}, where z1.sub.k1={0,1}, k1 satisfies the condition of 0≤k1≤8n−1, and this set is an ordered set. 4. The set M is regarded as a circular linked list, and x.sub.n−1 is followed by x.sub.0. 5. The sets P.sub.0 and P.sub.1 are regarded as circular linked lists; for P.sub.0, y0.sub.8n−1 is followed by y0.sub.0; and for P.sub.1, y1.sub.8n−1 is followed by y1.sub.0. 6. The sets C.sub.0 and C.sub.1 are regarded as circular linked lists; for C.sub.0, z0.sub.8n−1 is followed by z0.sub.0; and for C.sub.1, z1.sub.8n−1 is followed by z1.sub.0. 7. Any initial value i.sub.0 (where 0<=i.sub.0<=8n−1) is used as an initial value of the set M, and this value is reserved. Any initial value i.sub.1 (where 0<=i.sub.1<=8n−1) is used as an initial value of the set C.sub.0, and this value is reserved. Any initial value j.sub.0 (where 0<=j.sub.0<=8n−1) is used as an initial value of the set P.sub.0, and this value is reserved. Any initial value j.sub.1 (where 0<=j.sub.1<=8n−1) is used as an initial value of the set P.sub.1, and this value is reserved. Any initial value k.sub.0 (where 0<=k.sub.0<=8n−1) is used as an initial value of the set C.sub.0, and this value is reserved. Any initial value k1 (where 0<=k.sub.1<=8n−1) is used as an initial value of the set C.sub.1, and this value is reserved. In this encryption method, there are 16 specific encryption methods, wherein there are four failed encryption methods. 8. head=0, tail=8*n−1. 9. In this encryption method, there are 16 specific encryption methods, wherein there are four failed encryption methods, and eight half-encryption methods which are equivalent to these encryption methods performed by one key, so these encryption methods are discarded. Therefore, the double-key encryption can be realized by only four encryption methods.
(22)
(23) First encryption (p is an even number and r is an odd number) 1. A pointer p1 is established to point to an x.sub.i0 bit of the set M. When p1.fwdarw.head, it is set that p1.fwdarw.tail. 2. A pointer p2 is established to point to an x.sub.i0+1 bit of the set M. When p2.fwdarw.tail, it is set that p1.fwdarw.head. 3. A pointer q is established to point to a y0.sub.j0 bit of the set P.sub.0. 4. A pointer r is established to point to a z0.sub.k0 bit of the set C.sub.0. 5. Encryption starts. If it is determined that *q is true, *r=*p2, p2++, q++ and r++; or otherwise, *r=*p1, q++, r++ and p1−−. 6. It is also possible that, if it is determined that !(*q) is true, r=*p2, p2++, q++ and r++; or otherwise, *r=*p1, q++, r++ and p1−−.
(24) Second encryption (p is an even number and r is an odd number) 1. A pointer p1 is established to point to a z0.sub.i1 bit of the set C.sub.0. When p1.fwdarw.head, it is set that p1.fwdarw.tail. 2. A pointer p2 is established to point to a z0.sub.i1+1 bit of the set C.sub.0. When p2.fwdarw.tail, it is set that p1.fwdarw.head. 3. A pointer q is established to point to a y1.sub.j1 bit of the set P.sub.1. 4. A pointer r is established to point to a z1.sub.k1 bit of the set C.sub.1. 5. Encryption starts. If it is determined that *q is true, *r=*p2, p2++, q++ and r++; or otherwise, *r=*p1, q++, r++ and p1−−. 6. It is also possible that, if it is determined that !(*q) is true, *r=*p2 p2++, q++ and r++; or otherwise, *r=*p1, q++, r++ and p1−−.
(25) Decryption method 1 (p is an even number and r is an odd number, or p is an even number and r is an odd number) The initial values i.sub.0, i.sub.1, j.sub.0, j.sub.1, k.sub.0 and k.sub.1 for encryption are retrieved.
(26) First decryption (p is an even number and r is an odd number) 1. A pointer p1 is established to point to a z0.sub.i1 bit of the set C.sub.0. When p1.fwdarw.head, it is set that p1.fwdarw.tail. 2. A pointer p2 is established to point to a z0.sub.i1+1 bit of the set C.sub.0. When p2.fwdarw.tail, it is set that p1.fwdarw.head. 3. A pointer q is established to point to a y1.sub.j1 bit of the set P.sub.1. 4. A pointer r is established to point to a z1.sub.k1 bit of the set C.sub.1. 5. Encryption starts. If it is determined that *q is true, *p2=*r, p2++, q++ and r++; or otherwise, *p1=*r, q++, r++ and p1++. 6. It is also possible that, if it is determined that !(*q) is true, *p2=*r, p2++, q++ and r++; or otherwise, *p1=*r, q++, r++ and p1−−.
(27) Second decryption (p is an even number and r is an odd number) 1. A pointer p1 is established to point to an x.sub.i0 bit of the set M. When p1.fwdarw.head, it is set that p1.fwdarw.tail. 2. A pointer p2 is established to point to an x.sub.i0+1 bit of the set M. When p2.fwdarw.tail, it is set that p1.fwdarw.head. 3. A pointer q is established to point to a y0.sub.j0 bit of the set P.sub.0. 4. A pointer r is established to point to a z0.sub.k0 bit of the set C.sub.0. 5. Encryption starts. If it is determined that *q is true, *p2=*r, p2++, q++ and r++; or otherwise, *p1=*r, q++, r++ and p1−−. 6. It is also possible that, if it is determined that !(*q) is true, *p2=*r, p2++, q++ and r++; or otherwise, *p1=*r, q++, r++ and p1−−.
(28)
(29) First encryption (p is an even number and r is an odd number) 1. A pointer p1 is established to point to an x.sub.i0 bit of the set M. When p1.fwdarw.head, it is set that p1.fwdarw.tail. 2. A pointer p2 is established to point to an x.sub.i0+1 bit of the set M. When p2.fwdarw.tail, it is set that p1.fwdarw.head. 3. A pointer q is established to point to a y0.sub.j0 bit of the set P.sub.0. 4. A pointer r is established to point to a z0.sub.k0 bit of the set C.sub.0. 5. Encryption starts. If it is determined *q is true, *r=*p2, p2++, q++ and r++; or otherwise, *r=*p1, q++, r++ and p1−−. 6. It is also possible that, if it is determined that !(*q) is true, *r=*p2, p2++, q++ and r++; or otherwise, *r=*p1, q++, r++ and p1−−.
(30) Second encryption (p is an odd number and r is an even number) 1. A pointer p is established to point to a z0.sub.i1 bit of the set C.sub.0. 2. A pointer q is established to point to a y1.sub.j1 bit of the set P.sub.1. 3. A pointer r1 is established to point to a z1.sub.k1 bit of the set C.sub.1. When r1.fwdarw.head, it is set that r1.fwdarw.tail. 4. A pointer r2 is established to point to a z1.sub.k1+1 bit of the set C.sub.1. When r2.fwdarw.tail, it is set that r1.fwdarw.head. 5. Encryption starts. If it is determined that *q is true, *r2=*p, p++, q++ and r2++; or otherwise, *r1=*p, p++, q++ and r1−−. 6. It is also possible that, if it is determined that !(*q) is true, *r2=*p, p++, q++ and r2++; or otherwise, *r1=*p, p++, q++ and r1−−.
(31) Decryption method 2 (p is an even number and r is an odd number, or p is an odd number and r is an even number)
(32) First decryption (p is an odd number and r is an even number) 1. A pointer p is established to point to a z0.sub.i1 bit of the set C.sub.0. 2. A pointer q is established to point to a y1.sub.j1 bit of the set P.sub.1. 3. A pointer r1 is established to point to a z1.sub.k1 bit of the set C.sub.1. When r1.fwdarw.head, it is set that r1.fwdarw.tail. 4. A pointer r2 is established to point to a z1.sub.k1+1 bit of the set C.sub.1. When r2.fwdarw.tail, it is set that r1.fwdarw.head. 5. Encryption starts. If it is determined that *q is true, *p=*r2, p++, q++ and r2++; or otherwise, *p=*r1, p++, q++ and r1−−. 6. It is also possible that, if it is determined that !(*q) is true, *p=*r2, p++, q++ and r2++; or otherwise, p=*r1, p++, q++ and r1−−.
(33) Second decryption (p is an even number and r is an odd number) 1. A pointer p1 is established to point to an x.sub.i0 bit of the set M. When p1.fwdarw.head, it is set that p1.fwdarw.tail. 2. A pointer p2 is established to point to an x.sub.i0+1 bit of the set M. When p2.fwdarw.tail, it is set that p1.fwdarw.head. 3. A pointer q is established to point to a y0.sub.j0 bit of the set P.sub.0. 4. A pointer r is established to point to a z0.sub.k0 bit of the set C.sub.0. 5. Encryption starts. If it is determined that *q is true, *p2=*r, p2++, q++ and r++; or otherwise, *p1=, q++, r++ and p1−−. 6. It is also possible that, if it is determined that !(*q) is true, *p2=*r, p2++, q++ and r++; or otherwise, *p1=*r, q++, r++ and p1−−.
(34)
(35) First encryption (p is an odd number and r is an even number) 1. A pointer p is established to point to a z0.sub.i1 bit of the set C.sub.0. 2. A pointer q is established to point to a y1.sub.j1 bit of the set P.sub.1. 3. A pointer r1 is established to point to a z0.sub.k0 bit of the set C.sub.1. When r1.fwdarw.head, it is set that r1.fwdarw.tail. 4. A pointer r2 is established to point to a z0.sub.k0+1 bit of the set C.sub.1. When r2.fwdarw.tail, it is set that r1.fwdarw.head. 5. Encryption starts. If it is determined that *q is true, *r2=*p, p++, q++ and r2++; or otherwise, *r1=*p, p++, q++ and r1−−. 6. It is also possible that, if it is determined that !(*q) is true, *r2=*p, p++, q++ and r2++; or otherwise, *r1=*p, p++, q++ and r1−−.
(36) Second encryption (p is an even number and r is an odd number) 1. A pointer p1 is established to point to a z0.sub.i1 bit of the set C.sub.1. When p1.fwdarw.head, it is set that p1.fwdarw.tail. 2. A pointer p2 is established to point to a z0.sub.i1+1 bit of the set C.sub.1. When p2.fwdarw.tail, it is set that p1.fwdarw.head. 3. A pointer q is established to point to a y0.sub.j0 bit of the set P.sub.0. 4. A pointer r is established to point to a z1.sub.k1 bit of the set C.sub.0. 5. Encryption starts. If it is determined that *q is true, *r=*p2, p2++, q++ and r++; or otherwise, *r=*p1, q++, r++ and p1−−. 6. It is also possible that, if it is determined that !(*q) is true, *r=*p2, p2++, q++ and r++; or otherwise, *r=*p1, q++, r++ and p1−−.
(37) Decryption method 3 (p is an odd number and r is an even number, p is an even number and r is an odd number)
(38) First decryption (p is an even number and r is an odd number) 1. A pointer p1 is established to point to a z0.sub.i1 bit of the set C.sub.1. When p1.fwdarw.head, it is set that p1.fwdarw.tail. 2. A pointer p2 is established to point to a z0.sub.i1+1 bit of the set C.sub.1. When p2.fwdarw.tail, it is set that p1.fwdarw.head. 3. A pointer q is established to point to a y0.sub.j0 bit of the set P.sub.0. 4. A pointer r is established to point to a z1.sub.k1 bit of the set C.sub.0. 5. Encryption starts. If it is determined that *q is true, *p2=*r, p2++, q++ and r++; or otherwise, *p1=*r, q++, r++ and p1−−. 6. It is also possible that, if it is determined that !(*q) is true, *p2=*r, p2++, q++ and r++; or otherwise, *p1=*r, q++, r++ and p1−−.
(39) Second decryption (p is an odd number and r is an even number) 1. A pointer p is established to point to a z0.sub.i1 bit of the set C.sub.0. 2. A pointer q is established to point to a y1.sub.j1 bit of the set P.sub.1. 3. A pointer r1 is established to point to a z0.sub.k0 bit of the set C.sub.1. When r1.fwdarw.head, it is set that r1.fwdarw.tail. 4. A pointer r2 is established to point to a z0.sub.k0+1 bit of the set C.sub.1. When r2.fwdarw.tail, it is set that r1.fwdarw.head. 5. Encryption starts. If it is determined that *q is true, *p=*r2, p++, q++ and r2++; or otherwise, *p=*r1, p++, q++ and r1−−. 6. It is also possible that, if it is determined that !(*q) is true, *p=*r2, p++, q++ and r2++; or otherwise, *p=*r1, p++, q++ and r1−−.
(40)
(41) First encryption (p is an odd number and r is an even number) 1. A pointer p is established to point to an x.sub.i0 bit of the set M. 2. A pointer q is established to point to a y0.sub.j0 bit of the set P.sub.0. 3. A pointer r1 is established to point to a z0.sub.k0 bit of the set C.sub.0. When r1.fwdarw.head, it is set that r1.fwdarw.tail. 4. A pointer r2 is established to point to a z0.sub.k0+1 bit of the set C.sub.0. When r2.fwdarw.tail, it is set that r1.fwdarw.head. 5. Encryption starts. If it is determined that *q is true, *r=*p2, p2++, q++ and r++; or otherwise, *r=*p1, q++, r++ and p1−−. 6. It is also possible that, if it is determined that !(*q) is true, *r=*p2, p2++, q++ and r++; or otherwise, *r=*p1, q++, r++ and p1−−.
(42) Second encryption (p is an odd number and r is an even number) 1. A pointer p is established to point to a z0.sub.i1 bit of the set C.sub.0. 2. A pointer q is established to point to a y1.sub.j1 bit of the set P.sub.1. 3. A pointer r1 is established to point to a z1.sub.k1 bit of the set C.sub.1. When r1.fwdarw.head, it is set that r1.fwdarw.tail. 4. A pointer r2 is established to point to a z1.sub.k1+1 bit of the set C.sub.1. When r2.fwdarw.tail, it is set that r1.fwdarw.head. 5. Encryption starts. If it is determined that *q is true, *r=*p2, p2++, q++ and r++; or otherwise, *r=*p1, q++, r++ and p1−−. 6. It is also possible that, if it is determined that !(*q) is true, *r=*p2, p2++, q++ and r++; or otherwise, *r=*p1, q++, r++ and p1−−.
(43) Decryption method 4 (p is an odd number and r is an even number, p is an odd number and r is an even number)
(44) First decryption (p is an odd number and r is an even number) 1. A pointer p is established to point to a z0.sub.i1 bit of the set C.sub.0. 2. A pointer q is established to point to a y1.sub.j1 bit of the set P.sub.1. 3. A pointer r1 is established to point to a z1.sub.k1 bit of the set C.sub.1. When r1.fwdarw.head, it is set that r1.fwdarw.tail. 4. A pointer r2 is established to point to a z1.sub.k1+1 bit of the set C.sub.1. When r2.fwdarw.tail, it is set that r1.fwdarw.head. 5. Encryption starts. If it is determined that *q is true, *p2=*r, p2++, q++ and r++; or otherwise, *p1=*r, q++, r++ and p1−−. 6. It is also possible that, if it is determined that !(*q) is true, *p2=*r, p2++, q++ and r++; or otherwise, *p1=*r, q++, r++ and p1−−.
(45) Second decryption (p is an odd number and r is an even number) 1. A pointer p is established to point to an x.sub.i0 bit of the set M. 2. A pointer q is established to point to a y0.sub.j0 bit of the set P.sub.0. 3. A pointer r1 is established to point to a z0.sub.k0 bit of the set C.sub.0. When r1.fwdarw.head, it is set that r1.fwdarw.tail. 4. A pointer r2 is established to point to a z0.sub.k0+1 bit of the set C.sub.0. When r2.fwdarw.tail, it is set that r1.fwdarw.head. 5. Encryption starts. If it is determined that *q is true, *p2=*r, p2++, q++ and r++; or otherwise, *p1=*r, q++, r++ and p1−−. 6. It is also possible that, if it is determined that !(*q) is true, *p2=*r, p2++, q++ and r++; or otherwise, *p1=*r, q++, r++ and p1−−.
(46) Compared with the prior art, this patented technology does not require any dedicated computer hardware or dedicated electronic logic device during the encryption of stream ciphers. The design of logic circuits is also not required. The feedback problems and feedback algorithms of chaotic signals are not involved. The encryption and decryption process of stream ciphers is completely solved by computer software programming. In this way, the requirements for the external conditions of the encryption and decryption of plain codes are very low. As long as there is a networked computer, encryption and decryption can be carried out. This patented technology is very high in applicability.
(47) In this encryption technology, the longer the content of a protocol file (key) is, the more difficult the decryption is. In the existing technical specification, the length is 32 bytes. The length can also be increased to 64 bytes or 128 bytes. Or even, the length is longer.
(48) Software products developed by this technology can be applied to the information transmission for the diplomatic department and the information transmission for the military department, and also have good effects on remote control and image transmission encryption. Due to the large difficulty of decipherment, it is almost impossible to decipher during the secrecy process of plain codes.
(49) In the encryption process described above, only one byte is used as a reference string. Such encryption is easy to decipher. However, when the reference string has 8 bytes, 16 bytes, 32 bytes or even 64 bytes, the difficulty of decipherment can be imagined. The length of the reference string can be the same as the length of bytes of the plaintext. Even for a single byte, the difficulty of decipherment is also considerably large if multiple iterations could be performed.
(50) Due to the development of the modern communication technology, it is no longer a problem to add a certain amount of transmission codes.
(51) In this method, encryption is realized by double keys, and the keys can be managed by different persons, so it is ensured that the plaintext is securer.
(52) With reference to
Description
(53) 1. M={“”} represents a plaintext, i.e., a text to be encrypted. {0xD6D0 0xB9FA} is machine codes of the two Chinese characters “
”, i.e., an input sequence to be encrypted. 2. P0={“
”} represents a key. {0xC3B5 0xB9E5} is machine codes of the two Chinese characters “
”. 3. P1={“
”} represents another key. {0xC4B5 0xB5A4} is machine codes of the two Chinese characters “
”. 4. i.sub.0=5, i.sub.1=3, j.sub.0=4, j.sub.1=6, k.sub.0=2 and k.sub.1=1 are selected as initial values. 5. The encryption method 1 is employed, and a ciphertext C0={0x6E5B4 0Xf934} is obtained by the first encryption. 6. The encryption method 1 is employed, and a ciphertext C1={0xa2f7,0x623f} is obtained by the second encryption.
Decryption Process
Description
(54) 1. The initial values i.sub.0=5, i.sub.1=3, j.sub.0=4, j.sub.1=6, k.sub.0=2 and k.sub.1=1 are retrieved. 2. C1={0xa2f7,0x623f} represents a ciphertext. 3. P1={“”}={0xC4B5 0xB5A4} is machine codes of the two Chinese characters “
”, i.e., the second key. 4. The firstly encrypted ciphertext C0={0x6E5B, 0Xf934} is obtained by the key P1 and the decryption method 1. 5. The firstly encrypted ciphertext C0={0x6E5B, 0Xf934} is reverted by using the P0={“
”}={0xC3B5 0xB9E5} to obtain a plaintext M={“
”}={0xD6D0 0xB9FA}.
Encryption and Decryption Algorithms
(55) 1. A plaintext file m={“”}={0xD6 0xD0 0xB9 0xFA}=(1101 0110 1101 0000 1011 1000 1111 1010).sub.2.
(56) A key file P0={“”}={0xC3 0xB5 0xB9 0xE5}=(1100 0011 1011 0101 1011 1000 1110 0101).sub.2.
(57) A key file P1={“”}={0xC4 0xB5 0xB5 0xA4}=(1100 0100 1011 0101 1011 0101 1010 0100).sub.2. 2. A character pointer char *p_str_M is established.
(58) A character pointer char *p_str_P0 is established.
(59) A character pointer char*p_str_P1 is established.
(60) A character pointer char*p_str_C0 is established.
(61) A character pointer char*p_str_C1 is established. 3. The plaintext file M is opened, and the number of bytes in the plaintext file M is counted and stored in the n. 4. A plaintext storage space p_str_M=(char*)malloc(n*sizeof(char)) is allocated.
(62) A key storage space p_str_P0=(char*)malloc(n*sizeof(char)) is allocated.
(63) A key storage space p_str_P1=(char*)malloc(n*sizeof(char)) is allocated.
(64) A ciphertext storage space p_str_C0=(char*)malloc(n*sizeof(char)) is allocated.
(65) A ciphertext storage space p_str_C1=(char*)malloc(n*sizeof(char)) is allocated. 5. The plaintext file M is read into the space pointed by p_str_M. The p_str_M points to the first address of this space.
(66) The key file P0 is read into the space pointed by p_str_P0. The p_str_P0 points to the first address of this space.
(67) The key file P1 is read into the space pointed by p_str_P1. The p_str_P1 points to the first address of this space.
(68) The p_str_C0 points to the first address of the space for the firstly encrypted ciphertext.
(69) The p_str_C1 points to the first address of the space for the secondly encrypted ciphertext. 6. The initial value i0=5 is fetched, i.e., starting from the (x0.sub.5).sup.th bit of the space pointed by the p_str_M. This value is reserved. The reference is made to
(70) The initial value i1=3 is fetched, i.e., starting from the (z0.sub.3).sup.th bit of the space pointed by the p_str_C0. This value is reserved. The reference is made to
(71) The initial value j0=4 is fetched, i.e., starting from the (y0.sub.4).sup.th bit of the space pointed by the p_str_P0. This value is reserved. The reference is made to
(72) The initial value j1=6 is fetched, i.e., starting from the (y1.sub.6).sup.th bit of the space pointed by the p_str_P1. This value is reserved. The reference is made to
(73) The initial value k0=2 is fetched, i.e., starting from the (z0.sub.2).sup.th bit of the space pointed by the p_str_C0. This value is reserved. The reference is made to
(74) The initial value k1=1 is fetched, i.e., starting from the (z0.sub.2).sup.th bit of the space pointed by the p_str_C0. This value is reserved. The reference is made to
(75) int string_read_bit(char*p, int i).
(76) This function returns the value (0,1) of the i.sup.th bit of the character string pointed by the p. 8. The following function is established:
(77) void string_write_bit(char*p,int I,int j).
(78) This function writes the i.sup.th bit of the character string pointed by the p into the value (0,1) of j. 9. The encryption method 1 is taken as example.
(79) TABLE-US-00001 First encryption Variables p1 and p2 are established, where p1=i0 and p2=i0+1. Variables q and r are established, where q=j0 and r=k0. for(i=0;i<8*n;i++) {x = string_read_bit(p_str_P0,q); if(x) y = string_read_bit(p_str_M,p2); else y = string_read_bit(p_str_M,p1); string_write_bit(p_str_C0,r,y); q=q+1; if(q>8*n−1) q=0; r=r+1; if(r>8*n−1) r= 0; p1=p1−1; if(p1 <0) p1=2*n−1; p2=p2+1; if(p2>8*n−1) p2=0; } Second encryption Variables p1 and p2 are established, where p1=i1 and p2=i1+1. Variables q and r are established, where q=j1 and r=k1. for(i=0;i<8*n;i++) {x = string_read_bit(p_str_P1 ,q); if(x) y = string_read_bit(p_str_C0,p2); else y = string_read_bit(p_str_C0,p1); string_write_bit(p_str_C1,r,y); q=q+1; if(q>8*n−1) q = 0; r=r+1; if(r>8*n−1) r=0; p1=p1−1; if(p1<0) p1=2*n−1; p2=p2+1; if(p2>8*n−1) p2=0; } 10. The p_str_C points to the first address of the allocated ciphertext storage space, and n bytes in this space are written into the ciphertext file C. 11. The ciphertext file C={“”}={0x3bea 0xf56d}=(0011 1011 1110 1010 1111 0101 0110 1101).sub.2 is obtained. 12. The above process can refer to
Decryption Process
(80) The encryption method 1 is taken as example.
(81) TABLE-US-00002 First decryption Variables p1 and p2 are established, where p1=i1 and p2=i1+1. Variables q and r are established, where q=j1 and r=k1. for (i=0;i<8*n;i++) {x = string_read_bit(p_str_P1,q); y = string_read_bit(p_str_C1,r); if(x) string_write_bit(p_str_C0,p2,y); else string_write_bit(p_str_C0,p1,y); q=q+1;if(q>8*n−1) q = 0; r=r+1;if(r>8*n−1) r=0; p1=p1−1;if(p1<0) p1=2*n−1; p2=p2+1;if(p2>8*n−1) p2=0; } Second decryption Variables p1 and p2 are established, where p1=i0 and p2=i0+1. Variables q and r are established, where q=j0 and r=k0. for(i=0;i<8*n;i++) {x = string_read_bit(p_str_P0,q); y = string_read_bit(p_str_C0,r); if(x) string_write_bit(p_str_M,p2,y); else string_write_bit(p_str_M,p1,y); q=q+1;if(q>8*n−1) q=0; r=r+1;if(r>8*n−1) r=0; p1=p1−1;if(p1<0) p1=2*n−1; p2=p2+1;if(p2>8*n−1) p2=0; } Application function source program int read_string_bit(char *p_str,int n) {char ch0; int i,byte,bit; byte=n/8;bit=n%8; for(i=0;i<byte;i++) p_str++; ch0=*p_str; ch0=ch0<<bit;ch0=ch0&(0x80); if(ch0) return 1; else return 0; } void write_string_bit(char *p_str,int n,int boolean) {char ch0; int i,byte,bit; byte=n/8; bit=n%8; for(i=0;i<byte;i++) p_str++; ch0=*p_str; switch(bit) { case 0:{ch0=ch0&0x7f;if(boolean)ch0=ch0|0x80;break;} case 1:{ch0=ch0&0xbf;if(boolean)ch0=ch0|0x40;break;} case 2:{ch0=ch0&0xdf;if(boolean)ch0=ch0|0x20;break;} case 3:{ch0=ch0&0xef;if(boolean)ch0=ch0|0x10;break;} case 4:{ch0=ch0&0xf7;if(boolean)ch0=ch0|0x08;break;} case 5:{ch0=ch0&0xfb;if(boolean)ch0=ch0|0x04;break;} case 6:{ch0=ch0&0xfd;if(boolean)ch0=ch0|0x02;break;} case 7:{ch0=ch0&0xfe;if(boolean)ch0=ch0|0x01;break;} } *p_str=ch0; }
(82)
(83) In this method, there are 16 combinations in two-encryption mode, wherein 4 combinations are encrypted successfully in both encryptions, 4 combinations fail to encrypt in both encryptions, and 8 combinations are encrypted successfully in only one of the two encryptions which are discarded due to meaninglessness for the second encryption. Only 4 combinations that are encrypted successfully in both encryptions are reported. In the final state, “1” represents successful and “0” represents failed.
(84) The foregoing description merely shows the preferred embodiments of the disclosure, and the disclosure is not limited to the foregoing embodiments. All technical effects of the disclosure obtained by any identical means shall fall into the protection scope of the disclosure. Various different modifications and variations can be made to the technical solutions and/or embodiments within the protection scope of the disclosure.