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

Encryption method and decryption method for character string Download PDF

Info

Publication number
CN109981246B
CN109981246B CN201910215951.3A CN201910215951A CN109981246B CN 109981246 B CN109981246 B CN 109981246B CN 201910215951 A CN201910215951 A CN 201910215951A CN 109981246 B CN109981246 B CN 109981246B
Authority
CN
China
Prior art keywords
sequence
chaotic
numerical
low
order
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
CN201910215951.3A
Other languages
Chinese (zh)
Other versions
CN109981246A (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.)
Nantong Textile Vocational Technology College
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 CN201910215951.3A priority Critical patent/CN109981246B/en
Publication of CN109981246A publication Critical patent/CN109981246A/en
Application granted granted Critical
Publication of CN109981246B publication Critical patent/CN109981246B/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
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/04Network architectures or network communication protocols for network security for providing a confidential data exchange among entities communicating through data packet networks
    • H04L63/0428Network architectures or network communication protocols for network security for providing a confidential data exchange among entities communicating through data packet networks wherein the data content is protected, e.g. by encrypting or encapsulating the payload
    • 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)
  • Computer Hardware Design (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Complex Calculations (AREA)
  • Storage Device Security (AREA)

Abstract

The invention discloses an encryption method and a decryption method of character strings, which comprise the following steps: converting a certain string into a high-order numerical sequence and a low-order numerical sequence; then, generating chaotic signals by using a chaotic system, and scrambling the high-digit numerical value sequence according to the position change scrambling rule before and after the chaotic sequence is sequenced; 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 high-digit value sequence converted from the character string, and simultaneously utilizes the cryptographic property of the chaotic sequence to carry out bidirectional diffusion encryption or decryption on the low-digit value sequence converted from the character string, thereby having good performance of resisting known/selected plaintext attack and ciphertext-only attack and ensuring the safety and feasibility of character string encryption and decryption.

Description

Encryption method and decryption method for character string
Technical Field
The invention relates to the technical field of information security, in particular to an encryption method and a decryption method of 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 an encryption method and a decryption method for a character string, which are characterized in that a high-order numerical value sequence converted from a certain character string is scrambled by utilizing a position change rule before and after the sequence of a chaotic sequence generated by a chaotic system, a low-order numerical value sequence converted from the certain character string is subjected to bidirectional diffusion encryption by utilizing the password characteristic of the chaotic sequence generated by the chaotic system, and then the high-order numerical value sequence and the low-order numerical value sequence are converted to generate a ciphertext, so that the safety and the feasibility of encryption and decryption of the character string are ensured.
The technical scheme is as follows: the invention relates to a character string encryption method, which comprises the following steps:
(1) transcoding: converting a certain character string into numerical data one by one to obtain a high-order numerical sequence P1 ═ P11,P21,...,Pi1,....,PL1And a low order value sequence P2 ═ P12,P22,...,Pi2,....,PL2The length of the numerical value sequences P1 and P2 is consistent with the length of the character string, and is marked as L;
(2) scrambling of high-bit value sequences:
firstly, respectively calculating initial iteration step numbers m of the chaotic system by using external encryption keys (alpha and beta) according to a formula (1) shown below1And an extraction interval n1
Figure GDA0003356051700000021
Then let the initial value x1The tilt tent chaotic system shown in the following formula (2) is iterated with α and μ as β, k denotes the number of iterations, and x denotes the number of iterationsk+1Denotes the chaotic signal obtained in the k-th iteration, where k is 1, 2.,
Figure GDA0003356051700000022
obtaining a chaotic sequence X from m1Element start every n1Taking 1 element to form a chaotic sequence Y with the length of L,
and finally, sequencing the chaotic sequence Y in an ascending order, and according to the position change scrambling rule before and after sequencing the sequence Y, setting the high-digit value sequence P1 as { P }11,P21,...,Pi1,....,PL1Scrambling to obtain a scrambled high-digit value sequence
Figure GDA0003356051700000023
(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 GDA0003356051700000024
Extracting mth from chaos sequence X2An element as an initial value of a chaos system of a tilt tent
Figure GDA0003356051700000025
Simultaneously obtaining the parameter mu of the chaos system of the inclined tent1I.e. byμ1=β,
For low bit value sequence P2 ═ { P12,P22,...,Pi2,....,PL2Each element P ini2Wherein i 1,2,3, L, in this order:
from the initial value
Figure GDA0003356051700000026
And the parameter mu1Performing single iteration on the chaos system of the inclined tent shown in the formula (2) to obtain a chaos signal
Figure GDA0003356051700000027
For chaotic signals simultaneously
Figure GDA0003356051700000028
Performing integer processing according to the following formula (4) to obtain chaotic signal Y1i
Figure GDA0003356051700000029
② using chaotic signal Y1iFor data Pi2Forward diffusion encryption is performed according to the following formula (5) to obtain a forward diffusion encrypted ciphertext C1i
Figure GDA0003356051700000031
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 GDA0003356051700000032
thereby obtaining forward diffusion encrypted lowBit 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 GDA0003356051700000033
Extracting mth from chaos sequence X3An element as an initial value of a chaos system of a tilt tent
Figure GDA0003356051700000034
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 GDA0003356051700000035
And the parameter mu2Performing single iteration on the chaos system of the inclined tent shown in the formula (2) to obtain a chaos signal
Figure GDA0003356051700000036
For chaotic signals simultaneously
Figure GDA0003356051700000037
Performing integer processing according to the following formula (8) to obtain chaotic signal Y2i
Figure GDA0003356051700000038
② using chaotic signal Y2iFor data C1iPerforming reverse diffusion encryption according to the following formula (9) to obtain a bidirectional diffusion encrypted ciphertext C2i
Figure GDA0003356051700000039
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 GDA0003356051700000041
thereby obtaining the low-bit value sequence C2 ═ { C2 ═ C2 after bidirectional diffusion encryption1,C22,...,C2i,...,C2L};
(4) Transcoding: the scrambled high-bit numerical sequence is processed
Figure GDA0003356051700000042
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 GDA0003356051700000043
And is
Figure GDA0003356051700000044
Further, converting a certain character string into numerical data character by character in the step (1), wherein a certain character string comprises displayable ASCII characters except for blank spaces and 6763 double-byte coded Chinese characters in the GB2312 character set; 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, numerical bit data]Or converting displayable ASCII code characters into ASCII code numerical data expressed as [0, ASCII code numerical data]All can use [ Pi1,Pi2]Indicating that the corresponding data combination results in a high bit value sequence P1 ═ { P ═ P11,P21,...,Pi1,....,PL1And a low order value sequence P2 ═ P12,P22,...,Pi2,....,PL2}。
Further, the scrambled high-bit value sequence in step (4)
Figure GDA0003356051700000045
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 sequence C, and sequencing the scrambled high-digit numerical values
Figure GDA0003356051700000046
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 GDA0003356051700000047
Then
First, if it is determined
Figure GDA0003356051700000048
And (C2)i+161) ≧ 250, then 1 space is added in the character sequence C, i.e. C ═ C, "]Are combined with
Figure GDA0003356051700000049
Then using native2unicode (·) function to convert numerical data
Figure GDA00033560517000000410
Converted into single Chinese characters and added to the character sequence C, i.e.
Figure GDA00033560517000000411
If it is not
Figure GDA00033560517000000412
Then
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 is characterized by comprising the following steps:
(1) transcoding: a certain segment of character string cryptograph to be decrypted
Figure GDA0003356051700000051
Converting the characters one by one into numerical data to obtain a high-order numerical sequence
Figure GDA0003356051700000052
And low bit number value sequence
Figure GDA0003356051700000053
Wherein the length of the numerical sequences R1, R2 is
Figure GDA0003356051700000054
Some segment of character string cryptograph to be decrypted
Figure GDA0003356051700000055
Has a length of
Figure GDA0003356051700000056
(2) Descrambling of high-bit numerical sequences:
first using an external decryption key
Figure GDA0003356051700000057
Respectively calculating to obtain initial iteration steps of the chaotic system according to a formula (11) shown below
Figure GDA0003356051700000058
And an extraction interval
Figure GDA0003356051700000059
Figure GDA00033560517000000510
Then order the initial value
Figure GDA00033560517000000511
And parameters
Figure GDA00033560517000000512
The tilt tent chaotic system shown in the following formula (12) is iterated, k represents the number of iterations,
Figure GDA00033560517000000513
denotes the chaotic signal obtained in the k-th iteration, where k is 1, 2.,
Figure GDA00033560517000000514
obtaining a chaotic sequence
Figure GDA00033560517000000515
From the first
Figure GDA00033560517000000516
Element start every other
Figure GDA00033560517000000517
Each element is 1, thereby forming a length of
Figure GDA00033560517000000518
Of the chaotic sequence
Figure GDA00033560517000000519
Finally, the chaotic sequence is processed
Figure GDA00033560517000000520
Sorting in ascending order, according to sequence
Figure GDA00033560517000000521
The position change scrambling rule before and after sorting is used for high-digit value sequence
Figure GDA00033560517000000522
Performing inverse scrambling to obtain an inverse-scrambled high-bit value sequence
Figure GDA00033560517000000523
(3) 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 GDA00033560517000000524
Calculating according to the following formula (13) to obtain the initial iteration step number of the chaotic system
Figure GDA00033560517000000525
Figure GDA00033560517000000526
From chaotic sequences
Figure GDA0003356051700000061
To extract
Figure GDA0003356051700000062
An element as an initial value of a chaos system of a tilt tent
Figure GDA0003356051700000063
Obtaining parameters of the chaos system of the inclined tent at the same time
Figure GDA0003356051700000064
Namely, it is
Figure GDA0003356051700000065
For low-order bit value sequence
Figure GDA0003356051700000066
Each of the elements Ri2Wherein
Figure GDA0003356051700000067
The following operations are sequentially carried out:
from the initial value
Figure GDA0003356051700000068
And parameters
Figure GDA0003356051700000069
Performing single iteration on the chaos system of the inclined tent shown as the formula (12) to obtain a chaos signal
Figure GDA00033560517000000610
For chaotic signals simultaneously
Figure GDA00033560517000000611
Performing integer processing according to the following formula (14) to obtain chaotic signal
Figure GDA00033560517000000612
Figure GDA00033560517000000613
② using chaotic signals
Figure GDA00033560517000000614
For data Ri2Performing reverse diffusion decryption according to the following formula (15) to obtain reverse diffusion decrypted data
Figure GDA00033560517000000615
Figure GDA00033560517000000616
Wherein the content of the first and second substances,
Figure GDA00033560517000000617
and R'02In 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 R'i2、R′i-12And an
Figure GDA00033560517000000618
To the parameters of the chaos system of the inclined tent
Figure GDA00033560517000000619
The adjustment is made in accordance with the following equation (16),
Figure GDA00033560517000000620
thereby obtaining a low-bit value sequence after reverse diffusion decryption
Figure GDA00033560517000000621
Then, forward diffusion decryption of the low-order bit value sequence is carried out
Using external decryption keys
Figure GDA00033560517000000622
Calculating according to the following formula (17) to obtain the initial iteration step number of the chaotic system
Figure GDA00033560517000000623
Figure GDA00033560517000000624
From chaotic sequences
Figure GDA00033560517000000625
To extract
Figure GDA00033560517000000626
An element as an initial value of a chaos system of a tilt tent
Figure GDA00033560517000000627
Obtaining parameters of the chaos system of the inclined tent at the same time
Figure GDA00033560517000000628
Namely, it is
Figure GDA00033560517000000629
Decrypting a sequence of reverse diffusion decrypted low-bit values
Figure GDA00033560517000000630
Each element of D1iWherein
Figure GDA00033560517000000631
The following operations are sequentially carried out:
from the initial value
Figure GDA0003356051700000071
And parameters
Figure GDA0003356051700000072
Performing single iteration on the chaos system of the inclined tent shown as the formula (12) to obtain a chaos signal
Figure GDA0003356051700000073
For chaotic signals simultaneously
Figure GDA0003356051700000074
Performing integer processing according to the following formula (18) to obtain chaotic signal
Figure GDA0003356051700000075
Figure GDA0003356051700000076
② using chaotic signals
Figure GDA0003356051700000077
For data D1iForward diffusion decryption is performed according to the following formula (19) to obtain bidirectional diffusion decrypted data D2i
Figure GDA0003356051700000078
Wherein the content of the first and second substances,
Figure GDA0003356051700000079
and D10In order to spread the decryption key in the forward direction,
③ decrypting the data D1 according to the forward diffusioniAnd D1i-1And
Figure GDA00033560517000000710
to the parameters of the chaos system of the inclined tent
Figure GDA00033560517000000711
The adjustment is made according to the following equation (20),
Figure GDA00033560517000000712
thereby obtaining a low-bit value sequence after bidirectional diffusion decryption
Figure GDA00033560517000000713
(4) Transcoding: the high-order digit value sequence after the reverse scrambling is carried out
Figure GDA00033560517000000714
And the low-bit numerical sequence D2 after bidirectional diffusion decryption is carried out, the numerical value and the character are converted to obtain a character sequence PP, namely the character string recovered after the decryption of the character string to be decrypted, wherein the length of the character sequence PP is
Figure GDA00033560517000000715
Further, the step (1) is to encrypt a certain segment of character string to be decrypted
Figure GDA00033560517000000716
Converting into numerical data one by one to obtain high-order numerical sequence
Figure GDA00033560517000000717
And low bit number value sequence
Figure GDA00033560517000000718
The conversion relationship is expressed as follows:
firstly, a certain section of character string cryptograph to be decrypted is obtained
Figure GDA00033560517000000719
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 [ R ]i1,Ri2]Represents;
then the numerical data [ Ri1,Ri2]Correspondingly combining to obtain high-order numerical value sequence
Figure GDA00033560517000000720
And low bit number value sequence
Figure GDA00033560517000000721
Wherein
Figure GDA00033560517000000722
Then check the low-order numerical value sequence R2 one by one to see if there is Ri2An 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 GDA0003356051700000081
And low bit number value sequence
Figure GDA0003356051700000082
Further, the high-order digit value sequence after the inverse scrambling in the step (4) is carried out
Figure GDA0003356051700000083
And the low-order digit value sequence D2 after bidirectional diffusion decryption is used for converting the numerical value and the character, and the conversion relation is expressed as follows:
setting a null character string PP, and carrying out reverse scrambling on the high-digit numerical sequence
Figure GDA0003356051700000084
And the low-bit value sequence after bidirectional diffusion decryption
Figure GDA0003356051700000085
The corresponding elements in the sequence are operated as follows,
if it is not
Figure GDA0003356051700000086
Then
If it is not
Figure GDA0003356051700000087
And D2i≧ 250, then 1 space is added in the character sequence PP, i.e., PP ═ PP, "](ii) a Otherwise, using native2unicode (·) function to convert numerical data
Figure GDA0003356051700000088
Converted into single Chinese characters and added to the character sequence PP, i.e.
Figure GDA0003356051700000089
If it is not
Figure GDA00033560517000000810
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 invention uses the position change rule before and after the chaos sequence generated by the chaos system to scramble the high-digit value sequence converted from a certain segment of character string, and simultaneously uses the password characteristic of the chaos sequence generated by the chaos system to perform bidirectional diffusion encryption on the low-digit value sequence converted from a certain segment of character string, so that the high-digit value sequence and the low-digit value sequence are converted to generate a ciphertext, thereby ensuring the safety and feasibility of character string encryption and decryption.
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) transcoding: converting a certain character string into numerical data one by one, wherein the character string comprises displayable ASCII code characters except blank spaces and 6763 Chinese characters of double-byte encoding in a GB2312 character set; 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, numerical bit data]Or converting displayable ASCII code characters into ASCII code numerical data expressed as [0, ASCII code numerical data]All can use [ Pi1,Pi2]Indicating that the corresponding data combination results in a high bit value sequence P1 ═ { P ═ P11,P21,...,Pi1,....,PL1And a low order value sequence P2 ═ P12,P22,...,Pi2,....,PL2The length of the numerical value sequences P1 and P2 is consistent with the length of the character string and is marked as L,
(2) scrambling of high-bit value sequences:
firstly, respectively calculating the initial iteration step number (m) of the chaotic system by using external encryption keys (alpha and beta) according to the following formula1) And an extraction interval (n)1),
Figure GDA0003356051700000091
Figure GDA0003356051700000092
Then let the initial value x1Iterating the tilt tent chaotic system (formula as below), wherein k represents iteration number, and x represents iteration numberk+1Denotes the chaotic signal obtained in the k-th iteration, where k is 1, 2.,
Figure GDA0003356051700000093
obtaining a chaotic sequence X from m1Element start every n1Taking 1 element to form a chaotic sequence Y with the length of L,
and finally, sequencing the chaotic sequence Y in an ascending order, and according to the position change scrambling rule before and after sequencing the sequence Y, setting the high-digit value sequence P1 as { P }11,P21,...,Pi1,....,PL1Scrambling to obtain a scrambled high-digit value sequence
Figure GDA0003356051700000094
(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 GDA0003356051700000095
Extracting mth from chaos sequence X2An element as an initial value of a chaos system of a tilt tent
Figure GDA0003356051700000096
Simultaneously obtaining the parameters (mu) of the chaos system of the inclined tent1) I.e. mu1=β,
For low bit value sequence P2 ═ { P12,P22,...,Pi2,....,PL2Each element P ini2Wherein i 1,2,3, L, in this order:
from the initial value
Figure GDA0003356051700000101
And the parameter mu1Performing single iteration on the chaos system of the inclined tent to obtain a chaos signal
Figure GDA0003356051700000102
For chaotic signals simultaneously
Figure GDA0003356051700000103
The following integer processing is carried out to obtain a chaotic signal Y1i
Figure GDA0003356051700000104
② using chaotic signal Y1iFor data Pi2Forward diffusion encryption is carried out to obtain a forward diffusion encrypted ciphertext C1i
Figure GDA0003356051700000105
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 GDA0003356051700000106
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 GDA0003356051700000107
Extracting mth from chaos sequence X3An element as an initial value of a chaos system of a tilt tent
Figure GDA0003356051700000108
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 GDA0003356051700000109
And the parameter mu2Performing single iteration on the chaos system (formula below) of the inclined tent to obtain a chaos signal
Figure GDA00033560517000001010
For chaotic signals simultaneously
Figure GDA00033560517000001011
The following integer processing is carried out to obtain a chaotic signal Y2i
Figure GDA00033560517000001012
② using chaotic signal Y2iFor data C1iPerforming reverse diffusion encryption to obtain bidirectional diffusion encrypted ciphertext C2i
Figure GDA00033560517000001013
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 GDA0003356051700000111
thereby obtaining the low-bit value sequence C2 ═ { C2 ═ C2 after bidirectional diffusion encryption1,C22,...,C2i,...,C2L};
(4) Transcoding: setting a null character sequence C, and sequencing the scrambled high-digit numerical values
Figure GDA0003356051700000112
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 GDA0003356051700000113
Then
First, if it is determined
Figure GDA0003356051700000114
And (C2)i+161) ≧ 250, then 1 space is added in the character sequence C, i.e. C ═ C, "]Are combined with
Figure GDA0003356051700000115
Then using native2unicode (·) function to convert numerical data
Figure GDA0003356051700000116
Converted into single Chinese characters and added to the character sequence C, i.e.
Figure GDA0003356051700000117
If it is not
Figure GDA0003356051700000118
Then
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 GDA0003356051700000119
And is
Figure GDA00033560517000001110
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 GDA00033560517000001111
Converting the characters one by one into numerical data to obtain a high-order numerical sequence
Figure GDA00033560517000001112
And low bit number value sequence
Figure GDA00033560517000001113
The specific conversion relationship is expressed as follows:
firstly, a certain section of character string cryptograph to be decrypted is obtained
Figure GDA00033560517000001114
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 [ R ]i1,Ri2]Represents;
then the numerical data [ Ri1,Ri2]Correspondingly combining to obtain high-order numerical value sequence
Figure GDA00033560517000001115
And low bit number value sequence
Figure GDA0003356051700000121
Wherein
Figure GDA0003356051700000122
Then check the low-order numerical value sequence R2 one by one to see if there is Ri2An 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 GDA0003356051700000123
And low bit number value sequence
Figure GDA0003356051700000124
Wherein the length of the numerical sequences R1, R2 is
Figure GDA0003356051700000125
Some segment of character string cryptograph to be decrypted
Figure GDA0003356051700000126
Has a length of
Figure GDA0003356051700000127
(2) Descrambling of high-bit numerical sequences:
first using an external decryption key
Figure GDA0003356051700000128
Respectively calculating to obtain initial iteration steps of the chaotic system according to the formula shown in the specification
Figure GDA0003356051700000129
And an extraction interval
Figure GDA00033560517000001210
Figure GDA00033560517000001211
Figure GDA00033560517000001212
Then order the initial value
Figure GDA00033560517000001213
And parameters
Figure GDA00033560517000001214
Iteration is carried out on the tilting tent chaotic system (the formula is shown as follows), k represents the iteration number,
Figure GDA00033560517000001215
represents the kth iterationThe resulting chaotic signal, where k is 1, 2.,
Figure GDA00033560517000001216
obtaining a chaotic sequence
Figure GDA00033560517000001217
From the first
Figure GDA00033560517000001218
Element start every other
Figure GDA00033560517000001219
Each element is 1, thereby forming a length of
Figure GDA00033560517000001220
Of the chaotic sequence
Figure GDA00033560517000001221
Finally, the chaotic sequence is processed
Figure GDA00033560517000001222
Sorting in ascending order, according to sequence
Figure GDA00033560517000001223
The position change scrambling rule before and after sorting is used for high-digit value sequence
Figure GDA00033560517000001224
Performing inverse scrambling to obtain an inverse-scrambled high-bit value sequence
Figure GDA00033560517000001225
(3) 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 GDA00033560517000001226
Calculating to obtain the initial iteration step number of the chaotic system according to the following formula
Figure GDA00033560517000001227
Figure GDA00033560517000001228
From chaotic sequences
Figure GDA00033560517000001229
To extract
Figure GDA00033560517000001230
An element as an initial value of a chaos system of a tilt tent
Figure GDA00033560517000001231
Obtaining parameters of the chaos system of the inclined tent at the same time
Figure GDA0003356051700000131
Namely, it is
Figure GDA0003356051700000132
For low-order bit value sequence
Figure GDA0003356051700000133
Each of the elements Ri2Wherein
Figure GDA0003356051700000134
The following operations are sequentially carried out:
from the initial value
Figure GDA0003356051700000135
And parameters
Figure GDA0003356051700000136
A single iteration is performed on the tilt tent chaotic system,obtaining a chaotic signal
Figure GDA0003356051700000137
For chaotic signals simultaneously
Figure GDA0003356051700000138
Performing the following integer processing to obtain chaotic signal
Figure GDA0003356051700000139
Figure GDA00033560517000001310
② using chaotic signals
Figure GDA00033560517000001311
For data Ri2Performing reverse diffusion decryption according to the following formula (15) to obtain reverse diffusion decrypted data
Figure GDA00033560517000001312
Figure GDA00033560517000001313
Wherein the content of the first and second substances,
Figure GDA00033560517000001314
and R'02In 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 R'i2、R′i-12And an
Figure GDA00033560517000001315
To the parameters of the chaos system of the inclined tent
Figure GDA00033560517000001316
The adjustment is made in accordance with the following equation (16),
Figure GDA00033560517000001317
thereby obtaining a low-bit value sequence after reverse diffusion decryption
Figure GDA00033560517000001318
Then, forward diffusion decryption of the low-order bit value sequence is carried out
Using external decryption keys
Figure GDA00033560517000001319
Calculating to obtain the initial iteration step number of the chaotic system according to the following formula
Figure GDA00033560517000001320
Figure GDA00033560517000001321
From chaotic sequences
Figure GDA00033560517000001322
To extract
Figure GDA00033560517000001323
An element as an initial value of a chaos system of a tilt tent
Figure GDA00033560517000001324
Obtaining parameters of the chaos system of the inclined tent at the same time
Figure GDA00033560517000001325
Namely, it is
Figure GDA00033560517000001326
Decrypting a sequence of reverse diffusion decrypted low-bit values
Figure GDA00033560517000001327
Each element of D1iWherein
Figure GDA00033560517000001328
The following operations are sequentially carried out:
from the initial value
Figure GDA00033560517000001329
And parameters
Figure GDA00033560517000001330
Performing single iteration on the chaos system of the inclined tent shown as the formula (12) to obtain a chaos signal
Figure GDA00033560517000001331
For chaotic signals simultaneously
Figure GDA00033560517000001332
Performing the following integer processing to obtain chaotic signal
Figure GDA00033560517000001333
Figure GDA0003356051700000141
② using chaotic signals
Figure GDA0003356051700000142
For data D1iForward diffusion decryption is carried out to obtain bidirectional diffusion decrypted data D2i
Figure GDA0003356051700000143
Wherein the content of the first and second substances,
Figure GDA0003356051700000144
and D10In order to spread the decryption key in the forward direction,
③ decrypting the data D1 according to the forward diffusioniAnd D1i-1And
Figure GDA0003356051700000145
to the parameters of the chaos system of the inclined tent
Figure GDA0003356051700000146
The following adjustment is made as follows,
Figure GDA0003356051700000147
thereby obtaining a low-bit value sequence after bidirectional diffusion decryption
Figure GDA0003356051700000148
(4) Transcoding: setting a null character string PP, and carrying out reverse scrambling on the high-digit numerical sequence
Figure GDA0003356051700000149
And the low-bit value sequence after bidirectional diffusion decryption
Figure GDA00033560517000001410
The corresponding elements in the Chinese character data are sequentially converted into numerical values and characters, and the specific conversion relation is expressed as follows,
if it is not
Figure GDA00033560517000001411
Then
If it is not
Figure GDA00033560517000001412
And D2i≧ 250, then 1 space is added in the character sequence PP, i.e., PP ═ PP, "](ii) a Otherwise, using native2unicode (·) function to convert numerical data
Figure GDA00033560517000001413
Converted into single Chinese characters and added to the character sequence PP, i.e.
Figure GDA00033560517000001414
If it is not
Figure GDA00033560517000001415
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)]。
Thereby obtaining a character sequence PP, namely a character string recovered after the decryption of the segment of ciphertext, wherein the length of the character sequence PP is
Figure GDA00033560517000001416
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) converting a certain character string 'character string encryption and decryption 111111 aaaaaaa' into numerical data character by character to obtain a high-order numerical value sequence P1 ═ {215,183,180,188,189,195,0,0,0,0,0,0,0,0, 0} and a low-order numerical value sequence P2 ═ {214,251,174,211,226,220,49,49,49,49,49,49,97,97,97,97,97 }, wherein the lengths of the numerical value sequences P1 and P2 are consistent with the length of the character string and are marked as L18;
(2) first, using an external encryption key (α is 0.12345, β is 0.75), calculating according to the formula in step (2) of the encryption method for a character string in the above embodiment, to obtain an initial iteration step number (m) of the chaotic system1) And an extraction interval (n)1),
m1=513+25=538
n1=9+1=10
Then let the initial value x1α ═ 0.12345 and μ ═ β ═ 0.75, the tilt tent chaotic system shown in step (2) of the encryption method for a character string in the above embodiment iterates to obtain a chaotic sequence X, which is then calculated from the second place538 elements are taken as 1 element every other 10 elements to form a chaotic sequence Y with the length L of 18, wherein the chaotic sequence Y is {0.722203285427244,0.890875205023236,0.074566505410670,0.027605142635845,0.490204576614745,0.736737938553961,0.706512185278734,0.160908579611954,0.909369772129020,0.010038655637092,0.178263702574469,0.045578446993861,0.809369602110701,0.830644585500888,0.781903572849237,0.654761047957817,0.428568530673860,0.790729026121181},
and finally, sorting the chaotic sequence Y in an ascending order, and scrambling the high-order numerical value sequence P1 ═ 215,183,180,188,189,195,0,0,0,0,0,0,0,0,0,0,0 and 0 according to the position change scrambling rule {10,4,12,3,8,11,17,5,16,7,1,6,15,18,13,14,2 and 9} before and after sorting the sequence Y to obtain the scrambled high-order numerical value sequence
Figure GDA0003356051700000151
Figure GDA0003356051700000152
(3) Firstly, forward diffusion encryption of low-order numerical value sequence is carried out
Using the external encryption key (α ═ 0.12345, β ═ 0.75), calculating according to the formula in step (3) of the encryption method for a character string in the above embodiment, to obtain the initial iteration step number (m) of the chaotic system2),
m2=432+48=480
Extracting the 480 th element from the chaotic sequence X as an initial value of the chaotic system of the inclined tent
Figure GDA0003356051700000153
Simultaneously obtaining the parameters (mu) of the chaos system of the inclined tent1=0.75),
For low bit value sequence P2 ═ { P12,P22,...,Pi2,....,P182Each element P in {214,251,174,211,226,220,49,49,49,49,49, 97,97,97,97,97} ═ Pi2The chaos of the tilt tent shown in the formula in step (3) of the encryption method for the character string in the above embodiment is sequentially performedSystem single iteration, integral processing, forward diffusion encryption and inclined tent chaotic system parameter mu1Adjustment, etc., wherein forward diffusion encryption key Y1 is taken046 and C1026, so as to obtain the forward diffusion encrypted low bit value sequence C1 ═ {59,32,0,6,86,62,52,43,12,42,44,26,18,93,34,39,16,71 };
then, reverse diffusion encryption of low-order numerical value sequence is carried out
Using the external encryption key (α ═ 0.12345, β ═ 0.75), calculating according to the formula in step (3) of the encryption method for a character string in the above embodiment, to obtain the initial iteration step number (m) of the chaotic system3),
m3=543+50=593
Extracting 593 th element from the chaos sequence X as an initial value of the tilting tent chaos system
Figure GDA0003356051700000161
Simultaneously obtaining the parameters (mu) of the chaos system of the inclined tent2=0.75),
For low bit value sequence C1 ═ { C11,C12,...,C1i,....,C118Each element C1 in {59,32,0,6,86,62,52,43,12,42,44,26,18,93,34,39,16,71}iSequentially performing single iteration, integer processing, reverse diffusion encryption and tilt tent chaotic system parameter mu shown in formula in step (3) of the encryption method for the character string in the above specific embodiment2Adjustment, 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 {82,71,64,49,26,63,31,10,61,26,18,6,67,63,33,22,22,3 };
(4) the scrambled high-bit numerical sequence is processed
Figure GDA0003356051700000162
Figure GDA0003356051700000163
And the low bit after bidirectional diffusion encryptionConverting each corresponding element in the numerical value sequence C2 ═ 82,71,64,49,26,63,31,10,61,26,18,6,67,63,33,22,22,3 into a numerical value and a character in turn, so as to obtain a character string ciphertext C of "stoke s" (stoke); "will ^ will; zhuangshikimic d' B7.
According to the method for decrypting the character string in the above embodiment, the steps are as follows:
(1) hasty a certain section of ciphertext to be decrypted; "will ^ will; zhuangshikimic d 'B7' is converted into numerical data character by character, and a high-order numerical sequence R1 ═ {0,188,0,180,0,0,0,189,0,0,215,195,0,0, 183,0} and a low-order numerical sequence R2 ═ 115,232,97,210,59,96,64,171,94,59,179,167,100,96,66,55,183,36} are obtained;
(2) first using an external decryption key
Figure GDA0003356051700000164
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 tilt tent chaotic system
Figure GDA0003356051700000165
And an extraction interval
Figure GDA0003356051700000166
Figure GDA0003356051700000171
Figure GDA0003356051700000172
Then order the initial value
Figure GDA0003356051700000173
And parameters
Figure GDA0003356051700000174
The oblique tent shown in step (2) of the decryption method for the character string in the above embodimentThe chaotic system is iterated to obtain a chaotic sequence
Figure GDA0003356051700000175
Take 1 every 10 elements starting with the 538 th element, resulting in a length of
Figure GDA0003356051700000176
Of the chaotic sequence
Figure GDA0003356051700000177
Figure GDA0003356051700000178
Finally, the chaotic sequence is processed
Figure GDA0003356051700000179
Sorting in ascending order, according to sequence
Figure GDA00033560517000001710
The position change scrambling rule {10,4,12,3,8,11,17,5,16,7,1,6,15,18,13,14,2,9} before and after the sorting is carried out, and the high-order bit value sequence R1 is subjected to inverse scrambling to {0,188,0,180,0,0,0,189,0,0,215,195,0,0, 183,0} to obtain an inverse-scrambled high-order bit value sequence
Figure GDA00033560517000001711
Figure GDA00033560517000001712
(3) Firstly, the reverse diffusion decryption of the low-order bit value sequence is carried out
Using external decryption keys
Figure GDA00033560517000001713
Calculating according to the formula in step (3) 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 GDA00033560517000001714
Figure GDA00033560517000001715
From chaotic sequences
Figure GDA00033560517000001716
Extracting 593 th element as initial value of the chaos system of the inclined tent
Figure GDA00033560517000001717
Obtaining parameters of the chaos system of the inclined tent at the same time
Figure GDA00033560517000001718
For low bit value sequences R2 ═ { R12,R22,...,Ri2,....,R182Each element R of {115,232,97,210,59,96,64,171,94,59,179,167,100,96,66,55,183,36 })i2Wherein i is 1,2, 3.. times, 18, the single iteration, the integer processing, the inverse diffusion decryption and the tilt tent chaotic system parameter shown in the formula in step (3) of the decryption method for the character string in the above embodiment are sequentially performed
Figure GDA00033560517000001719
Adjustment, etc., in which the decryption key is fetched in the reverse direction
Figure GDA00033560517000001720
And R'0236, so as to obtain the bidirectional diffusion decrypted low-bit value sequence D1 ═ {59,32,0,6,86,62,52,43,12,42,44,26,18,93,34,39,16,71 };
then, forward diffusion decryption of the low-order bit value sequence is carried out
Using external decryption keys
Figure GDA00033560517000001721
According to the formula in step (3) of the decryption method for character strings in the above embodimentPerforming calculation to obtain the initial iteration step number of the chaotic system
Figure GDA00033560517000001722
Figure GDA0003356051700000181
From chaotic sequences
Figure GDA0003356051700000182
Extracting the 480 th element as the initial value of the chaos system of the tilt tent
Figure GDA0003356051700000183
Obtaining parameters of the chaos system of the inclined tent at the same time
Figure GDA0003356051700000184
Decrypting the sequence of low-bit values D1 ═ D1 after the back diffusion1,D12,...,D1i,...,D118Each element D1 in {59,32,0,6,86,62,52,43,12,42,44,26,18,93,34,39,16,71}iIn the above embodiment, the single iteration, the integer processing, the forward diffusion decryption and the tilt tent chaotic system parameter shown in the formula in step (3) of the decryption method for the character string in the above embodiment are sequentially performed
Figure GDA0003356051700000185
Adjustment, etc., in which forward diffusion decryption keys are fetched
Figure GDA0003356051700000186
And D1026, so as to obtain a bidirectional diffusion decrypted low-bit value sequence D2 ═ {214,251,174,211,226,220,49,49,49,49,49,49,97,97,97,97,97 };
(4) the high-order digit value sequence after the reverse scrambling is carried out
Figure GDA0003356051700000187
And carrying out numerical value and character conversion on the low-digit numerical value sequence D2 subjected to bidirectional diffusion decryption to obtain a character sequence PP, namely the character string recovered after decryption of the section of ciphertext is 'character string encryption and decryption 111111 aaaaaa'.
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.75000000000001; 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 GDA0003356051700000188
Figure GDA0003356051700000191
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 GDA0003356051700000192
Figure GDA0003356051700000201
Figure GDA0003356051700000211
As can be seen from the above specific embodiments 2 and 3, the character string ciphertext generated by the character 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 character string to be encrypted, so that the character 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 character string, a certain section of ciphertext to be decrypted is's hard a hurry; "will ^ will; zhuangshikim d' B7 vendor $ ", a string decryption procedure similar to embodiment 1, only with slight changes in decryption key:
Figure GDA0003356051700000212
or
Figure GDA0003356051700000213
Or
Figure GDA0003356051700000214
Or D1027; or
Figure GDA0003356051700000215
Or R'02The string ciphertext decryption result is shown in table 3, 37. As can be seen from Table 3, the small change of the decryption key causes the result of decryption of the ciphertext to be very largeThe recovered character string is useless information, so that the decryption method of the character string has sensitivity to the decryption key.
TABLE 3 ciphertext decipher result when external decipher key is changed slightly
Figure GDA0003356051700000216
Figure GDA0003356051700000221
Example 5
According to the above method for decrypting a string, the decryption steps are similar to those in embodiment 1, and only a certain segment of string ciphertext to be decrypted ("s diffa hasty; '@ will ^; zhuyu d' B7 vendor") is slightly changed: "S diffa hurry; "will ^ will; zhuangshikimic d' B7 dealer $; or "s diffa:," @ will ^; zhuangshikimic d' B7 dealer $; or "s diffa hurry; "said ^ a,; zhuangshikimic d' B7 dealer $; or "s diffa hurry; "will ^ will; zhuangshikimic c' B7 dealer $; or "s diffa hurry; "will ^ will; zhuangshikimic d' B7 meal $; or "s diffa hurry; "will ^ will; zhuangshikimic acid d' B7 vendor & "; or "hard sa hurry; "will ^ will; zhuangshikimic d' B7 dealer $; or "s diffa hurry; "will ^ will; zhuangshikimic d' B7$ vendor ", the string decryption result is 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 GDA0003356051700000222
Figure GDA0003356051700000231
Figure GDA0003356051700000241

Claims (6)

1. A method for encrypting character strings is characterized by comprising the following steps:
(1) transcoding: converting a certain character string into numerical data one by one to obtain a high-order numerical sequence P1 ═ P11,P21,...,Pi1,....,PL1And a low order value sequence P2 ═ P12,P22,...,Pi2,....,PL2The length of the numerical value sequences P1 and P2 is consistent with the length of the character string, and is marked as L;
(2) scrambling of high-bit value sequences:
firstly, respectively calculating initial iteration step numbers m of the chaotic system by using external encryption keys (alpha and beta) according to a formula (1) shown below1And an extraction interval n1
Figure FDA0003356051690000011
Then let the initial value x1The tilt tent chaotic system shown in the following formula (2) is iterated with α and μ as β, k denotes the number of iterations, and x denotes the number of iterationsk+1Denotes the chaotic signal obtained in the k-th iteration, where k is 1, 2.,
Figure FDA0003356051690000012
obtaining a chaotic sequence X from m1Element start every n1Taking 1 element to form a chaotic sequence Y with the length of L,
and finally, sequencing the chaotic sequence Y in an ascending order, and according to the position change scrambling rule before and after sequencing the sequence Y, setting the high-digit value sequence P1 as { P }11,P21,...,Pi1,....,PL1Scrambling to obtainScrambled high bit number sequence
Figure FDA0003356051690000013
(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 FDA0003356051690000014
Extracting mth from chaos sequence X2An element as an initial value of a chaos system of a tilt tent
Figure FDA0003356051690000015
Simultaneously obtaining the parameter mu of the chaos system of the inclined tent1I.e. mu1=β,
For low bit value sequence P2 ═ { P12,P22,...,Pi2,....,PL2Each element P ini2Wherein i 1,2,3, L, in this order:
from the initial value
Figure FDA0003356051690000021
And the parameter mu1Performing single iteration on the chaos system of the inclined tent shown in the formula (2) to obtain a chaos signal
Figure FDA0003356051690000022
For chaotic signals simultaneously
Figure FDA0003356051690000023
Performing integer processing according to the following formula (4) to obtain chaotic signal Y1i
Figure FDA0003356051690000024
② using chaotic signal Y1iFor data Pi2Forward diffusion encryption is performed according to the following formula (5) to obtain a forward diffusion encrypted ciphertext C1i
Figure FDA0003356051690000025
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 FDA0003356051690000026
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 FDA0003356051690000027
Extracting mth from chaos sequence X3An element as an initial value of a chaos system of a tilt tent
Figure FDA00033560516900000212
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 FDA0003356051690000028
And the parameter mu2Performing single iteration on the chaos system of the inclined tent shown in the formula (2) to obtain a chaos signal
Figure FDA0003356051690000029
For chaotic signals simultaneously
Figure FDA00033560516900000210
Performing integer processing according to the following formula (8) to obtain chaotic signal Y2i
Figure FDA00033560516900000211
② using chaotic signal Y2iFor data C1iPerforming reverse diffusion encryption according to the following formula (9) to obtain a bidirectional diffusion encrypted ciphertext C2i
Figure FDA0003356051690000031
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 FDA0003356051690000032
thereby obtaining the low-bit value sequence C2 ═ { C2 ═ C2 after bidirectional diffusion encryption1,C22,...,C2i,...,C2L};
(4) Transcoding: the scrambled high-bit numerical sequence is processed
Figure FDA0003356051690000033
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 FDA0003356051690000034
And is
Figure FDA0003356051690000035
2. The method for encrypting a character string according to claim 1, wherein: converting a certain character string into numerical data one by one in the step (1), wherein the certain character string comprises displayable ASCII characters except for blank spaces and 6763 double-byte coded Chinese characters in a GB2312 character set; 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, numerical bit data]Or converting displayable ASCII code characters into ASCII code numerical data expressed as [0, ASCII code numerical data]All can use [ Pi1,Pi2]Indicating that the corresponding data combination results in a high bit value sequence P1 ═ { P ═ P11,P21,...,Pi1,....,PL1And a low order value sequence P2 ═ P12,P22,...,Pi2,....,PL2}。
3. The method for encrypting a character string according to claim 1, wherein: the high-order digit value sequence after scrambling in the step (4)
Figure FDA0003356051690000036
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 sequence C, and sequencing the scrambled high-digit numerical values
Figure FDA0003356051690000037
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 FDA0003356051690000038
Then
First, if it is determined
Figure FDA0003356051690000041
And (C2)i+161) ≧ 250, then 1 space is added to character sequence C, i.e., C ═ C, '']Are combined with
Figure FDA0003356051690000042
Then using native2unicode (·) function to convert numerical data
Figure FDA0003356051690000043
Converted into single Chinese characters and added to the character sequence C, i.e.
Figure FDA0003356051690000044
If it is not
Figure FDA0003356051690000045
Then
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: a certain segment of character string cryptograph to be decrypted
Figure FDA0003356051690000046
Converting the characters one by one into numerical data to obtain a high-order numerical sequence
Figure FDA0003356051690000047
And low bit number value sequence
Figure FDA0003356051690000048
Wherein the length of the numerical sequences R1, R2 is
Figure FDA0003356051690000049
Some segment of character string cryptograph to be decrypted
Figure FDA00033560516900000410
Has a length of
Figure FDA00033560516900000427
(2) Descrambling of high-bit numerical sequences:
first using an external decryption key
Figure FDA00033560516900000411
Respectively calculating to obtain initial iteration steps of the chaotic system according to a formula (11) shown below
Figure FDA00033560516900000412
And an extraction interval
Figure FDA00033560516900000413
Figure FDA00033560516900000414
Then order the initial value
Figure FDA00033560516900000415
And parameters
Figure FDA00033560516900000416
The tilt tent chaotic system shown in the following formula (12) is iterated, k represents the number of iterations,
Figure FDA00033560516900000417
denotes the chaotic signal obtained in the k-th iteration, where k is 1, 2.,
Figure FDA00033560516900000418
obtaining a chaotic sequence
Figure FDA00033560516900000419
From the first
Figure FDA00033560516900000420
Element start every other
Figure FDA00033560516900000421
Each element is 1, thereby forming a length of
Figure FDA00033560516900000422
Of the chaotic sequence
Figure FDA00033560516900000423
Finally, the chaotic sequence is processed
Figure FDA00033560516900000424
Sorting in ascending order, according to sequence
Figure FDA00033560516900000425
The position change scrambling rule before and after sorting is used for high-digit value sequence
Figure FDA00033560516900000426
Performing inverse scrambling to obtain an inverse-scrambled high-bit value sequence
Figure FDA0003356051690000051
(3) 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 FDA0003356051690000052
Calculating according to the following formula (13) to obtain the initial iteration step number of the chaotic system
Figure FDA0003356051690000053
Figure FDA0003356051690000054
From chaotic sequences
Figure FDA0003356051690000055
To extract
Figure FDA0003356051690000056
An element as an initial value of a chaos system of a tilt tent
Figure FDA0003356051690000057
Obtaining parameters of the chaos system of the inclined tent at the same time
Figure FDA0003356051690000058
Namely, it is
Figure FDA0003356051690000059
For low-order bit value sequence
Figure FDA00033560516900000510
Each of the elements Ri2Wherein
Figure FDA00033560516900000511
The following operations are sequentially carried out:
from the initial value
Figure FDA00033560516900000512
And parameters
Figure FDA00033560516900000513
Performing single iteration on the chaos system of the inclined tent shown as the formula (12) to obtain a chaos signal
Figure FDA00033560516900000514
For chaotic signals simultaneously
Figure FDA00033560516900000515
Performing integer processing according to the following formula (14) to obtain chaotic signal
Figure FDA00033560516900000516
Figure FDA00033560516900000517
② using chaotic signals
Figure FDA00033560516900000518
For data Ri2Performing reverse diffusion decryption according to the following formula (15) to obtain a reverse diffusion solutionSecret data
Figure FDA00033560516900000519
Figure FDA00033560516900000520
Wherein the content of the first and second substances,
Figure FDA00033560516900000521
and R'02In 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 R'i2、R′i-12And an
Figure FDA00033560516900000522
To the parameters of the chaos system of the inclined tent
Figure FDA00033560516900000523
The adjustment is made in accordance with the following equation (16),
Figure FDA00033560516900000524
thereby obtaining a low-bit value sequence after reverse diffusion decryption
Figure FDA00033560516900000525
Then, forward diffusion decryption of the low-order bit value sequence is carried out
Using external decryption keys
Figure FDA00033560516900000526
Calculating according to the following formula (17) to obtain the initial iteration step number of the chaotic system
Figure FDA0003356051690000061
Figure FDA0003356051690000062
From chaotic sequences
Figure FDA0003356051690000063
To extract
Figure FDA0003356051690000064
An element as an initial value of a chaos system of a tilt tent
Figure FDA0003356051690000065
Obtaining parameters of the chaos system of the inclined tent at the same time
Figure FDA0003356051690000066
Namely, it is
Figure FDA0003356051690000067
Decrypting a sequence of reverse diffusion decrypted low-bit values
Figure FDA0003356051690000068
Each element of D1iWherein
Figure FDA0003356051690000069
The following operations are sequentially carried out:
from the initial value
Figure FDA00033560516900000610
And parameters
Figure FDA00033560516900000611
Performing single iteration on the chaos system of the inclined tent shown as the formula (12) to obtain a chaos signal
Figure FDA00033560516900000612
For chaotic signals simultaneously
Figure FDA00033560516900000613
Performing integer processing according to the following formula (18) to obtain chaotic signal
Figure FDA00033560516900000614
Figure FDA00033560516900000615
② using chaotic signals
Figure FDA00033560516900000616
For data D1iForward diffusion decryption is performed according to the following formula (19) to obtain bidirectional diffusion decrypted data D2i
Figure FDA00033560516900000617
Wherein the content of the first and second substances,
Figure FDA00033560516900000618
and D10In order to spread the decryption key in the forward direction,
③ decrypting the data D1 according to the forward diffusioniAnd D1i-1And
Figure FDA00033560516900000619
to the parameters of the chaos system of the inclined tent
Figure FDA00033560516900000620
The adjustment is made according to the following equation (20),
Figure FDA00033560516900000621
thereby obtaining a low-bit value sequence after bidirectional diffusion decryption
Figure FDA00033560516900000622
(4) Transcoding: the high-order digit value sequence after the reverse scrambling is carried out
Figure FDA00033560516900000623
And the low-bit numerical sequence D2 after bidirectional diffusion decryption is carried out, the numerical value and the character are converted to obtain a character sequence PP, namely the character string recovered after the decryption of the character string to be decrypted, wherein the length of the character sequence PP is
Figure FDA00033560516900000624
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 FDA00033560516900000625
Converting the characters one by one into numerical data to obtain a high-order numerical sequence
Figure FDA00033560516900000626
And low bit number value sequence
Figure FDA00033560516900000627
The 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 [ R ]i1,Ri2]Represents;
then the numerical data [ Ri1,Ri2]Correspondingly combining to obtain high-order numerical value sequence
Figure FDA0003356051690000071
And low bit number value sequence
Figure FDA0003356051690000072
Wherein
Figure FDA0003356051690000073
Then check the low-order numerical value sequence R2 one by one to see if there is Ri2An 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 FDA0003356051690000074
And low bit number value sequence
Figure FDA0003356051690000075
6. The method for decrypting character string according to claim 4, wherein: the high-order digit value sequence after the reverse scrambling in the step (4)
Figure FDA0003356051690000076
And the low-order digit value sequence D2 after bidirectional diffusion decryption is used for converting the numerical value and the character, and the conversion relation is expressed as follows:
setting a null character sequence PP, and carrying out reverse scrambling on the high-digit numerical sequence
Figure FDA0003356051690000077
And the low-bit value sequence after bidirectional diffusion decryption
Figure FDA0003356051690000078
The corresponding elements in the sequence are operated as follows,
if it is not
Figure FDA0003356051690000079
Then
If it is not
Figure FDA00033560516900000710
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
Figure FDA00033560516900000711
Converted into single Chinese characters and added to the character sequence PP, i.e.
Figure FDA00033560516900000712
If it is not
Figure FDA00033560516900000713
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)]。
CN201910215951.3A 2019-03-21 2019-03-21 Encryption method and decryption method for character string Active CN109981246B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910215951.3A CN109981246B (en) 2019-03-21 2019-03-21 Encryption method and decryption method for character string

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910215951.3A CN109981246B (en) 2019-03-21 2019-03-21 Encryption method and decryption method for character string

