CN109981245B - Encryption and decryption method for character string - Google Patents

Encryption and decryption method for character string Download PDF

Info

Publication number
CN109981245B
CN109981245B CN201910215924.6A CN201910215924A CN109981245B CN 109981245 B CN109981245 B CN 109981245B CN 201910215924 A CN201910215924 A CN 201910215924A CN 109981245 B CN109981245 B CN 109981245B
Authority
CN
China
Prior art keywords
sequence
chaotic
character
numerical
low
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.)
Active
Application number
CN201910215924.6A
Other languages
Chinese (zh)
Other versions
CN109981245A (en
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.)
Jiangsu Xunrui Technology Co ltd
Original Assignee
Nantong Textile Vocational Technology College
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 Nantong Textile Vocational Technology College filed Critical Nantong Textile Vocational Technology College
Priority to CN201910215924.6A priority Critical patent/CN109981245B/en
Publication of CN109981245A publication Critical patent/CN109981245A/en
Application granted granted Critical
Publication of CN109981245B publication Critical patent/CN109981245B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/001Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols using chaotic signals

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Complex Calculations (AREA)
  • Storage Device Security (AREA)
  • Compression, Expansion, Code Conversion, And Decoders (AREA)

Abstract

The invention discloses a method for encrypting and decrypting a character string, which comprises the following steps: firstly, a chaotic system is utilized to generate chaotic signals, and a certain segment of character string to be encrypted is scrambled according to a position change scrambling rule before and after a chaotic sequence is sequenced; then converting the scrambled character string into a high-order numerical sequence and a low-order numerical sequence; generating chaotic signals by using a chaotic system, and carrying out forward and reverse diffusion encryption on the low-bit value sequence; finally, the numerical value and the character are converted to obtain the encrypted ciphertext of the character string, and the ciphertext can be decrypted by a similar method to restore the original character string of a certain section. The invention adopts the scrambling rule of the chaotic sequence to scramble or descramble the character string, and simultaneously utilizes the cryptographic characteristic of the chaotic sequence to carry out bidirectional diffusion encryption or decryption on the low-digit numerical sequence converted from the character string, thereby having good performance of resisting known/selected plaintext attack and ciphertext-only attack and ensuring the security and feasibility of encryption and decryption of the character string.

Description

Encryption and decryption method for character string
Technical Field
The invention relates to the technical field of information security, in particular to an encryption and decryption method for a character string.
Background
With the rapid development of Internet technology and multimedia technology, data communication is becoming an important means for people to communicate information. The data transmission by Internet is convenient and fast without being limited by regions, but because of the particularity of some data, both sending parties do not want the data transmitted on the network to be browsed or processed by an unauthorized person. The information not only relates to personal privacy, but also relates to national security, and has a great relationship with politics, military affairs, foreign exchange and the like of the country, so that the security and confidentiality of the data are more and more important. In these special areas where data security is required or when the owner of the data needs to protect his or her own interests, reliable data encryption techniques are needed.
The traditional character string encryption is usually carried out by DES and RAS encryption methods, the encryption operation is relatively complex, the requirements on the safety and the convenience of the character string encryption are gradually increased along with the development of network communication technology, and the adoption of a safe and reliable password technology for carrying out the character data encryption is urgent. The chaotic cipher technology is a new technology for encrypting a required object by using a chaotic signal. The chaotic system has sensitive dependence on initial conditions and structural parameters, and can provide a plurality of uncorrelated and random-like and determined reproducible chaotic sequences. Because the chaos encryption has the characteristics of continuous wide-band spectrum and impulse sharp autocorrelation, the chaos has a great application prospect in the fields of digital information encryption, secret communication and the like, and has attracted extensive research interest. Chaos was studied in the field of cryptography, originating at the end of the 80 s, and a modified Logistic-based mapping was first proposed by mathews, a british mathematician, as a sequential cryptographic scheme. Since the introduction of Matthews' chaotic cipher, chaotic encryption has begun to receive attention from researchers in different fields.
Disclosure of Invention
The purpose of the invention is as follows: the invention aims to solve the defects in the prior art and provides a character string encryption and decryption method, which scrambles a certain section of character string to be encrypted by utilizing the position change rule before and after the chaos sequence generated by a chaos system is sequenced, performs bidirectional diffusion encryption on a low-digit value sequence converted from the scrambled character string by utilizing the password characteristic of the chaos sequence generated by the chaos system, and further converts the high-digit value sequence and the low-digit value sequence to generate a ciphertext, thereby ensuring the safety and feasibility of character string encryption and decryption.
The technical scheme is as follows: the invention relates to a character string encryption method, which comprises the following steps:
(1) scrambling of character strings:
firstly, an initial value x is set by using external encryption keys (alpha, beta)1The tilt tent chaotic system shown in the following formula (1) is iterated with α and μ as β, k denotes the number of iterations, and x denotes the number of iterationsk+1Representing a chaotic signal obtained from the k-th iteration, wherein k is 1,2, so as to obtain a chaotic sequence X,
Figure GDA0003349206570000021
then respectively calculating according to the following formula (2) to obtain the initial iteration step number m of the chaotic system1And an extraction interval (n)1) From the m-th in the chaotic sequence X1Element start every n1Taking 1 element to form a chaotic sequence Y with the length of L,
Figure GDA0003349206570000022
and finally sequencing the chaotic sequence Y in an ascending order, scrambling a certain segment of character string to be encrypted according to the position change scrambling rule before and after sequencing of the sequence Y, and obtaining the scrambled character stringOf a character sequence
Figure GDA0003349206570000023
Wherein the length of the character string is marked as L;
(2) transcoding: converting the scrambled character sequence into numerical data one by one to obtain a high-digit numerical sequence
Figure GDA0003349206570000024
And low bit number value sequence
Figure GDA0003349206570000025
Wherein the numerical sequence
Figure GDA0003349206570000026
Is consistent with the length of the character sequence;
(3) bidirectional diffusion encryption of low-bit value sequences:
firstly, forward diffusion encryption of low-order numerical value sequence is carried out
Calculating the initial iteration step number m of the chaotic system by using external encryption keys (alpha and beta) according to the following formula (3)2
Figure GDA0003349206570000027
Extracting mth from chaos sequence X2An element as an initial value of a chaos system of a tilt tent
Figure GDA0003349206570000028
Simultaneously obtaining the parameter mu of the chaos system of the inclined tent1I.e. mu1=β,
For low-order bit value sequence
Figure GDA0003349206570000029
Each element of
Figure GDA00033492065700000210
Wherein i 1,2, 3.., L, in this order:
from the initial value
Figure GDA00033492065700000211
And the parameter mu1Performing single iteration on the chaos system of the inclined tent shown in the formula (1) to obtain a chaos signal
Figure GDA00033492065700000212
For chaotic signals simultaneously
Figure GDA00033492065700000213
Performing integer processing according to the following formula (4) to obtain chaotic signal Y1i
Figure GDA00033492065700000214
② using chaotic signal Y1iFor data
Figure GDA00033492065700000215
Forward diffusion encryption is performed according to the following formula (5) to obtain a forward diffusion encrypted ciphertext C1i
Figure GDA0003349206570000031
Wherein, Y10And C10In order to forward-spread the encryption key,
③ encrypt the ciphertext C1 according to the forward diffusioniAnd C1i-1And Y1i-1For the parameter mu of the chaos system of the inclined tent1The adjustment is made according to the following equation (6),
Figure GDA0003349206570000032
thereby obtaining the forward diffusion encrypted low-bit value sequence C1 ═ C11,C12,...,C1i,...,C1L};
Then, reverse diffusion encryption of low-order numerical value sequence is carried out
Calculating the initial iteration step number m of the chaotic system by using external encryption keys (alpha and beta) according to the following formula (7)3
Figure GDA0003349206570000033
Extracting mth from chaos sequence X3An element as an initial value of a chaos system of a tilt tent
Figure GDA0003349206570000034
Simultaneously obtaining the parameter mu of the chaos system of the inclined tent2I.e. mu2=β,
The sequence of low bit values C1 ═ C1 after forward diffusion encryption1,C12,...,C1i,...,C1LEach element C1 iniWherein i 1,2,3, L, in this order:
from the initial value
Figure GDA0003349206570000035
And the parameter mu2Performing single iteration on the chaos system of the inclined tent shown in the formula (1) to obtain a chaos signal
Figure GDA0003349206570000036
For chaotic signals simultaneously
Figure GDA0003349206570000037
Performing integer processing according to the following formula (8) to obtain chaotic signal Y2i
Figure GDA0003349206570000038
② using chaotic signal Y2iFor data C1iPerforming reverse diffusion encryption according to the following formula (9) to obtain a bidirectional diffusion encrypted ciphertext C2i
Figure GDA0003349206570000039
Wherein, Y20And C20In order to spread the encryption key in the reverse direction,
③ encrypt the ciphertext C2 according to the bidirectional diffusioniAnd C2i-1And Y2i-1For the parameter mu of the chaos system of the inclined tent2The adjustment is made according to the following equation (10),
Figure GDA0003349206570000041
thereby obtaining the low-bit value sequence C2 ═ { C2 ═ C2 after bidirectional diffusion encryption1,C22,...,C2i,...,C2L};
(4) Transcoding: sequence of high-order numerical values
Figure GDA0003349206570000042
And carrying out conversion of numerical values and characters on the low-order numerical value sequence C2 subjected to bidirectional diffusion encryption to obtain a character sequence C, namely an encrypted ciphertext of the character string, wherein the length of the sequence C is
Figure GDA0003349206570000043
And is
Figure GDA0003349206570000044
Further, the character sequence after scrambling in step (2) is converted into numerical data character by character, wherein the character sequence includes displayable ASCII characters except spaces and 6763 double-byte coded Chinese characters in the GB2312 character set; wherein, the conversion of characters into numerical data one by one means that a unicode2native () function is adopted to convert a single Chinese character into zone bit code numerical data which are expressed as [ zone numerical data, bit numerical data]Or converting displayable ASCII code characters into ASCII code numerical data expressed as [0, ASCII code numerical data]All can useData of
Figure GDA0003349206570000045
Indicating that the corresponding data are combined to obtain a high-order numerical sequence
Figure GDA0003349206570000046
And low bit number value sequence
Figure GDA0003349206570000047
Further, the high-order bit value sequence in step (4)
Figure GDA0003349206570000048
And the low-order digit value sequence C2 after the two-way diffusion encryption carries out the conversion of the numerical value and the character, and the conversion relation is expressed as follows:
setting a null character string C, and sequencing the high-order numerical values
Figure GDA0003349206570000049
And the low bit value sequence C2 ═ C2 after the bidirectional diffusion encryption1,C22,...,C2i,...,C2LThe following operations are sequentially carried out on each corresponding element in the structure,
if it is not
Figure GDA00033492065700000410
First, make a judgment if
Figure GDA00033492065700000411
And (C2)i+161) ≧ 250, then 1 space is added to character sequence C, i.e., C ═ C, '']Are combined with
Figure GDA00033492065700000412
Then using native2unicode (·) function to convert numerical data
Figure GDA00033492065700000413
Converting into single Chinese character, and addingInto the character sequence C, i.e.
Figure GDA00033492065700000414
If it is not
Figure GDA00033492065700000415
Directly using char (·) function to convert numerical data (C2)i+33) into a single ASCII code character and added to the character sequence C, i.e. C ═ C, char (C2)i+33)]。
The invention also discloses a character string decryption method, which comprises the following steps:
(1) transcoding: a certain segment of character string cryptograph to be decrypted
Figure GDA0003349206570000051
Converting the characters one by one into numerical data to obtain a high-order numerical sequence
Figure GDA00033492065700000529
And low bit number value sequence
Figure GDA0003349206570000052
Wherein the length of the numerical sequences R1, R2 is
Figure GDA0003349206570000053
Some segment of character string cryptograph to be decrypted
Figure GDA0003349206570000054
Has a length of
Figure GDA0003349206570000055
Figure GDA0003349206570000056
(2) Bidirectional diffusion decryption of low-bit value sequences:
firstly, the reverse diffusion decryption of the low-order bit value sequence is carried out
Using external decryption keys
Figure GDA0003349206570000057
Starting value
Figure GDA0003349206570000058
And parameters
Figure GDA0003349206570000059
The chaos system of the tilt tent shown in the formula (11) is iterated, k represents the number of iterations,
Figure GDA00033492065700000510
denotes the chaotic signal obtained from the k-th iteration, where k is 1,2
Figure GDA00033492065700000530
Figure GDA00033492065700000511
Calculating according to the following formula (12) to obtain the initial iteration step number of the chaotic system
Figure GDA00033492065700000512
From chaotic sequences
Figure GDA00033492065700000513
To extract
Figure GDA00033492065700000514
The chaotic signal is used as an initial value of the chaotic system of the tilt tent
Figure GDA00033492065700000515
Obtaining parameters of the chaos system of the inclined tent at the same time
Figure GDA00033492065700000516
Namely, it is
Figure GDA00033492065700000517
Figure GDA00033492065700000518
For low-order bit value sequence
Figure GDA00033492065700000531
Each of the elements Ri2Wherein
Figure GDA00033492065700000519
The following operations are sequentially carried out:
from the initial value
Figure GDA00033492065700000520
And parameters
Figure GDA00033492065700000521
Performing single iteration on the chaos system of the inclined tent shown as the formula (11) to obtain a chaos signal
Figure GDA00033492065700000522
For chaotic signals simultaneously
Figure GDA00033492065700000523
Performing integer processing according to the following formula (13) to obtain chaotic signal
Figure GDA00033492065700000524
Figure GDA00033492065700000525
② using chaotic signals
Figure GDA00033492065700000526
For data Ri2Performing reverse diffusion decryption according to the following formula (14) to obtain reverse diffusion decrypted data
Figure GDA00033492065700000527
Figure GDA00033492065700000528
Wherein the content of the first and second substances,
Figure GDA0003349206570000061
and R02In order to spread the decryption key in the reverse direction,
thirdly, according to the element R in the low-order numerical value sequencei2、Ri-12Corresponding numerical value Ri2、Ri-12And an
Figure GDA0003349206570000062
To the parameters of the chaos system of the inclined tent
Figure GDA0003349206570000063
The adjustment is made according to the following equation (15),
Figure GDA0003349206570000064
thereby obtaining a low-bit value sequence after reverse diffusion decryption
Figure GDA00033492065700000626
Then, forward diffusion decryption of the low-order bit value sequence is carried out
Using external decryption keys
Figure GDA0003349206570000065
Calculating according to the following formula (16) to obtain the initial iteration step number of the chaotic system
Figure GDA0003349206570000066
Figure GDA0003349206570000067
From chaotic sequences
Figure GDA0003349206570000068
To extract
Figure GDA0003349206570000069
An element as an initial value of a chaos system of a tilt tent
Figure GDA00033492065700000610
Obtaining parameters of the chaos system of the inclined tent at the same time
Figure GDA00033492065700000611
Namely, it is
Figure GDA00033492065700000612
Decrypting a sequence of reverse diffusion decrypted low-bit values
Figure GDA00033492065700000613
Each element of D1iWherein
Figure GDA00033492065700000614
The following operations are sequentially carried out:
from the initial value
Figure GDA00033492065700000615
And parameters
Figure GDA00033492065700000616
Performing single iteration on the chaos system of the inclined tent shown as the formula (11) to obtain a chaos signal
Figure GDA00033492065700000617
For chaotic signals simultaneously
Figure GDA00033492065700000618
Performing integer processing according to the following formula (17) to obtain chaotic signal
Figure GDA00033492065700000619
Figure GDA00033492065700000620
② using chaotic signals
Figure GDA00033492065700000621
For data D1iForward diffusion decryption is performed according to the following formula (18) to obtain bidirectional diffusion decrypted data D2i
Figure GDA00033492065700000622
Wherein the content of the first and second substances,
Figure GDA00033492065700000623
and D10In order to spread the decryption key in the forward direction,
③ decrypting the data D1 according to the forward diffusioniAnd D1i-1And
Figure GDA00033492065700000624
to the parameters of the chaos system of the inclined tent
Figure GDA00033492065700000625
The adjustment is made according to the following equation (19),
Figure GDA00033492065700000722
thereby obtaining a low-bit value sequence after bidirectional diffusion decryption
Figure GDA0003349206570000071
(3) Transcoding: carrying out numerical value and character processing on the high-order numerical value sequence R1 and the low-order numerical value sequence D2 after bidirectional diffusion decryptionConverting to obtain a character sequence PP, wherein the length of the character sequence PP is
Figure GDA0003349206570000072
(4) And (3) derangement of character strings:
first using an external decryption key
Figure GDA0003349206570000073
Respectively calculating to obtain initial iteration steps of the chaotic system according to a formula (20) shown below
Figure GDA0003349206570000074
And an extraction interval
Figure GDA0003349206570000075
Figure GDA0003349206570000076
Then from the chaotic sequence
Figure GDA0003349206570000077
To middle
Figure GDA0003349206570000078
Element start every other
Figure GDA0003349206570000079
Each element is 1, thereby forming a length of
Figure GDA00033492065700000710
Of the chaotic sequence
Figure GDA00033492065700000711
Finally, the chaotic sequence is processed
Figure GDA00033492065700000712
Sorting in ascending order, according to sequence
Figure GDA00033492065700000713
The position change scrambling rule before and after sorting is used for character sequence
Figure GDA00033492065700000714
Performing inverse scrambling to obtain the character sequence after inverse scrambling
Figure GDA00033492065700000715
Namely the character string recovered after the character string to be decrypted is decrypted.
Further, the step (1) is to encrypt a certain segment of character string to be decrypted
Figure GDA00033492065700000716
Converting the characters into numerical data one by one to obtain a high-order numerical sequence R1 ═ { R }11,R21,...,Ri1,....,RL1And low order bit value sequences
Figure GDA00033492065700000717
The conversion relationship is expressed as follows:
firstly, a certain section of character string cryptograph to be decrypted is obtained
Figure GDA00033492065700000718
In the method, characters are converted into numerical data one by one, namely, a unicode2native () function is adopted to convert a single Chinese character into zone bit code numerical data which are expressed as [ zone numerical data, bit numerical data]Or converting displayable ASCII code characters into ASCII code numerical data expressed as [0, ASCII code numerical data]All can use the data [ Ri1,Ri2]Represents;
then, each numerical data [ R ]i1,Ri2]Corresponding combination
Figure GDA00033492065700000719
Obtaining a high-order numerical sequence
Figure GDA00033492065700000720
And low order numerical orderColumn(s) of
Figure GDA00033492065700000721
Next, it is checked whether there is R in the low order numerical sequence R2i2An element of 32, if so, would correspond to the last element R in the high-order numerical sequence R1i+11Adding 1 to the value and deleting the element R with the value of 32i2And its element R in the corresponding high-order numerical sequence R1i1
Finally obtaining a high-order numerical sequence
Figure GDA0003349206570000081
And low bit number value sequence
Figure GDA0003349206570000082
Further, the high-order numerical value sequence R1 and the low-order numerical value sequence D2 decrypted by the bidirectional diffusion in the step (3) are converted into values and characters, and the conversion relationship is expressed as follows:
setting a null character sequence PP, and sequencing high-digit numerical values
Figure GDA0003349206570000083
And the low-bit value sequence after bidirectional diffusion decryption
Figure GDA0003349206570000084
The corresponding elements in the sequence are operated as follows,
if R isi1If greater than 128, then
If R isi1215 and D2i> 250, then 1 space is added to the character sequence PP, i.e. PP ═ PP, ', i.e'];
Otherwise, using native2unicode () function to convert numerical data [ Ri1,D2i]Converted into single Chinese character and added into the character sequence PP, i.e. PP ═ PP, native2unicode ([ R)i1,D2i])];
If R isi1If < 128, then
Directly using char (·) function to convert numerical data (D2)i) Converted into a single ASCII code character and added to the character sequence PP, i.e. PP ═ PP, char (D2)i)]。
Has the advantages that: the method comprises the steps of scrambling a certain section of character string to be encrypted by utilizing a position change rule before and after the chaos sequence generated by the chaos system is sequenced, performing bidirectional diffusion encryption on a low-digit value sequence converted from the scrambled character string by utilizing the password characteristic of the chaos sequence generated by the chaos system, and converting the high-digit value sequence and the low-digit value sequence to generate a ciphertext, so that the safety and feasibility of encryption and decryption of the character string are ensured.
Drawings
Fig. 1 is a schematic diagram of an encryption and decryption process of a character string according to the present invention.
Detailed Description
The method for encrypting the character string shown in fig. 1 comprises the following steps:
(1) scrambling of character strings:
firstly, an initial value x is set by using external encryption keys (alpha, beta)1Iterating the tilt tent chaotic system (formula as below), wherein k represents iteration number, and x represents iteration numberk+1Representing a chaotic signal obtained from the k-th iteration, wherein k is 1,2, so as to obtain a chaotic sequence X,
Figure GDA0003349206570000091
then respectively calculating the initial iteration step number (m) of the chaotic system according to the following formula1) And an extraction interval (n)1) From the m-th in the chaotic sequence X1Element start every n1Taking 1 element to form a chaotic sequence Y with the length of L,
Figure GDA0003349206570000092
Figure GDA0003349206570000093
and finally sequencing the chaotic sequence Y in an ascending order, scrambling a certain segment of character string to be encrypted according to the position change scrambling rule before and after sequencing of the sequence Y to obtain a scrambled character sequence
Figure GDA0003349206570000094
Where the string length is noted as L.
(2) Transcoding: converting the scrambled character sequence into numerical data one by one, wherein the character sequence comprises displayable ASCII code characters except blank spaces and 6763 Chinese characters of double-byte encoding in a GB2312 character set; wherein, the conversion of characters into numerical data one by one means that a unicode2native () function is adopted to convert a single Chinese character into zone bit code numerical data which are expressed as [ zone numerical data, bit numerical data]Or converting displayable ASCII code characters into ASCII code numerical data expressed as [0, ASCII code numerical data]All can use the data
Figure GDA0003349206570000095
Indicating that the corresponding data are combined to obtain a high-order numerical sequence
Figure GDA0003349206570000096
And low bit number value sequence
Figure GDA0003349206570000097
Wherein the numerical sequence
Figure GDA0003349206570000098
The length of the encryption key is consistent with the length of a certain segment of character string to be encrypted.
(3) Bidirectional diffusion encryption of low-bit value sequences:
firstly, forward diffusion encryption of low-order numerical value sequence is carried out
Calculating the initial iteration step number (m) of the chaotic system by using external encryption keys (alpha and beta) according to the following formula2),
Figure GDA0003349206570000099
Extracting mth from chaos sequence X2An element as an initial value of a chaos system of a tilt tent
Figure GDA00033492065700000910
Simultaneously obtaining the parameters (mu) of the chaos system of the inclined tent1) I.e. mu1=β,
For low-order bit value sequence
Figure GDA00033492065700000911
Each element of
Figure GDA00033492065700000912
Wherein i 1,2, 3.., L, in this order:
from the initial value
Figure GDA00033492065700000913
And the parameter mu1Performing single iteration on the chaos system of the inclined tent to obtain a chaos signal
Figure GDA00033492065700000914
For chaotic signals simultaneously
Figure GDA00033492065700000915
The following integer processing is carried out to obtain a chaotic signal Y1i
Figure GDA0003349206570000101
② using chaotic signal Y1iFor data
Figure GDA0003349206570000102
Forward diffusion encryption is performed according to the following formula (5) to obtain a forward diffusion encrypted ciphertext C1i
Figure GDA0003349206570000103
Wherein, Y10And C10In order to forward-spread the encryption key,
③ encrypt the ciphertext C1 according to the forward diffusioniAnd C1i-1And Y1i-1For the parameter mu of the chaos system of the inclined tent1The following adjustment is made as follows,
Figure GDA0003349206570000104
thereby obtaining the forward diffusion encrypted low-bit value sequence C1 ═ C11,C12,...,C1i,...,C1L};
Then, reverse diffusion encryption of low-order numerical value sequence is carried out
Calculating the initial iteration step number (m) of the chaotic system by using external encryption keys (alpha and beta) according to the following formula3),
Figure GDA0003349206570000105
Extracting mth from chaos sequence X3An element as an initial value of a chaos system of a tilt tent
Figure GDA0003349206570000106
Simultaneously obtaining the parameters (mu) of the chaos system of the inclined tent2) I.e. mu2=β,
The sequence of low bit values C1 ═ C1 after forward diffusion encryption1,C12,...,C1i,...,C1LEach element C1 iniWherein i 1,2,3, L, in this order:
from the initial value
Figure GDA0003349206570000107
And the parameter mu2Performing single iteration on the chaos system of the inclined tent shown in the step (1) to obtainChaotic signal
Figure GDA0003349206570000108
For chaotic signals simultaneously
Figure GDA0003349206570000109
The following integer processing is carried out to obtain a chaotic signal Y2i
Figure GDA00033492065700001010
② using chaotic signal Y2iFor data C1iPerforming reverse diffusion encryption according to the following formula to obtain bidirectional diffusion encrypted ciphertext C2i
Figure GDA00033492065700001011
Wherein, Y20And C20In order to spread the encryption key in the reverse direction,
③ encrypt the ciphertext C2 according to the bidirectional diffusioniAnd C2i-1And Y2i-1For the parameter mu of the chaos system of the inclined tent2The following adjustment is made as follows,
Figure GDA0003349206570000111
thereby obtaining the low-bit value sequence C2 ═ { C2 ═ C2 after bidirectional diffusion encryption1,C22,...,C2i,...,C2L};
(4) Transcoding: setting a null character string C, and sequencing the high-order numerical values
Figure GDA0003349206570000112
And the low bit value sequence C2 ═ C2 after the bidirectional diffusion encryption1,C22,...,C2i,...,C2LThe following operations are sequentially carried out on each corresponding element in the structure,
if it is not
Figure GDA0003349206570000113
First, make a judgment if
Figure GDA0003349206570000114
And (C2)i+161) ≧ 250, then 1 space is added to character sequence C, i.e., C ═ C, '']Are combined with
Figure GDA0003349206570000115
Then using native2unicode (·) function to convert numerical data
Figure GDA0003349206570000116
Converted into single Chinese characters and added to the character sequence C, i.e.
Figure GDA0003349206570000117
If it is not
Figure GDA0003349206570000118
Directly using char (·) function to convert numerical data (C2)i+33) into a single ASCII code character and added to the character sequence C, i.e. C ═ C, char (C2)i+33)]
Thereby obtaining a character sequence C, namely the encrypted ciphertext of the character string, wherein the length of the sequence C is
Figure GDA0003349206570000119
And is
Figure GDA00033492065700001110
As shown in fig. 1, a method for decrypting a string includes the following steps:
(1) transcoding: a certain segment of character string cryptograph to be decrypted
Figure GDA00033492065700001111
Character-by-character conversionConverting the data into numerical data to obtain a high-order numerical value sequence R1 ═ { R ═ R11,R21,...,Ri1,....,RL1R and a low order value sequence R2 ═ R12,R22,...,Ri2,....,RL2The conversion relationship is expressed as follows:
firstly, converting characters in a certain section of character string ciphertext C to be decrypted into numerical data one by one, namely, converting a single Chinese character into region bit code numerical data by adopting a unicode2native (·) function, and expressing the region bit code numerical data into region bit data]Or converting displayable ASCII code characters into ASCII code numerical data expressed as [0, ASCII code numerical data]All can use the data [ Ri1,Ri2]Represents;
then, each numerical data [ R ]i1,Ri2]Corresponding combination
Figure GDA00033492065700001112
Obtaining a high-order numerical sequence
Figure GDA00033492065700001113
And low bit number value sequence
Figure GDA00033492065700001114
Next, it is checked whether there is R in the low order numerical sequence R2i2An element of 32, if so, would correspond to the last element R in the high-order numerical sequence R1i+11Adding 1 to the value and deleting the element R with the value of 32i2And its element R in the corresponding high-order numerical sequence R1i1
Finally obtaining a high-order numerical sequence
Figure GDA0003349206570000121
And low bit number value sequence
Figure GDA0003349206570000122
Wherein the length of the numerical sequences R1, R2 is
Figure GDA0003349206570000123
A certain segment of word to be decryptedString cipher text
Figure GDA0003349206570000124
Has a length of
Figure GDA0003349206570000125
(2) Bidirectional diffusion decryption of low-bit value sequences:
firstly, the reverse diffusion decryption of the low-order bit value sequence is carried out
Using external decryption keys
Figure GDA0003349206570000126
Starting value
Figure GDA0003349206570000127
And parameters
Figure GDA0003349206570000128
Iteration is carried out on the tilting tent chaotic system (the formula is shown as follows), k represents the iteration number,
Figure GDA0003349206570000129
denotes the chaotic signal obtained from the k-th iteration, where k is 1,2
Figure GDA00033492065700001210
Figure GDA00033492065700001211
Calculating to obtain the initial iteration step number of the chaotic system according to the following formula
Figure GDA00033492065700001212
From chaotic sequences
Figure GDA00033492065700001213
To extract
Figure GDA00033492065700001214
The chaotic signal is used as an initial value of the chaotic system of the tilt tent
Figure GDA00033492065700001215
Obtaining parameters of the chaos system of the inclined tent at the same time
Figure GDA00033492065700001216
Namely, it is
Figure GDA00033492065700001217
Figure GDA00033492065700001218
For low-order bit value sequence
Figure GDA00033492065700001219
Each of the elements Ri2Wherein
Figure GDA00033492065700001220
The following operations are sequentially carried out:
from the initial value
Figure GDA00033492065700001221
And parameters
Figure GDA00033492065700001222
Performing single iteration on the chaos system of the inclined tent to obtain a chaos signal
Figure GDA00033492065700001223
For chaotic signals simultaneously
Figure GDA00033492065700001224
Performing the following integer processing to obtain chaotic signal
Figure GDA00033492065700001225
Figure GDA00033492065700001226
② using chaotic signals
Figure GDA00033492065700001227
For data Ri2Performing reverse diffusion decryption to obtain reverse diffusion decrypted data
Figure GDA00033492065700001228
Figure GDA0003349206570000131
Figure GDA0003349206570000132
Wherein the content of the first and second substances,
Figure GDA0003349206570000133
and R02In order to spread the decryption key in the reverse direction,
thirdly, according to the element R in the low-order numerical value sequencei2、Ri-12Corresponding numerical value Ri2、Ri-12And an
Figure GDA0003349206570000134
To the parameters of the chaos system of the inclined tent
Figure GDA0003349206570000135
The following adjustment is made as follows,
Figure GDA0003349206570000136
thereby obtaining a low-bit value sequence after reverse diffusion decryption
Figure GDA0003349206570000137
Then, forward diffusion decryption of the low-order bit value sequence is carried out
Using external decryption keys
Figure GDA0003349206570000138
Calculating to obtain the initial iteration step number of the chaotic system according to the formula shown in the specification
Figure GDA0003349206570000139
Figure GDA00033492065700001310
From chaotic sequences
Figure GDA00033492065700001311
To extract
Figure GDA00033492065700001312
An element as an initial value of a chaos system of a tilt tent
Figure GDA00033492065700001313
Obtaining parameters of the chaos system of the inclined tent at the same time
Figure GDA00033492065700001314
Namely, it is
Figure GDA00033492065700001315
Decrypting a sequence of reverse diffusion decrypted low-bit values
Figure GDA00033492065700001316
Each element of D1iWherein
Figure GDA00033492065700001317
The following operations are sequentially carried out:
from the initial value
Figure GDA00033492065700001318
And parameters
Figure GDA00033492065700001319
Performing single iteration on the chaos system of the inclined tent to obtain a chaos signal
Figure GDA00033492065700001320
For chaotic signals simultaneously
Figure GDA00033492065700001321
Performing integer processing according to the following formula to obtain chaotic signal
Figure GDA00033492065700001322
Figure GDA00033492065700001323
② using chaotic signals
Figure GDA00033492065700001324
For data D1iForward diffusion decryption is carried out according to the following formula to obtain bidirectional diffusion decrypted data D2i
Figure GDA00033492065700001325
Wherein the content of the first and second substances,
Figure GDA00033492065700001326
and D10In order to spread the decryption key in the forward direction,
③ decrypting the data D1 according to the forward diffusioniAnd D1i-1And
Figure GDA00033492065700001327
to the parameters of the chaos system of the inclined tent
Figure GDA00033492065700001328
The following adjustment is made as follows,
Figure GDA0003349206570000141
thereby obtaining a low-bit value sequence after bidirectional diffusion decryption
Figure GDA0003349206570000142
(3) Transcoding: setting a null character sequence PP, and sequencing high-digit numerical values
Figure GDA0003349206570000143
And the low-bit value sequence after bidirectional diffusion decryption
Figure GDA0003349206570000144
The corresponding elements in the sequence are operated as follows,
if R isi1If greater than 128, then
If R isi1215 and D2i> 250, then 1 space is added to the character sequence PP, i.e. PP ═ PP, ', i.e'];
Otherwise, using native2unicode () function to convert numerical data [ Ri1,D2i]Converted into single Chinese character and added into the character sequence PP, i.e. PP ═ PP, native2unicode ([ R)i1,D2i])];
If R isi1If < 128, the numerical data (D2) is directly processed by using char (·) functioni) Converted into a single ASCII code character and added to the character sequence PP, i.e. PP ═ PP, char (D2)i)]
Obtaining a character sequence PP, wherein the length of the character sequence PP is
Figure GDA0003349206570000145
(4) And (3) derangement of character strings:
first using an external decryption key
Figure GDA0003349206570000146
Respectively calculating the initial iteration steps of the chaotic system according to the following formula
Figure GDA0003349206570000147
And an extraction interval
Figure GDA0003349206570000148
Figure GDA0003349206570000149
Figure GDA00033492065700001410
Then from the chaotic sequence
Figure GDA00033492065700001411
To middle
Figure GDA00033492065700001412
Element start every other
Figure GDA00033492065700001413
Each element is 1, thereby forming a length of
Figure GDA00033492065700001414
Of the chaotic sequence
Figure GDA00033492065700001415
Finally, the chaotic sequence is processed
Figure GDA00033492065700001416
Sorting in ascending order, according to sequence
Figure GDA00033492065700001417
The position change scrambling rule before and after sorting is used for character sequence
Figure GDA00033492065700001418
Performing inverse scrambling to obtain the character sequence after inverse scrambling
Figure GDA00033492065700001419
I.e. the character string recovered after the decryption of the character string to be decrypted, wherein the length of the character string is
Figure GDA00033492065700001420
The invention is further illustrated by the following specific examples:
example 1
According to the method for encrypting the character string in the above embodiment, the steps are as follows:
(1) first, iterating the tilt tent chaotic system shown in the formula in step (1) of the encryption method for a character string in the above embodiment by using an external encryption key (α is 0.12345, β is 0.65), so as to obtain a chaotic sequence X, and meanwhile, calculating according to the formula in step (1) of the encryption method for a character string in the above embodiment, so as to obtain an initial iteration step number (m) of the chaotic system1) And an extraction interval (n)1),
m1=523+23=546
n1=19+1=20
1 is taken out every other 20 elements from the 546 th element in the chaotic sequence X, so as to form a chaotic sequence Y with the length L of 18, wherein the chaotic sequence Y is {0.361896018751758,0.707665360260700,0.416287938280632,0.569011637774278,0.276890527259342,0.467623413399187,0.989176495851167,0.169240171895533,0.675028025531495,0.458815246880602,0.612489131368256,0.174072241734472,0.580925969554056,0.934397085989157,0.159735447382966,0.158302228329434,0.858615950392380 and 0.592104003195874},
and finally sequencing the chaotic sequence Y in an ascending order, scrambling a certain section of character string to be encrypted, namely 'character string encryption/decryption 111111 aaaaaaaa', according to the position change scrambling rule {16,15,8,12,5,1,3,10,6,4,13,18,11,9,2,17,14,7} before and after the sequence Y is sequenced to obtain a scrambled character sequence
Figure GDA0003349206570000151
Figure GDA0003349206570000152
(2) The scrambled character sequence is processed
Figure GDA0003349206570000153
Figure GDA0003349206570000154
Converting the characters into numerical data one by one to obtain a high-order numerical sequence
Figure GDA0003349206570000155
Figure GDA0003349206570000156
And low bit number value sequence
Figure GDA0003349206570000157
Figure GDA0003349206570000158
Wherein the numerical sequence
Figure GDA0003349206570000159
The length of the character string is consistent with the length of the character string, and is marked as L being 18;
(3) firstly, forward diffusion encryption of low-order numerical value sequence is carried out
Using the external encryption key (α ═ 0.12345, β ═ 0.65), calculating according to the formula in step (3) of the encryption method for a character string in the above embodiment, and obtaining the initial iteration step number (m) of the chaotic system2),
m2=432+8=440
Extracting 440 th element from the chaos sequence X as an initial value of the tilt tent chaos system
Figure GDA00033492065700001510
Simultaneously obtaining the parameters (mu) of the chaos system of the inclined tent1=0.65),
For low-order bit value sequence
Figure GDA0003349206570000161
Figure GDA0003349206570000162
Each element of
Figure GDA0003349206570000163
In the above embodiment, the oblique tent chaotic mapping single iteration, the integer processing, the forward diffusion encryption and the oblique tent chaotic mapping parameter μ shown in the formula in step (3) of the encryption method for the character string are sequentially performed1Adjustment, etc., wherein forward diffusion encryption key Y1 is taken046 and C1026, so as to obtain the forward diffusion encrypted low bit number sequence C1 ═ {64,14,78,35,4,28,63,55,82,55,55,60,61,85,25,1,68,92 };
then, reverse diffusion encryption of low-order numerical value sequence is carried out
Using the external encryption key (α ═ 0.12345, β ═ 0.65), calculating according to the formula in step (3) of the encryption method for a character string in the above embodiment, and obtaining the initial iteration step number (m) of the chaotic system3),
m3=543+34=577
Extracting the 577 th element from the chaotic sequence X as an initial value of the tilting tent chaotic system
Figure GDA0003349206570000164
Simultaneously obtaining the parameters (mu) of the chaos system of the inclined tent2=0.65),
For low bit value sequence C1 ═ { C11,C12,...,C1i,....,C118Each element C1 in {64,14,78,35,4,28,63,55,82,55,55,60,61,85,25,1,68,92} is C1iSequentially performing single iteration and integer transformation of the chaos mapping of the inclined tent shown in the formula in the step (3) of the encryption method for the character string in the above embodimentProcessing, reverse diffusion encryption and tilt tent chaotic mapping parameter mu2Adjustment, etc., in which the reverse diffusion encryption key Y2 is taken056 and C2036, so as to obtain the low-order bit value sequence C2 after the bidirectional diffusion encryption, which is {35,26,86,76,84,32,25,31,68,74,86,2,51,90,53,66,87,60 };
(4) sequence of high-order numerical values
Figure GDA0003349206570000165
And each corresponding element in the low-order digit value sequence C2 after bidirectional diffusion encryption is subjected to numerical value and character conversion in turn, so as to obtain a character string ciphertext as "D"; wm jin Cuochun @ Myan cocoon w # T { fraction cx]”。
According to the method for decrypting the character string in the above embodiment, the steps are as follows:
(1) a certain section of ciphertext D to be decrypted; the wm chinaware spring @ michael cocoons w # T { frac ] "are converted into numerical data one by one, and a high-bit numerical sequence R1 ═ {0,0, 189,215,180,0,195,188,0,0, 183,0,0,0} and a low-bit numerical sequence R2 ═ {68,59,119,109,245,193,186,64,229,235,119,35,84,123,214,99,120,93 };
(2) firstly, the reverse diffusion decryption of the low-order bit value sequence is carried out
Using external decryption keys
Figure GDA0003349206570000166
Calculating according to the formula in step (2) of the decryption method for the character string in the above specific embodiment to obtain the initial iteration step number of the chaotic system
Figure GDA0003349206570000167
Figure GDA0003349206570000168
From chaotic sequences
Figure GDA0003349206570000171
Extracting the 577 th element as the initial value of the chaos system of the inclined tent
Figure GDA0003349206570000172
Obtaining parameters of the chaos system of the inclined tent at the same time
Figure GDA0003349206570000173
For low bit value sequences R2 ═ { R12,R22,...,Ri2,....,R182Each element R of {68,59,119,109,245,193,186,64,229,235,119,35,84,123,214,99,120,93}i2Wherein i is 1,2, 3.. times, 18, the slope tent chaotic mapping single iteration, the integer processing, the inverse diffusion decryption and the slope tent chaotic mapping parameter shown in the formula in step (2) of the decryption method for the character string in the above embodiment are sequentially performed
Figure GDA0003349206570000174
Adjustment, etc., in which the decryption key is fetched in the reverse direction
Figure GDA0003349206570000175
And R'0236, so as to obtain the low-order bit value sequence D1 after bidirectional diffusion decryption, which is {64,14,78,35,4,28,63,55,82,55,55,60,61,85,25,1,68,92 };
then, forward diffusion decryption of the low-order bit value sequence is carried out
Using external decryption keys
Figure GDA0003349206570000176
Calculating according to the formula in step (2) of the decryption method for the character string in the above specific embodiment to obtain the initial iteration step number of the chaotic system
Figure GDA0003349206570000177
Figure GDA0003349206570000178
From chaotic sequences
Figure GDA0003349206570000179
Extracting 440 th element as the initial value of the chaos system of the tilt tent
Figure GDA00033492065700001710
Obtaining parameters of the chaos system of the inclined tent at the same time
Figure GDA00033492065700001711
Decrypting the sequence of low-bit values D1 ═ D1 after the back diffusion1,D12,...,D1i,...,D118Each element D1 in {64,14,78,35,4,28,63,55,82,55,55,60,61,85,25,1,68,92}iIn the above embodiment, the slope tent chaotic mapping single iteration, the integer processing, the forward diffusion decryption and the slope tent chaotic mapping parameter shown in the formula in step (2) of the decryption method for the character string are sequentially performed
Figure GDA00033492065700001712
Adjustment, etc., in which forward diffusion decryption keys are fetched
Figure GDA00033492065700001713
And D1026, so as to obtain a bidirectional diffusion decrypted low-bit value sequence D2 ═ {97,97,49, 226,214,174,49,220,211,97,97,49, 251,97,97,49 };
(3) converting the numerical value and the character by using the sequence of high-order values R1 ═ {0,0, 189,215,180,0,195,188,0,0, 183,0, 0} and the sequence of low-order values D2 ═ 97,97,49, 226,214,174,49,220,211,97,97,49, 251,97,97,49}, wherein the character string is "aa 11 string 1 dense plus aa11 character aa 1", that is, the character sequence PP { 'a', 'a', '1', '1', '1', 'solution', 'word', 'string', '1', 'dense', 'a', 'a', 'a', '1', '1', '1', 'and';
(4) first using an external decryption key
Figure GDA00033492065700001714
Calculating according to the formula in step (4) of the decryption method for the character string in the above specific embodiment to obtain the initial iteration step number of the chaos mapping of the tilt tent
Figure GDA00033492065700001715
And an extraction interval
Figure GDA00033492065700001716
Figure GDA00033492065700001717
Figure GDA00033492065700001718
From chaotic sequences
Figure GDA0003349206570000181
The 546 th element is started to take 1 every 20 elements, thereby forming the length of
Figure GDA0003349206570000182
Of the chaotic sequence
Figure GDA0003349206570000183
Figure GDA0003349206570000184
Figure GDA0003349206570000185
Figure GDA0003349206570000186
Figure GDA0003349206570000187
Finally, the chaotic sequence is processed
Figure GDA0003349206570000188
Sorting in ascending order, according to sequence
Figure GDA0003349206570000189
The position change scrambling rule before and after the ordering {16,15,8,12,5,1,3,10,6,4,13,18,11,9,2,17,14,7}, inverse scrambling is performed on the character sequence PP { ' a ', ' a ', ' 1 ', ' 1 ', ' solution ', ' word ', ' string ', ' 1 ', ' cipher ', ' addition ', ' a ', ' 1 ', ' 1 ', ' character ', ' a ', ' a ', ' 1 ', ' 1 ', ' 1 ', ' string ', ' addition ', ' solution ', ' cipher ', ' 1 ', ' 1 ', ' 1 ', ' 1 ', ' 1 ', ' a ', ' a ', ' a ', ' a ', ' and ' a ' }, namely the character string recovered after the decryption of the character string to be decrypted is 'character string encryption and decryption 111111 aaaaaaa',
example 2
According to the above method for encrypting a string, a certain string to be encrypted is "string encryption/decryption 111111 aaaaaaaa", and the encryption procedure of a string is similar to that in embodiment 1, only a slight change occurs in the encryption key: 0.12345000000001; or β 0.65000000000001; or Y1045, percent; or C1027; or Y2055; or C20The string encryption results are shown in table 1, 37. As can be seen from table 1, a small change in the encryption key causes a large change in the encryption text of the character string, and thus it can be seen that the encryption method for the character string provided in this patent is sensitive to the encryption key.
TABLE 1 encryption result of character string when the external encryption key is changed slightly
Figure GDA00033492065700001810
Figure GDA0003349206570000191
Example 3
According to the above method for encrypting a string, the encryption procedure is similar to that of embodiment 1, and only a certain segment of the string to be encrypted ("string encryption/decryption 111111 aaaaaaaa") is slightly changed: "substring encryption/decryption 111111 aaaaaaa"; or "string solving honey 111111 aaaaaaa"; or "string encryption/decryption 211111 aaaaaaaa"; or "string encryption/decryption 111112 aaaaaaa"; or "string encryption/decryption 111111 baaaaa"; or "string encryption/decryption 111111 aaaaaaab", the string encryption results are shown in table 2. As can be seen from table 2: the subtle change of the plain text information of the character string to be encrypted can cause 'all-face-nothing' of the encrypted ciphertext, so that the character string encryption method provided by the patent has sensitivity to the plain text information of the character string to be encrypted.
TABLE 2 encryption result of character string when the character string to be encrypted is slightly changed
Figure GDA0003349206570000192
Figure GDA0003349206570000201
As can be seen from the above specific embodiments 2 and 3, the string encryption ciphertext generated by the string encryption method provided by the present invention is not only closely related to the encryption key, but also depends on the plaintext information of the string to be encrypted, so that the string encryption method provided by the present invention can resist known/selected plaintext attacks, and has strong security.
Example 4
According to the decryption method of the Chinese characters, a certain section of ciphertext to be decrypted is D; wm jin Cuochun @ Myan cocoon w # T { fraction cx]", the decryption step of a string is similar to that of embodiment 1, and only slight changes occur in the decryption key:
Figure GDA0003349206570000202
or
Figure GDA0003349206570000203
Or
Figure GDA0003349206570000204
Or D1027; or
Figure GDA0003349206570000205
Or R02The string ciphertext decryption result is shown in table 3, 37. As can be seen from table 3, a small change in the decryption key causes a large change in the decryption result of the ciphertext, and the recovered string is useless, so that the method for decrypting the string provided in this patent is sensitive to the decryption key.
TABLE 3 ciphertext decipher result when external decipher key is changed slightly
Figure GDA0003349206570000206
Figure GDA0003349206570000211
Example 5
According to the method for decrypting the character string, the decryption steps are similar to those of the embodiment 1, and only a certain section of the character string ciphertext to be decrypted ("D; wm Jinzhichun @ Myan cocoon w # T { subdivision cx ]") is slightly changed: "d; wm jin dui chun @ michael cocoon w # T { fraction cx ] "; or "D; wm Cotton cut spring @ Myan cocoon w # T { subdivision cx ] "; or "D; wm brocade chiseling & burma cocoon w # T { fraction cx ] "; or "D; wm jin kui chun @ michael cocoon W # T { subdivision cx ] "; or "D; wm jin dui chun @ burma cocoon w # T [ fen cx ] "; or "D; wm jin kui chun @ michael cocoon w # T { fen cx } "; or "; dwm Chizuchun @ Myan cocoon w # T { subdivision cx ] "; or "D; wm brocade chikura @ Myan cocoon w # T { fraction c ] x ", and the string decryption results are shown in Table 4. As can be seen from table 4, the small change of the ciphertext of the character string to be decrypted causes a large change of the decryption result of the ciphertext, and it is difficult to recover the original character string, so that the character string decryption method provided in this patent can resist ciphertext-only attack.
TABLE 4 ciphertext decryption result when the ciphertext of the string to be decrypted has a slight change
Figure GDA0003349206570000221
Figure GDA0003349206570000231

Claims (6)

1. A method for encrypting character strings is characterized by comprising the following steps:
(1) scrambling of character strings:
firstly, an initial value x is set by using external encryption keys (alpha, beta)1The tilt tent chaotic system shown in the following formula (1) is iterated with α and μ as β, k denotes the number of iterations, and x denotes the number of iterationsk+1Representing a chaotic signal obtained from the k-th iteration, wherein k is 1,2, so as to obtain a chaotic sequence X,
Figure FDA0003349206560000011
then, the initial iteration step numbers (m) of the chaotic system are respectively calculated according to the following formula (2)1) And an extraction interval (n)1) From the m-th in the chaotic sequence X1Element start every n1Taking 1 element to form a chaotic sequence Y with the length of L,
Figure FDA0003349206560000012
and finally sequencing the chaotic sequence Y in an ascending order, scrambling a certain segment of character string to be encrypted according to the position change scrambling rule before and after sequencing of the sequence Y to obtain a scrambled character sequence
Figure FDA0003349206560000013
Wherein the length of the character string is marked as L;
(2) transcoding: converting the scrambled character sequence into numerical data one by one to obtain a high-digit numerical sequence
Figure FDA0003349206560000014
And low bit number value sequence
Figure FDA0003349206560000015
Wherein the numerical sequence
Figure FDA0003349206560000016
Is consistent with the length of the character sequence;
(3) bidirectional diffusion encryption of low-bit value sequences:
firstly, forward diffusion encryption of low-order numerical value sequence is carried out
Calculating the initial iteration step number m of the chaotic system by using external encryption keys (alpha and beta) according to the following formula (3)2
Figure FDA00033492065600000110
Extracting mth from chaos sequence X2An element as an initial value of a chaos system of a tilt tent
Figure FDA0003349206560000017
Simultaneously obtaining the parameters (mu) of the chaos system of the inclined tent1) I.e. mu1=β,
For low-order bit value sequence
Figure FDA0003349206560000018
Each element of
Figure FDA0003349206560000019
Wherein i 1,2, 3.., L, in this order:
from the initial value
Figure FDA0003349206560000021
And the parameter mu1Performing single iteration on the chaos system of the inclined tent shown in the formula (1) to obtain a chaos signal
Figure FDA0003349206560000022
For chaotic signals simultaneously
Figure FDA0003349206560000023
Performing integer processing according to the following formula (4) to obtain chaotic signal Y1i
Figure FDA0003349206560000024
② using chaotic signal Y1iFor data
Figure FDA0003349206560000025
Forward diffusion encryption is performed according to the following formula (5) to obtain a forward diffusion encrypted ciphertext C1i
Figure FDA0003349206560000026
Wherein, Y10And C10In order to forward-spread the encryption key,
③ encrypt the ciphertext C1 according to the forward diffusioniAnd C1i-1And Y1i-1For the parameter mu of the chaos system of the inclined tent1The adjustment is made according to the following equation (6),
Figure FDA0003349206560000027
thereby obtaining the forward diffusion encrypted low-bit value sequence C1 ═ C11,C12,...,C1i,...,C1L};
Then, reverse diffusion encryption of low-order numerical value sequence is carried out
Calculating the initial iteration step number m of the chaotic system by using external encryption keys (alpha and beta) according to the following formula (7)3
Figure FDA0003349206560000028
Extracting mth from chaos sequence X3An element as an initial value of a chaos system of a tilt tent
Figure FDA0003349206560000029
Simultaneously obtaining the parameters (mu) of the chaos system of the inclined tent2) I.e. mu2=β,
The sequence of low bit values C1 ═ C1 after forward diffusion encryption1,C12,...,C1i,...,C1LEach element C1 iniWherein i 1,2,3, L, in this order:
from the initial value
Figure FDA00033492065600000210
And the parameter mu2Performing single iteration on the chaos system of the inclined tent shown in the formula (1) to obtain a chaos signal
Figure FDA00033492065600000211
For chaotic signals simultaneously
Figure FDA00033492065600000212
Performing integer processing according to the following formula (8) to obtain chaotic signal Y2i
Figure FDA0003349206560000031
② using chaotic signal Y2iFor data C1iPerforming reverse diffusion encryption according to the following formula (9) to obtain a bidirectional diffusion encrypted ciphertext C2i
Figure FDA0003349206560000032
Wherein, Y20And C20In order to spread the encryption key in the reverse direction,
③ encrypt the ciphertext C2 according to the bidirectional diffusioniAnd C2i-1And Y2i-1For the parameter mu of the chaos system of the inclined tent2The adjustment is made according to the following equation (10),
Figure FDA0003349206560000033
thereby obtaining the low-bit value sequence C2 ═ { C2 ═ C2 after bidirectional diffusion encryption1,C22,...,C2i,...,C2L};
(4) Transcoding: sequence of high-order numerical values
Figure FDA0003349206560000034
And carrying out conversion of numerical values and characters on the low-order numerical value sequence C2 subjected to bidirectional diffusion encryption to obtain a character sequence C, namely an encrypted ciphertext of the character string, wherein the length of the sequence C is
Figure FDA0003349206560000035
And is
Figure FDA0003349206560000036
2. The method for encrypting a character string according to claim 1, wherein: converting the scrambled character sequence into numerical data one by one in the step (2), wherein the character sequence comprises displayable ASCII code characters except blank spaces and 6763 Chinese characters of double-byte encoding in the GB2312 character set(ii) a Wherein, the conversion of characters into numerical data one by one means that a unicode2native () function is adopted to convert a single Chinese character into zone bit code numerical data which are expressed as [ zone numerical data, bit numerical data]Or converting displayable ASCII code characters into ASCII code numerical data expressed as [0, ASCII code numerical data]All can use the data
Figure FDA0003349206560000037
Indicating that the corresponding data are combined to obtain a high-order numerical sequence
Figure FDA0003349206560000038
And low bit number value sequence
Figure FDA0003349206560000039
3. The method for encrypting a character string according to claim 1, wherein: the high-order digit value sequence in the step (4)
Figure FDA00033492065600000310
And the low-order digit value sequence C2 after the two-way diffusion encryption carries out the conversion of the numerical value and the character, and the conversion relation is expressed as follows:
setting a null character string C, and sequencing the high-order numerical values
Figure FDA00033492065600000311
And the low bit value sequence C2 ═ C2 after the bidirectional diffusion encryption1,C22,...,C2i,...,C2LThe following operations are sequentially carried out on each corresponding element in the structure,
if it is not
Figure FDA00033492065600000312
First, make a judgment if
Figure FDA0003349206560000041
And (C2)i+161) ≧ 250, then 1 space is added to character sequence C, i.e., C ═ C, '']Are combined with
Figure FDA0003349206560000042
Then using native2unicode (·) function to convert numerical data
Figure FDA0003349206560000043
Converted into single Chinese characters and added to the character sequence C, i.e.
Figure FDA0003349206560000044
If it is not
Figure FDA0003349206560000045
Directly using char (·) function to convert numerical data (C2)i+33) into a single ASCII code character and added to the character sequence C, i.e. C ═ C, char (C2)i+33)]。
4. A decryption method of character strings is characterized by comprising the following steps:
(1) transcoding: converting a certain segment of character string ciphertext C to be decrypted into numerical data one by one to obtain a high-order numerical sequence R1 ═ R11,R21,...,Ri1,....,RL1R and a low order value sequence R2 ═ R12,R22,...,Ri2,....,RL2Wherein the length of the numerical value sequences R1, R2 is
Figure FDA0003349206560000046
Some segment of character string cryptograph to be decrypted
Figure FDA0003349206560000047
Has a length of
Figure FDA0003349206560000048
(2) Bidirectional diffusion decryption of low-bit value sequences:
firstly, the reverse diffusion decryption of the low-order bit value sequence is carried out
Using external decryption keys
Figure FDA0003349206560000049
Starting value
Figure FDA00033492065600000410
And parameters
Figure FDA00033492065600000411
The chaos system of the tilt tent shown in the formula (11) is iterated, k represents the number of iterations,
Figure FDA00033492065600000412
denotes the chaotic signal obtained from the k-th iteration, where k is 1,2
Figure FDA00033492065600000413
Figure FDA00033492065600000414
Calculating according to the following formula (12) to obtain the initial iteration step number of the chaotic system
Figure FDA00033492065600000415
From chaotic sequences
Figure FDA00033492065600000416
To extract
Figure FDA00033492065600000417
The chaotic signal is used as an initial value of the chaotic system of the tilt tent
Figure FDA00033492065600000418
Obtaining parameters of the chaos system of the inclined tent at the same time
Figure FDA00033492065600000419
Namely, it is
Figure FDA00033492065600000420
Figure FDA00033492065600000421
For low-order bit value sequence
Figure FDA00033492065600000422
Each of the elements Ri2Wherein i is 1,2, 3.,
Figure FDA00033492065600000423
the following operations are sequentially carried out:
from the initial value
Figure FDA0003349206560000051
And parameters
Figure FDA0003349206560000052
Performing single iteration on the chaos system of the inclined tent shown as the formula (11) to obtain a chaos signal
Figure FDA0003349206560000053
For chaotic signals simultaneously
Figure FDA0003349206560000054
Performing integer processing according to the following formula (13) to obtain chaotic signal
Figure FDA0003349206560000055
Figure FDA0003349206560000056
② using chaotic signals
Figure FDA0003349206560000057
For data Ri2Performing reverse diffusion decryption according to the following formula (14) to obtain reverse diffusion decrypted data
Figure FDA0003349206560000058
Figure FDA0003349206560000059
Wherein the content of the first and second substances,
Figure FDA00033492065600000510
and R02In order to spread the decryption key in the reverse direction,
thirdly, according to the element R in the low-order numerical value sequencei2、Ri-12Corresponding numerical value Ri2、Ri-12And an
Figure FDA00033492065600000511
To the parameters of the chaos system of the inclined tent
Figure FDA00033492065600000512
The adjustment is made according to the following equation (15),
Figure FDA00033492065600000513
thereby obtaining the sequence D1 ═ D1 of the low-bit value after the reverse diffusion decryption1,D12,...,D1i,...,D1L};
Then, forward diffusion decryption of the low-order bit value sequence is carried out
Using external decryption keys
Figure FDA00033492065600000514
Calculating according to the following formula (16) to obtain the initial iteration step number of the chaotic system
Figure FDA00033492065600000515
Figure FDA00033492065600000516
From chaotic sequences
Figure FDA00033492065600000517
To extract
Figure FDA00033492065600000518
An element as an initial value of a chaos system of a tilt tent
Figure FDA00033492065600000519
Obtaining parameters of the chaos system of the inclined tent at the same time
Figure FDA00033492065600000520
Namely, it is
Figure FDA00033492065600000521
Decrypting a sequence of reverse diffusion decrypted low-bit values
Figure FDA00033492065600000522
Each element of D1iWherein i is 1,2, 3.,
Figure FDA00033492065600000523
the following operations are sequentially carried out:
from the initial value
Figure FDA00033492065600000524
And parameters
Figure FDA00033492065600000525
Performing single iteration on the chaos system of the inclined tent shown as the formula (11) to obtain a chaos signal
Figure FDA00033492065600000526
For chaotic signals simultaneously
Figure FDA00033492065600000527
Performing integer processing according to the following formula (17) to obtain chaotic signal
Figure FDA00033492065600000528
Figure FDA00033492065600000529
② using chaotic signals
Figure FDA0003349206560000061
For data D1iForward diffusion decryption is performed according to the following formula (18) to obtain bidirectional diffusion decrypted data D2i
Figure FDA0003349206560000062
Wherein the content of the first and second substances,
Figure FDA0003349206560000063
and D10In order to spread the decryption key in the forward direction,
③ decrypting the data D1 according to the forward diffusioniAnd D1i-1And
Figure FDA0003349206560000064
to the parameters of the chaos system of the inclined tent
Figure FDA0003349206560000065
The adjustment is made according to the following equation (19),
Figure FDA0003349206560000066
thereby obtaining a low-bit value sequence after bidirectional diffusion decryption
Figure FDA0003349206560000067
(3) Transcoding: carrying out value-to-character conversion on the high-order numerical value sequence R1 and the low-order numerical value sequence D2 after bidirectional diffusion decryption to obtain a character sequence PP, wherein the length of the character sequence PP is
Figure FDA0003349206560000068
(4) And (3) derangement of character strings:
first using an external decryption key
Figure FDA0003349206560000069
Respectively calculating to obtain initial iteration steps of the chaotic system according to a formula (20) shown below
Figure FDA00033492065600000610
And an extraction interval
Figure FDA00033492065600000611
Figure FDA00033492065600000612
Then from the chaotic sequence
Figure FDA00033492065600000613
To middle
Figure FDA00033492065600000614
Element start every other
Figure FDA00033492065600000615
Each element is 1, thereby forming a length of
Figure FDA00033492065600000616
Of the chaotic sequence
Figure FDA00033492065600000617
Finally, the chaotic sequence is processed
Figure FDA00033492065600000618
Sorting according to ascending order, and performing reverse scrambling on each character in the character string PP according to the position change scrambling rule before and after sorting of the sequence Y to obtain a character sequence after reverse scrambling
Figure FDA00033492065600000619
Namely the character string recovered after the character string to be decrypted is decrypted.
5. The method for decrypting character string according to claim 4, wherein: the step (1) is to decrypt a certain segment of character string ciphertext to be decrypted
Figure FDA00033492065600000620
Converting the characters one by one into numerical data to obtain a high-order numerical sequence
Figure FDA00033492065600000621
And low bit number value sequence
Figure FDA00033492065600000622
The conversion relationship is expressed as follows:
firstly, a certain section of character string cryptograph to be decrypted is obtained
Figure FDA0003349206560000078
In the method, characters are converted into numerical data one by one, namely, a unicode2native () function is adopted to convert a single Chinese character into zone bit code numerical data which are expressed as [ zone numerical data, bit numerical data]Or converting displayable ASCII code characters into ASCII code numerical data expressed as [0, ASCII code numerical data]All can use the data [ Ri1,Ri2]Represents;
then, each numerical data [ R ]i1,Ri2]Corresponding combination
Figure FDA0003349206560000071
Obtaining a high-order numerical sequence
Figure FDA0003349206560000072
And low bit number value sequence
Figure FDA0003349206560000073
Next, it is checked whether there is R in the low order numerical sequence R2i2An element of 32, if so, would correspond to the last element R in the high-order numerical sequence R1i+11Adding 1 to the value and deleting the element R with the value of 32i2And its element R in the corresponding high-order numerical sequence R1i1
Finally obtaining a high-order numerical sequence
Figure FDA0003349206560000074
And low bit number value sequence
Figure FDA0003349206560000075
6. The method for decrypting character string according to claim 4, wherein: and (3) performing conversion of numerical values and characters on the high-order numerical value sequence R1 and the low-order numerical value sequence D2 subjected to bidirectional diffusion decryption, wherein the conversion relation is expressed as follows:
setting a null character sequence PP, and sequencing high-digit numerical values
Figure FDA0003349206560000076
And the low-bit value sequence after bidirectional diffusion decryption
Figure FDA0003349206560000077
The corresponding elements in the sequence are operated as follows,
if R isi1If greater than 128, then
If R isi1215 and D2i> 250, then 1 space is added to the character sequence PP, i.e. PP ═ PP, ', i.e'](ii) a Otherwise, using native2unicode () function to convert numerical data [ Ri1,D2i]Converted into single Chinese character and added into the character sequence PP, i.e. PP ═ PP, native2unicode ([ R)i1,D2i])];
If R isi1If < 128, then
Directly using char (·) function to convert numerical data (D2)i) Converted into a single ASCII code character and added to the character sequence PP, i.e. PP ═ PP, char (D2)i)]。
CN201910215924.6A 2019-03-21 2019-03-21 Encryption and decryption method for character string Active CN109981245B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910215924.6A CN109981245B (en) 2019-03-21 2019-03-21 Encryption and decryption method for character string

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910215924.6A CN109981245B (en) 2019-03-21 2019-03-21 Encryption and decryption method for character string