Publications (2)

Publication Number Publication Date
CN109981246A CN109981246A (en) 2019-07-05
CN109981246B true CN109981246B (en) 2021-12-17

Family

ID=67079846

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910215951.3A Active CN109981246B (en) 2019-03-21 2019-03-21 Encryption method and decryption method for character string

Country Status (1)

Country Link
CN (1) CN109981246B (en)

Families Citing this family (3)

* 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
CN110650005B (en) * 2019-09-17 2022-02-01 南通大学 Chinese and English character string encryption method
CN114500035B (en) * 2022-01-24 2023-06-23 杭州天宽科技有限公司 Data encryption system based on service data sharing cloud platform

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
CN109472338A (en) * 2018-11-19 2019-03-15 南通大学 A kind of Mass production method of commodity anti-counterfeit two-dimensional bar code

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103532701B (en) * 2013-10-16 2014-09-10 南通纺织职业技术学院 Encryption and decryption method for numeric type data

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
CN109472338A (en) * 2018-11-19 2019-03-15 南通大学 A kind of Mass production method of commodity anti-counterfeit two-dimensional bar code

Non-Patent Citations (5)

* Cited by examiner, † Cited by third party
Title
A novel bit-level image encryption scheme using hyper-chaotic systems;Suying Sheng,Xinhua Wu;《IEEE》;20130725;全文 *
A novel chaos-based image encryption scheme using coupled map lattices;Xinhua Wu;《IEEE》;20130725;全文 *
基于斜帐篷混沌映射和Arnold变换的图像加密方案;李春虎等;《计算机应用研究》;20171115(第11期);全文 *
基于有限状态斜帐篷映射的图像加密算法;张子振;《湖南理工学院学报(自然科学版)》;20101215;全文 *
基于混沌序列置乱与扩散变换的彩色数字图像加密算法;张芳君等;《软件导刊》;20180905;全文 *