Publications (2)

Publication Number Publication Date
CN109981245A CN109981245A (en) 2019-07-05
CN109981245B true CN109981245B (en) 2022-01-28

Family

ID=67079842

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910215924.6A Active CN109981245B (en) 2019-03-21 2019-03-21 Encryption and decryption method for character string

Country Status (1)

Country Link
CN (1) CN109981245B (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110457949A (en) * 2019-08-14 2019-11-15 于向东 A kind of data desensitization method of holding uniqueness based on data dictionary, integrality, relevance
CN110650006B (en) * 2019-09-17 2021-11-12 南通大学 Encryption and decryption method for Chinese and English character strings
CN111985591B (en) * 2020-07-24 2022-06-21 南通大学 Commodity anti-counterfeiting code generation method based on character string encryption
CN112163230B (en) * 2020-09-16 2021-09-24 南通大学 Commodity anti-counterfeiting code generation method based on Chinese character encryption
CN113095042B (en) * 2021-03-23 2023-12-19 广州零端科技有限公司 Character string encryption method, system, device and storage medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104486073A (en) * 2014-12-23 2015-04-01 南通大学 Encryption and decryption method of character data
CN109102452A (en) * 2018-07-28 2018-12-28 河南大学 A kind of image encryption method based on Latin square scramble and directional diffusion

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9836281B2 (en) * 2013-03-12 2017-12-05 Greg J. Wright Encryption method and system using a random bit string encryption key

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104486073A (en) * 2014-12-23 2015-04-01 南通大学 Encryption and decryption method of character data
CN109102452A (en) * 2018-07-28 2018-12-28 河南大学 A kind of image encryption method based on Latin square scramble and directional diffusion

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
一种基于双向扩散的混沌图像加密算法研究;吴新华;《南通纺织职业技术学院学报(综合版)》;20140630;第14卷(第2期);13-17 *

Also Published As

Publication number Publication date
CN109981245A (en) 2019-07-05

Similar Documents

Publication Publication Date Title
CN109995504B (en) Encryption and decryption method for character string
CN109981245B (en) Encryption and decryption method for character string
CN109981246B (en) Encryption method and decryption method for character string
CN110011783B (en) Encryption and decryption method for Chinese characters
Sinha et al. Encrypted information hiding using audio steganography and audio cryptography
CN105100115A (en) Data storage method for privacy protection based on encryption password and data fractionation
CN104751401A (en) Novel piecewise linear chaotic mapping image encrypting and encoding method
CN104378198A (en) Voice encryption method based on block cipher system
CN109547663B (en) Improved LSB image steganography method combined with cryptography
CN114157772B (en) Digital image encryption method based on space-time chaotic system and half tensor product compressed sensing
CN103179319A (en) Method for encrypting digital images of double-chaos system
Miss et al. Fuzzy logic based image encryption for confidential data transfer using (2, 2) secret sharing scheme
Bandekar et al. LSB based text and image steganography using AES algorithm
Yahaya et al. Cryptosystem for secure data transmission using Advance Encryption Standard (AES) and Steganography
Kundu et al. A secure approach to audio steganography
Suresh et al. Separable reversible data hiding using Rc4 algorithm
CN116192360A (en) Asymmetric visual sense meaningful image encryption method based on 2D compressed sensing
Alghamdi et al. A secure iris image encryption technique using bio-chaotic algorithm
CN110278066B (en) Encryption and decryption method for Chinese character string
Alghamdi et al. Bio-chaotic stream cipher-based iris image encryption
Sivakumar et al. Generation of random key stream using word grid puzzle for the applications of cryptography
CN110287713B (en) Encryption method and decryption method for Chinese character string
Bartwal et al. Lossless and Reversible Data Hiding in Encrypted Images With Public Key Cryptography.
Barakat et al. Securing Digital Image using Modified Chaotic Logistic Key
Reddy Improved secure data transfer using video steganographic technique

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
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20231221

Address after: 707, 7th Floor, Building 3, Zilang Science and Technology City, No. 60 Chongzhou Avenue, Development Zone, Nantong City, Jiangsu Province, 226000

Patentee after: Jiangsu Xunrui Technology Co.,Ltd.

Address before: 226000 No. 87 Youth Middle Road, Nantong City, Jiangsu Province

Patentee before: JIANGSU College OF ENGINEERING AND TECHNOLOGY