Also Published As

Publication number Publication date
CN109981246A (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
CN105847629A (en) Reversible information hiding method for encrypted image
Abdulzahra et al. Combining cryptography and steganography for data hiding in images
Sinha et al. Encrypted information hiding using audio steganography and audio cryptography
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
Miss et al. Fuzzy logic based image encryption for confidential data transfer using (2, 2) secret sharing scheme
Su et al. A robust visual image encryption scheme based on controlled quantum walks
Bandekar et al. LSB based text and image steganography using AES algorithm
Kundu et al. A secure approach to audio steganography
CN116192360A (en) Asymmetric visual sense meaningful image encryption method based on 2D compressed sensing
CN110278066B (en) Encryption and decryption method for Chinese character string
CN110287713B (en) Encryption method and decryption method for Chinese character string
Sivakumar et al. Generation of random key stream using word grid puzzle for the applications of cryptography
Mishra et al. Image encryption technique based on chaotic system and hash function
Barakat et al. Securing Digital Image using Modified Chaotic Logistic Key
Reddy Improved secure data transfer using video steganographic technique
Bremnavas et al. Medical image security using LSB and chaotic logistic map
Sharma et al. Steganography techniques using cryptography-a review paper
Jumaa Hiding of random permutated encrypted text using lsb steganography with random pixels generator
CN103746793A (en) Number form text encryption and decryption methods
Zyara Suggested Method for Encryption and Hiding‎ Image using LCG and LSB
Manideep et al. Information Hiding Secretly Using Image Steganography

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