CN115544551B - Data encryption method for MCU singlechip operating system - Google Patents

Data encryption method for MCU singlechip operating system Download PDF

Info

Publication number
CN115544551B
CN115544551B CN202211495804.4A CN202211495804A CN115544551B CN 115544551 B CN115544551 B CN 115544551B CN 202211495804 A CN202211495804 A CN 202211495804A CN 115544551 B CN115544551 B CN 115544551B
Authority
CN
China
Prior art keywords
letter
sequence
matrix
frequency
letters
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
CN202211495804.4A
Other languages
Chinese (zh)
Other versions
CN115544551A (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.)
Beijing Sizhong Electronic Technology Co ltd
Original Assignee
Beijing Sizhong Electronic Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Sizhong Electronic Technology Co ltd filed Critical Beijing Sizhong Electronic Technology Co ltd
Priority to CN202211495804.4A priority Critical patent/CN115544551B/en
Publication of CN115544551A publication Critical patent/CN115544551A/en
Application granted granted Critical
Publication of CN115544551B publication Critical patent/CN115544551B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/602Providing cryptographic facilities or services
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2211/00Indexing scheme relating to details of data-processing equipment not covered by groups G06F3/00 - G06F13/00
    • G06F2211/007Encryption, En-/decode, En-/decipher, En-/decypher, Scramble, (De-)compress
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2221/00Indexing scheme relating to security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F2221/21Indexing scheme relating to G06F21/00 and subgroups addressing additional information or applications relating to security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F2221/2107File encryption

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • General Health & Medical Sciences (AREA)
  • Computer Hardware Design (AREA)
  • Computer Security & Cryptography (AREA)
  • Health & Medical Sciences (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Bioethics (AREA)
  • Compression, Expansion, Code Conversion, And Decoders (AREA)
  • Storage Device Security (AREA)

Abstract

The invention relates to the technical field of data processing, in particular to a data encryption method of an MCU singlechip operating system, which comprises the following steps: the letter matrix is partitioned, a second candidate letter and a first letter combination are obtained according to the frequency of each letter in each partitioned letter matrix, total runlength and larger total frequency are further obtained, large-run disorder and small-run disorder are carried out according to the larger total frequency predicted by the total runlength, and an alphanumeric mapping table is obtained; each letter in the block letter matrix is chain encrypted according to the alphanumeric mapping table and the alternative letter sequence of each letter. The method has the advantages of large disorder among ciphertexts, large difficulty in breaking, simple encryption method and small calculation amount, and ensures the safety of program code storage.

Description

Data encryption method for MCU singlechip operating system
Technical Field
The invention relates to the technical field of data processing, in particular to a data encryption method of an MCU singlechip operating system.
Background
The method is characterized in that a program code is encrypted through a password, so that the program is changed into a ciphertext, and the method is a common MCU encryption mode. However, such protection measures are fragile and easy to crack, and an attacker of the single chip microcomputer can extract key information from the chip by using bugs or software defects on the design of the single chip microcomputer chip through various technical means by means of special equipment or self-made equipment to obtain the program in the single chip microcomputer.
Based on the above, the invention provides a data encryption method of an MCU singlechip operating system, which combines the letter probability in plain text to perform self-adaptive setting on an alphanumeric mapping table in the encryption process, on one hand, the encryption method is simple and has small calculation amount, and on the other hand, the difference between the encrypted ciphertext and the original plaintext is large, so that an attacker is difficult to obtain effective information from the ciphertext, and is difficult to crack under the condition of not knowing a secret key, thereby ensuring the safety of program code storage.
Disclosure of Invention
The invention provides a data encryption method of an MCU singlechip operating system, which aims to solve the existing problems.
The data encryption method of the MCU singlechip operating system adopts the following technical scheme:
an embodiment of the invention provides a data encryption method of an MCU singlechip operating system, which comprises the following steps:
acquiring a replaceable letter sequence of each letter in the letter sequence; acquiring a letter matrix; partitioning the letter matrix to obtain a plurality of partitioned letter matrices;
acquiring the frequency of each letter in the block letter matrix and the average frequency of the letters;
when the frequency of each letter is less than or equal to 5 times of the average frequency of the letters, randomly arranging all the letters in the letter sequence to obtain an alphanumeric mapping table; otherwise, taking the letters with the frequency more than 5 times of the average frequency of the letters as first candidate letters; acquiring a second candidate letter according to the replaceable letter sequence and the letter sequence of each first candidate letter, acquiring total run length and maximum run length according to the second candidate letter, combining all the first candidate letters in pairs to obtain a first letter combination, and acquiring the larger total frequency according to all the first letter combinations; when the total run length is larger than or equal to the larger total frequency, the character sequence is firstly subjected to large run length disorder operation and then subjected to small run length disorder operation to obtain a disorder sequence, and the disorder sequence is used as a character-number mapping table; when the total run-length is smaller than the larger total frequency, the character sequence is subjected to small run-length disorder operation firstly and then large run-length disorder operation to obtain a disorder sequence, and the disorder sequence is used as an alphanumeric mapping table;
and sequentially taking each letter in the block letter matrix as a letter to be encrypted, when the letter to be encrypted is the first letter in the block letter matrix, taking the first element in the replaceable letter sequence of the letter to be encrypted as a ciphertext of the letter to be encrypted, when the letter to be encrypted is not the first letter in the block letter matrix, acquiring the order of the ciphertext of the previous letter of the letter to be encrypted in the block letter matrix in an alphanumeric mapping table, taking the order as the first order, acquiring the element at the first order position of the replaceable letter sequence of the letter to be encrypted as the ciphertext of the letter to be encrypted, and storing the ciphertext.
Preferably, the large run out-of-order operation comprises:
dividing an input sequence into a plurality of maximum runs
Figure 100002_DEST_PATH_IMAGE001
The sub-sequence of (1), the first in the sub-sequence
Figure 12478DEST_PATH_IMAGE002
An element asDivision points of which
Figure DEST_PATH_IMAGE003
Taking an element before a division point as a first element block, taking the division point and an element after the division point as a second element block, and splicing the first element block after the second element block to obtain a disordered subsequence; and splicing all the disordered subsequences according to the sequence of the subsequences to obtain the disordered sequence.
Preferably, the small run out-of-order operation includes:
and when the second element and the first element are adjacent in the alphabetical list, acquiring an element which is not adjacent to the first element in the alphabetical list, is positioned behind the first element in the input sequence and is closest to the first element as a third element, and exchanging positions of the third element and the second element.
Preferably, the alternative letter sequence of each letter in the acquired letter sequence includes:
the alternative letter sequence for each letter in the letter sequence includes all of the letters in the letter sequence and has a length of 26; all letters in the letter sequence have different elements in the same ordinal position in the alternative letter sequence.
Preferably, the blocking the alphabet matrix to obtain a plurality of blocked alphabet matrices includes:
converting the letter matrix into a digital matrix, and decomposing the digital matrix to obtain a sparse matrix; converting the sparse matrix into a sequence curve, converting the sequence curve into a frequency domain, and acquiring the reciprocal of the maximum frequency in the frequency domain as a period;
dividing the period by the number of columns of the letter matrix and rounding upwards to obtain the block length, dividing the letter matrix into a plurality of block letter matrices according to the block length, wherein the number of columns of the block letter matrices is equal to that of the letter matrix, and the number of rows of the block letter matrices is equal to that of the blocks.
Preferably, the obtaining the frequency of each letter and the average frequency of letters in the block letter matrix includes:
and counting the frequency of each letter and the number of the types of all the letters in the block letter matrix, and taking the reciprocal of the number of the types as the average frequency of the letters.
Preferably, the obtaining the second candidate letter according to the alternative letter sequence of each first candidate letter and the letter sequence comprises:
set a value to
Figure 906135DEST_PATH_IMAGE004
The cumulative number of differences of (1), the first element in the alternative letter sequence of the first candidate letter is taken as the fourth element;
the fourth element is subjected to difference judgment, and the packet
Comprises the following steps: acquiring the next element of the fourth element in the replaceable letter sequence as a fifth element, and if the fifth element and the fourth element are not adjacent in the letter sequence, adding one to the difference cumulative number to take the fifth element as a new fourth element;
repeating the difference judgment operation on the new fourth element until the fifth element does not exist, stopping iteration, and dividing the accumulated number of the differences when the iteration is stopped by the value obtained by subtracting one from the length of the replaceable letter sequence to obtain the difference of the first candidate letter;
and taking the first candidate letter with the difference smaller than a first preset threshold value as a second candidate letter.
Preferably, the obtaining of the total run length and the maximum run length according to the second candidate letter comprises:
expressing each second candidate letter in the block letter matrix by using 1, expressing each element except 1 by using 0, calculating the ratio of the number of 1 to the number of 0 blocks to obtain the run-length of each second candidate letter, and dividing the run-length of each second candidate letter by the maximum value of the run-length of all second candidate letters to obtain the normalized run-length of each second subsequent letter; taking the sum of the normalized runability of all the second candidate letters as the total runability;
and acquiring the frequency of all runs of each second candidate letter in the block letter matrix, and taking the run corresponding to the maximum frequency in the runs of all the second candidate letters as the maximum run.
Preferably, the obtaining the total frequency greater according to all the first letter combinations includes:
acquiring the frequency number of each first letter combination in the block letter matrix as the first frequency number of each first letter combination; clustering all the first letter combinations into two types according to the first frequency of all the first letter combinations by using a clustering algorithm, and taking each first letter combination in the category with a large first frequency average value as a second letter combination;
dividing the first frequency count of each second letter combination by the maximum value in the first frequency counts of all the second letter combinations to obtain the frequency count of each second letter combination, wherein the frequency count is larger; and taking the sum of the frequency larger characters of all the second letter combinations as the total frequency larger character.
The technical scheme of the invention has the beneficial effects that:
1. because the letter types and the number of the letters in different block letter matrixes are different from each other, the letter-number mapping tables of the different block letter matrixes are adaptively set according to the frequency information of each letter in the block letter matrixes, so that the difference between the different block letter matrixes is increased, even if the letters of the two block letter matrixes are the same, the letter-number mapping tables are different, and the corresponding replaced letters are different, on one hand, the disorder among ciphertexts can be increased, and the cracking difficulty is increased; on the other hand, the calculation of the letter frequency is a very simple method, namely, the encryption method is simple, the calculation amount is small, and a good encryption effect can be achieved;
2. the next letter is encrypted by combining the ciphertext of the previous letter, so that the ciphertexts of different letters have strong correlation, if one letter is changed, the ciphertexts of all the following letters are changed, the disorder of the ciphertexts is increased, the difference between the ciphertexts after encryption and the original plaintext is large, an attacker is further difficult to obtain effective information from the ciphertexts, and the ciphertexts are difficult to crack under the condition of not knowing a secret key, so that the safety of program code storage is improved;
3. the data volume of the letter matrix is large, on one hand, the whole encryption easily causes an attacker to intercept and obtain a ciphertext and then tamper the ciphertext, which directly causes a large amount of data errors, on the other hand, the method can decrypt and obtain all the plaintext after the attacker guesses a secret key, and blocks the letter matrix, and encrypts each block letter matrix by using different alphanumeric mapping tables, on the one hand, the attacker cannot cause a large amount of data errors even if tampering the ciphertext of one block letter matrix, but only causes the data errors of the corresponding block letter matrix, and on the other hand, the attacker only causes the content of the block letter matrix corresponding to the part of the secret key to be leaked, and cannot cause all the plaintext to be leaked even if guessing the part of the secret key. The robustness of the encryption method is enhanced through the blocking, so that the program code is stored more safely.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
FIG. 1 is a flow chart of the steps of a data encryption method of an MCU singlechip operating system according to the invention;
FIG. 2 is a schematic diagram of an alphabet matrix-to-digital matrix of the data encryption method of the MCU singlechip operating system of the invention;
FIG. 3 is a schematic diagram of an encryption process of the data encryption method of the MCU singlechip operating system according to the invention.
Detailed Description
In order to further explain the technical means and effects of the present invention adopted to achieve the predetermined purpose, the following detailed description, with reference to the accompanying drawings and preferred embodiments, describes a data encryption method of the MCU one-chip microcomputer operating system according to the present invention, and its specific implementation, structure, features and effects thereof. In the following description, different "one embodiment" or "another embodiment" refers to not necessarily the same embodiment. Furthermore, the particular features, structures, or characteristics may be combined in any suitable manner in one or more embodiments.
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs.
The following describes a specific scheme of the data encryption method of the MCU singlechip operating system provided by the invention in detail with reference to the accompanying drawings.
Referring to fig. 1, a flowchart of steps of a data encryption method for an MCU monolithic processor operating system according to an embodiment of the present invention is shown, where the method includes the following steps:
and S001, acquiring letters in the program, and converting the letters into a letter matrix.
It should be noted that, the number of english letters is 26, and the probability of repeated words existing in the program is high, so that the partial letter arrangement has a certain rule. The data can be blocked, and different keys are set for the data of different blocks to prevent the encrypted ciphertext from reflecting the arrangement rule of letters in the plaintext. In order to block data, the data needs to be converted into a matrix format first.
In this embodiment, the number of letters in the program is first obtained by statistics, and all the letters in the program are converted into a matrix with similar rows and columns, which is called a letter matrix, according to the number of letters. For example: a 100 letter program translates into a 10 x 10 letter matrix. In the conversion process, if the number of letters in a certain row or a certain column is less than the number of columns or rows, 0 complementing operation is performed on the row or the column. It should be noted that, in the present embodiment, only the letters in the program are converted into the matrix format, and other data, such as symbols and numbers in the program, are not changed.
And S002, partitioning the letter matrix to obtain a partitioned letter matrix.
It should be noted that, when the alphabet matrix is partitioned, the alphabet matrix may be partitioned according to the periodicity of the alphabet data in the alphabet matrix, and each block is encrypted by using different keys, so that the periodicity of the plaintext is not reflected in the ciphertext. RPCA (robust principal component analysis) is a method for decomposing an original matrix into a low-rank matrix and a sparse matrix, wherein different rows of the low-rank matrix are linearly related and can represent the relation or similar characteristics between the different rows, the sparse matrix is equivalent to noise data, and if the noise data of certain rows are similar, the relevance of the corresponding rows on the original matrix is large, so that the original matrix can be partitioned by calculating the data rule in the sparse matrix. Since RPCA is directed to a number matrix, the letter matrix is first converted to a number matrix.
In this embodiment, each letter in the letter matrix is used in
Figure DEST_PATH_IMAGE005
The order in English alphabet is used for representation, and a number matrix is obtained. As shown in fig. 2, letters
Figure 204261DEST_PATH_IMAGE006
Is composed of
Figure 152625DEST_PATH_IMAGE005
The first element of the English alphabet, and thus the letters of the alphabet matrix
Figure 74576DEST_PATH_IMAGE006
The value of the element of the corresponding position in the number matrix is
Figure 108391DEST_PATH_IMAGE007
Letter of Chinese character
Figure 272525DEST_PATH_IMAGE008
Is composed of
Figure 964144DEST_PATH_IMAGE005
A second element of the English alphabet, thus a letter of the alphabet matrix
Figure 306264DEST_PATH_IMAGE008
Elements of corresponding positions in the number matrixHas a value of
Figure 342222DEST_PATH_IMAGE009
The letters in the letter matrix
Figure 60779DEST_PATH_IMAGE010
The value of the element of the corresponding position in the number matrix is
Figure 875414DEST_PATH_IMAGE011
It should be noted that the periodicity of the alphabet matrix is not calculated directly, but calculated after the digit matrix is decomposed by the RPCA, because the result obtained by calculating the periodicity directly by the alphabet matrix can only represent the overall similarity between different data, and cannot represent the trend similarity, for example
Figure 637702DEST_PATH_IMAGE012
And
Figure 911689DEST_PATH_IMAGE013
the data change trends of (1) are different, but the cosine similarity is large, and the cosine similarity can only represent the overall similarity between the data and cannot represent the trend similarity. And the low-rank matrix obtained by RPCA decomposition represents the relation among data, the same characteristics among all data of the original matrix are represented, and the trend similarity among different data of the original matrix can be obtained by analyzing the sparse matrix, wherein the sparse matrix represents the unique characteristics of each data of the original matrix. Therefore, in the embodiment, the original matrix is partitioned according to the data rule of the sparse matrix after RPCA decomposition.
In this embodiment, after the letter matrix is converted into the number matrix, a sparse matrix is obtained through RPCA decomposition, a mode that adjacent rows of the sparse matrix are connected (the beginning of the second row is connected to the end of the first row, and the beginning of the third row is connected to the end of the second row) is converted into a sequence curve, the sequence curve is converted into a frequency domain by fourier transform, and the maximum frequency in the frequency domain is obtained. The maximum frequency reflects the most frequent change of the data, and the period corresponding to the maximum frequency is taken as the period of the letter matrix to reflect the change rule of the data in the letter matrix. The period corresponding to the maximum frequency is the inverse of the maximum frequency.
The size of the period reflects the number of data in the period, the period is divided by the number of columns of the letter matrix and rounded up, the obtained result is taken as the block length, and the block length reflects the closest number of rows of the period size in the letter matrix. And dividing the letter matrix into a plurality of block letter matrixes according to the block length, wherein the column number of each block letter matrix is equal to that of the letter matrix, and the row number of each block letter matrix is equal to the block length. E.g. number of rows of letter matrix
Figure 785667DEST_PATH_IMAGE014
Block length of
Figure 609136DEST_PATH_IMAGE011
Time, letter matrix
Figure 919156DEST_PATH_IMAGE007
To
Figure 946018DEST_PATH_IMAGE011
Action first block letter matrix, letter matrix
Figure 131012DEST_PATH_IMAGE015
To
Figure 776364DEST_PATH_IMAGE016
Act second block letter matrix, letter matrix
Figure 853691DEST_PATH_IMAGE017
To
Figure 728368DEST_PATH_IMAGE014
The behavior is the third block letter matrix.
Therefore, the blocking of the letter matrix is realized, and the blocking letter matrix is obtained. The purpose of blocking is that because the similarity between different blocking letter matrixes in the letter matrix is larger, in order to not embody the information in the ciphertext and increase the cracking difficulty, the different blocking letter matrixes are encrypted by using different keys by blocking the letter matrix, so that the ciphertext is more complex and is difficult to crack. Meanwhile, due to the fact that the data volume of the letter matrix is large, on one hand, an attacker is easy to capture the ciphertext and then tamper the ciphertext after intercepting the ciphertext to directly cause a large number of data errors, on the other hand, the attacker can decrypt the ciphertext to obtain all plaintext after guessing the key to obtain the other method, the letter matrix is partitioned, and each partitioned letter matrix is encrypted by using different keys respectively. The robustness of the encryption method is enhanced by blocking.
And S003, acquiring a replaceable letter sequence of each letter in each block letter matrix.
The English letters are
Figure 592419DEST_PATH_IMAGE005
If the letter sequence table is used as the letter sequence, the encryption end and the decryption end agree in advance with the replaceable letter sequence of each letter in the letter sequence, and the length of the replaceable letter sequence of each letter is
Figure 467445DEST_PATH_IMAGE005
And comprise all
Figure 493170DEST_PATH_IMAGE005
The sequence of the English letters, and the elements of the same sequence position in the replaceable letter sequences of all the letters are different. And constructing all letters and the corresponding alternative letter sequences of the letters into an encryption dictionary.
For example: letters
Figure 947154DEST_PATH_IMAGE006
The alternative letter sequence of
Figure 975415DEST_PATH_IMAGE018
Letter of Chinese character
Figure 847556DEST_PATH_IMAGE008
The alternative letter sequence of
Figure 293450DEST_PATH_IMAGE019
Letter of Chinese character
Figure 139789DEST_PATH_IMAGE010
The alternative letter sequence of
Figure 345643DEST_PATH_IMAGE020
And the like.
It should be noted that there are multiple encryption dictionaries meeting the condition, and both the encryption side and the decryption side can agree with multiple encryption dictionaries in advance, and different block letter matrices are encrypted by using different encryption dictionaries. Meanwhile, the encryption end and the decryption end can replace the encryption dictionary at intervals so as to improve the confidentiality effect.
And S004, acquiring the total run length and the larger total frequency of each block letter matrix.
It should be noted that, in the encryption method in this embodiment, a sequence of a ciphertext of a letter previous to a current letter to be encrypted in the block letter matrix in the alphanumeric mapping table is taken as a first time, and an element at a first time position in the replaceable letter sequence of the current letter to be encrypted is obtained as the ciphertext of the current letter to be encrypted. In the encryption process, an alphanumeric mapping table is applied, which is a mapping relation table indicating the number corresponding to each letter. Alphanumeric maps, if implemented as specified, are susceptible to leakage during long-term encryption. To avoid this problem, the alphanumeric mapping table may be adaptively obtained according to the alphabet appearance rule in the block alphabet matrix, so as to improve the encryption effect. If the alphanumeric mapping table is randomly set, the encryption effect cannot be guaranteed to be always good, and the following two extreme cases may occur:
1. in the ciphertext corresponding to the same continuous letter, the context of the letter elements in the corresponding replaceable letter sequence in the letter is easy to expose.
In the combination of the replaceable letter sequences of all the letters, when the element sequence in the replaceable letter sequence of some letters is close to the element sequence of 26 English letters to a greater extent, the continuous ciphertext of the same letter easily exposes the context of the element letters in the replaceable letter sequence of the letter (the rule is easily obtained through long-time cracking). For example when
Figure 462503DEST_PATH_IMAGE006
Is a sequence of replaceable letters of
Figure 111922DEST_PATH_IMAGE021
Figure 947022DEST_PATH_IMAGE008
The alternative letter sequence of
Figure 159829DEST_PATH_IMAGE022
Meanwhile, when the alphanumeric mapping table of each letter is the same as the English alphabet sequence table, the plaintext is assumed to be
Figure 760225DEST_PATH_IMAGE023
Then the encrypted ciphertext is
Figure 33074DEST_PATH_IMAGE024
. When the more letters appear in plain text continuously, an attacker can find the same ciphertext in the process of cracking different block letter matrixes
Figure 948946DEST_PATH_IMAGE025
Occur many times, increasing the risk of being compromised.
This problem may arise when the order of elements in the alternative alphabetic sequence of certain letters is similar to the alphabetic order in an english alphabetic ordering list. To avoid this problem, the alphanumeric mapping table needs to be adjusted so that the order of the elements in the alphanumeric mapping table is different from the order of the letters in the english alphabetical order table, and different alphanumeric mapping tables are applied to different blocks, thereby increasing security.
2. The greater the probability of occurrence of a combination of two letters, the easier it is for an attacker to obtain the mapping relationship in the alphanumeric mapping table.
For example letters
Figure 965444DEST_PATH_IMAGE006
And
Figure 151837DEST_PATH_IMAGE008
alternative letter sequences and cases of
Figure 595588DEST_PATH_IMAGE007
The same as Chinese, while when the alphanumeric mapping table of each letter is the same as the English alphabetical sequence table, the plaintext
Figure 733177DEST_PATH_IMAGE026
Is a ciphertext of
Figure 553365DEST_PATH_IMAGE027
Converting the cipher text into its number in the English alphabet order table as
Figure 591335DEST_PATH_IMAGE028
. It can be seen that the first appearance in the plain text
Figure 471566DEST_PATH_IMAGE029
The number of the corresponding ciphertext is
Figure 706239DEST_PATH_IMAGE030
Second occurrence in the plaintext
Figure 313806DEST_PATH_IMAGE029
The number of the corresponding ciphertext is
Figure 458480DEST_PATH_IMAGE031
(ii) a First appearance in the plain text
Figure 260345DEST_PATH_IMAGE032
The number of the corresponding ciphertext is
Figure 857679DEST_PATH_IMAGE033
Second occurrence in the plaintext
Figure 268938DEST_PATH_IMAGE032
The number of the corresponding ciphertext is
Figure 268118DEST_PATH_IMAGE034
. Clear text from the above
Figure 232095DEST_PATH_IMAGE008
When they appear continuously, the intervals of the numbers of the corresponding cipher texts are all
Figure 316726DEST_PATH_IMAGE009
And clear text
Figure 141463DEST_PATH_IMAGE006
When they appear continuously, the intervals of the numbers of the corresponding cipher texts are all
Figure 244417DEST_PATH_IMAGE007
. This rule is easy for an attacker to crack the plaintext.
To avoid this problem, the alphanumeric mapping table needs to be adjusted so that adjacent letters in the alternative letter sequence that combine letters with a high frequency of occurrence are further apart in the alphanumeric mapping table.
The two extreme cases are problems that the order of elements in the replaceable alphabetical sequence of some letters is similar to the order of letters in the English alphabetical sequence table, and the alphanumeric mapping table is similar to the English alphabetical sequence table. Therefore, the difference between the replaceable letter sequence of the letter with high frequency in the block letter matrix and the English letter sequence table is calculated, when the difference is large, the two extreme conditions cannot occur, and the alphanumeric mapping table can be randomly set. Conversely, when the difference is small, the above extreme cases may occur, and at this time, the probabilities of the two extreme cases need to be analyzed according to the block alphabet matrix, so as to set the alphanumeric mapping table.
In this embodiment, the frequency of occurrence of each letter in the block letter matrix and the number of kinds of letters occurring in the block letter matrix are first counted. The reciprocal of the number of the kind is taken as the average frequency of the letters, for example, 18 letters are in total in a block letter matrix, then the average frequency of the letters is
Figure 106193DEST_PATH_IMAGE035
. Letters with a frequency greater than 5 times the average frequency of the letters can be considered to be more frequent and are referred to as first candidate letters.
The two extreme cases are all premised on that the run length of some letters is large or the occurrence frequency of some letter combinations is large, if the first candidate letter does not exist, the run length of each letter is not large or the occurrence frequency of some letter combinations is not large, at the moment, the two extreme cases cannot occur, and an attacker cannot analyze the replaceable letters corresponding to the same letter in the plaintext through the ciphertext. Therefore, when the first candidate letter does not exist, an alphanumeric mapping table is randomly set, namely all letters in the letter sequence are randomly arranged to obtain the alphanumeric mapping table, wherein the letter sequence is an English letter sequence table.
When first candidate letters exist, calculating the difference between the replaceable letter sequence of each first candidate letter and the English letter sequence table to obtain the difference of each first candidate letter, wherein the specific method comprises the following steps:
set a value to
Figure 694432DEST_PATH_IMAGE004
The cumulative number of differences of (2) takes the first element in the alternative letter sequence of the first candidate letter as the fourth element. Obtaining the fourth element in the alternativeAnd replacing the next element in the letter sequence as a fifth element, and if the fifth element and the fourth element are not adjacent in the English letter sequence table, adding one to the difference cumulative number, and using the fifth element as a new fourth element. Repeating the above operations, carrying out difference judgment operation on the new fourth element until the fifth element does not exist, stopping iteration, and dividing the accumulated number of differences when iteration is stopped by the value obtained by subtracting one from the length of the replaceable letter sequence to obtain the difference of the first candidate letter.
Such as letters
Figure 932646DEST_PATH_IMAGE006
Is a sequence of replaceable letters of
Figure 421265DEST_PATH_IMAGE036
The initial cumulative number of differences is
Figure 578577DEST_PATH_IMAGE004
Figure 903379DEST_PATH_IMAGE037
As a fourth element, a group of elements,
Figure 693087DEST_PATH_IMAGE010
is a fifth element and is a compound of the first element,
Figure 255787DEST_PATH_IMAGE037
and
Figure 239792DEST_PATH_IMAGE010
adjacent in the English letter sequence table, at this moment, the difference accumulated number is unchanged;
Figure 786311DEST_PATH_IMAGE010
as a fourth element, a group of elements,
Figure 382640DEST_PATH_IMAGE038
is a fifth element which is a function of,
Figure 331004DEST_PATH_IMAGE010
and
Figure 95698DEST_PATH_IMAGE038
the difference cumulative number is increased by one when the English letters are not adjacent in the sequence table; in the same way, the method for preparing the composite material,
Figure 113201DEST_PATH_IMAGE038
and
Figure DEST_PATH_IMAGE039
adjacent in the English alphabetical order list, the difference accumulation number is not changed at the moment;
Figure 188255DEST_PATH_IMAGE039
and
Figure 991126DEST_PATH_IMAGE040
the difference cumulative number is increased by one when the English letters are not adjacent in the English letter sequence table;
Figure 316934DEST_PATH_IMAGE040
and
Figure 838045DEST_PATH_IMAGE037
the difference cumulative number is increased by one when the English letters are not adjacent in the English letter sequence table;
Figure 510597DEST_PATH_IMAGE037
and
Figure 433553DEST_PATH_IMAGE008
the difference accumulation numbers are increased by one when the English alphabetical ordering list is not adjacent. The final cumulative difference number is
Figure 930263DEST_PATH_IMAGE015
. Letters
Figure 938670DEST_PATH_IMAGE006
Alternative letter sequences of
Figure 788814DEST_PATH_IMAGE036
Has a length of
Figure 314080DEST_PATH_IMAGE017
Then letter
Figure 466844DEST_PATH_IMAGE006
Has a difference of
Figure 680656DEST_PATH_IMAGE041
It should be noted that the difference between each element in the alternative letter sequence and the letter in the same position in the English alphabet sequence table is not directly calculated, for example, because of the alternative letter sequence
Figure 741016DEST_PATH_IMAGE042
The difference from the english alphabet list is small, but the difference between each element in the replaceable alphabet sequence and the letter in the same position in the english alphabet list makes the obtained numerical value larger, which results in larger error.
In this embodiment, the difference is smaller than a first preset threshold
Figure 858139DEST_PATH_IMAGE043
As a second candidate letter. In the present embodiment
Figure 712963DEST_PATH_IMAGE044
In other embodiments, the implementer may set the value of the first preset threshold as desired.
For each second candidate letter, all letters except the second candidate letter in the block letter matrix are represented by 0, the second candidate letter is represented by 1, when 0 appears continuously, 0 appearing continuously is regarded as one block, then the ratio of the number of 1 to the number of blocks of 0 is calculated, and the ratio is taken as the runability of the second candidate letter. For example: for block alphabet matrices
Figure 679651DEST_PATH_IMAGE045
In other words, when calculating
Figure 12543DEST_PATH_IMAGE006
When the run-length is required, the block letter matrix is firstly converted into
Figure 264400DEST_PATH_IMAGE046
At this time
Figure 290125DEST_PATH_IMAGE007
Is in an amount of
Figure 478530DEST_PATH_IMAGE015
Figure 615113DEST_PATH_IMAGE004
Number of blocks of
Figure 815150DEST_PATH_IMAGE009
Then, then
Figure 496929DEST_PATH_IMAGE006
Has a run-length of
Figure 188942DEST_PATH_IMAGE047
. For block alphabet matrices
Figure 112904DEST_PATH_IMAGE048
In other words, when calculating
Figure 308393DEST_PATH_IMAGE006
When the run-length is required, the block letter matrix is firstly converted into
Figure 423724DEST_PATH_IMAGE049
At this time
Figure 337453DEST_PATH_IMAGE007
Is in an amount of
Figure 65106DEST_PATH_IMAGE015
Figure 380681DEST_PATH_IMAGE004
Number of blocks of
Figure 404263DEST_PATH_IMAGE011
Then, then
Figure 70868DEST_PATH_IMAGE006
Has a run-length of
Figure 946420DEST_PATH_IMAGE050
. It should be noted that the greater the run length, the more likely the above extreme case 1 occurs, and in this case, the more necessary the alphanumeric mapping table needs to be set for the run length to avoid the extreme case 1.
And dividing each run-length in the block letter matrix by the maximum value of the run-lengths of all the second candidate letters to obtain the normalized run-length of each second subsequent letter. The sum of the normalized runability of all second candidate letters is taken as the total runability. The total runability reflects the possibility of the occurrence of extreme case 1, and when the total runability is larger, the more necessary it is to set the alphanumeric mapping table for the runlength to avoid extreme case 1.
For the extreme case 2, the combination property between the first candidate letters needs to be calculated, all the first candidate letters are combined pairwise to obtain all possible combinations, and each obtained combination is used as a first letter combination. And counting the frequency number of each first letter combination in the block letter matrix as the first frequency number of each first letter combination. And clustering all the first letter combinations into two types according to the first frequency numbers of all the first letter combinations by utilizing a clustering algorithm, and taking each first letter combination in the category with the large first frequency number mean value as a second letter combination. The second letter combination is a letter combination with a high frequency of occurrence in the block letter matrix. Dividing the first frequency count of each second letter combination by the maximum value in the first frequency counts of all the second letter combinations to obtain the larger frequency count of each second letter combination, wherein the larger the frequency count is, the more likely the extreme case 2 occurs, and at this time, the more necessary the alphanumeric mapping table needs to be set for the letter combinations to avoid the extreme case 2. And taking the sum of the frequency larger characters of all the second letter combinations as the total frequency larger character. The greater the total frequency reflects the possibility of the occurrence of the extreme case 2, and when the greater the total frequency, the more necessary the alphanumeric mapping table needs to be set for the combination of letters to avoid the extreme case 2.
When the second candidate letter does not exist, the total run-length does not exist, and at this time, the total run-length is recorded as 0, and when the second letter combination does not exist, the total frequency is not large, and at this time, the total frequency is large and is recorded as 0.
Therefore, the total run-length and the total frequency are larger. The total run length and the large total frequency reflect the possibility of two extreme conditions, and the two extreme conditions can be avoided as much as possible when an alphanumeric mapping table is set subsequently according to the total run length and the large total frequency, so that the encryption result is more complex, and the statistical analysis attack is resisted.
And S005, acquiring an alphanumeric mapping table in a self-adaptive manner according to the total run length and the total frequency greater.
When the total run length is 0 and the total frequency is greater than 0, the second candidate letter does not exist and the second letter combination does not exist, which indicates that the run length of each letter is not great and the occurrence frequency of the letter combination is not large, and at this time, the two extreme situations described in step S004 do not occur, and an attacker cannot analyze the replaceable letter corresponding to the same letter in the plaintext through the ciphertext. Therefore, when the total run length is 0 and the total frequency is 0, an alphanumeric mapping table is randomly set, that is, all letters in the letter sequence are randomly arranged to obtain the alphanumeric mapping table, wherein the letter sequence is an English letter sequence table.
It should be noted that when the total run length is not 0 or the total frequency is not 0 significantly, the two extreme cases described in step S004 may occur, and the alphanumeric mapping table needs to be set to a sequence with a large difference from the english alphabet table. When the total run length is larger, extreme case 1 can be avoided by setting an alphanumeric mapping table to increase the difference of consecutive letters in the block alphabet matrix (where the difference refers to the meaning of the difference in step S004, and the difference here is no longer just considering 1 neighborhood letter, and needs to consider a larger range of neighborhood letters). When the total frequency is larger, the extreme case 2 can be avoided by setting the alphanumeric mapping table to increase the difference between the letters in the block alphabet matrix and the letters before and after the letter in the block alphabet matrix in the alphanumeric mapping table (where the difference refers to the meaning of the difference in step S004, and only 1 neighborhood letter is considered here). For example, the run of the second candidate alphabet is 3, in order to avoid the extreme case 1, the difference of the 3 neighborhood alphabets needs to be considered, and in order to avoid the extreme case 2, because of the alphabet combination, only the 1 neighborhood alphabet (the difference is calculated before, and the 1 neighborhood alphabet is considered) needs to be considered.
In this embodiment, first, the frequency counts of all runs of each second candidate letter in the block letter matrix are obtained, and the run corresponding to the largest frequency count among the runs of all the second candidate letters is taken as the largest run and is marked as the largest run
Figure 631348DEST_PATH_IMAGE051
Denote the total run-length as
Figure 75099DEST_PATH_IMAGE052
The greater frequency of the total frequency is recorded as
Figure 982662DEST_PATH_IMAGE053
. The letter sequence, i.e. English letter sequence table, is used as the initial alphanumeric mapping table.
When in use
Figure 802850DEST_PATH_IMAGE054
And then, the influence of the large run is larger, and the extreme condition 1 is more likely to occur, at this time, the large run out-of-order operation needs to be carried out on the letter sequence to avoid the extreme condition 1, the small run out-of-order operation is further carried out to avoid the extreme condition 2, and the sequence obtained after the large run out-of-order operation and the small run out-of-order operation is used as an alphanumeric mapping table.
When the temperature is higher than the set temperature
Figure 342285DEST_PATH_IMAGE055
In time, it is stated that the influence of small runs is large, and extreme case 2 is more likely to occur, and at this time, it is necessary to first perform small run shuffling on the letter sequenceAnd (3) avoiding an extreme case 2 by the sequence operation, further avoiding an extreme case 1 by the large run out-of-order operation, and taking a sequence obtained after the small run out-of-order operation and the large run out-of-order operation as an alphanumeric mapping table.
The large run out-of-order operation specifically comprises:
recording the sequence needing large run out-of-order operation as input sequence, dividing the input sequence into multiple run lengths with maximum length
Figure 222516DEST_PATH_IMAGE051
The sub-sequence of (1), the first in the sub-sequence
Figure 348866DEST_PATH_IMAGE056
The elements are used as dividing points, wherein
Figure 97379DEST_PATH_IMAGE057
And in order to get the rounded character upwards, taking the elements before the division point as a first element block, taking the division point and the elements after the division point as a second element block, and splicing the first element block after the second element block to obtain the disordered subsequence. And splicing all the disordered subsequences according to the sequence of the subsequences to obtain the disordered sequence. For example, the manual input sequence is
Figure 366687DEST_PATH_IMAGE058
Maximum run length
Figure 152240DEST_PATH_IMAGE059
First, the input sequence is
Figure 903902DEST_PATH_IMAGE060
Is divided into a plurality of lengths of
Figure 924948DEST_PATH_IMAGE061
Of (a) a subsequence
Figure 438975DEST_PATH_IMAGE062
Figure 661008DEST_PATH_IMAGE063
. Will be the second in each subsequence
Figure 902896DEST_PATH_IMAGE064
An element as a division point, e.g.
Figure 117846DEST_PATH_IMAGE065
In
Figure 237112DEST_PATH_IMAGE008
For the division point, the element before the division point is used as the first element block
Figure 371990DEST_PATH_IMAGE006
Taking the division point and the elements after the division point as a second element block
Figure 943917DEST_PATH_IMAGE066
Splicing the first element block after the second element block to obtain an out-of-order subsequence
Figure 696978DEST_PATH_IMAGE067
. The same reason is that
Figure 936330DEST_PATH_IMAGE068
Out of order subsequence of
Figure 250898DEST_PATH_IMAGE069
. All out-of-order subsequences
Figure 575701DEST_PATH_IMAGE070
Figure 866874DEST_PATH_IMAGE071
Splicing according to the sequence of the subsequences to obtain an out-of-order sequence
Figure 960731DEST_PATH_IMAGE072
. It should be noted that the reason why the out-of-order operation of large runs does not use the reverse order but uses the division method of division points is that in the reverse order relationship, for example
Figure 443272DEST_PATH_IMAGE073
In the reverse order of
Figure 724212DEST_PATH_IMAGE074
The original adjacent relationship is still maintained, so the present embodiment selects the middle position as the start data (i.e. the segmentation point) to perform blocking on the subsequence, and joins different blocks out of order as the result of the large run out of order operation.
The small run out-of-order operation specifically comprises:
and recording a sequence needing small run out-of-order operation as an input sequence, sequentially taking each element in the input sequence as a first element, taking the next element of the first element as a second element, when the second element is adjacent to the first element in the English alphabetic ordering list, acquiring an element which is not adjacent to the first element in the English alphabetic ordering list, is positioned behind the first element in the input sequence and is closest to the first element as a third element, and exchanging positions of the third element and the second element. For example, the input sequence is
Figure 84655DEST_PATH_IMAGE075
First, the
Figure 298598DEST_PATH_IMAGE008
As the first element, it is preferable that,
Figure 689391DEST_PATH_IMAGE010
as the second element, it is preferable that,
Figure 582260DEST_PATH_IMAGE008
and
Figure 965968DEST_PATH_IMAGE010
adjacent to the first element in the English alphabet list
Figure 283686DEST_PATH_IMAGE008
Non-adjacent and located at the first element in the input sequence
Figure 94647DEST_PATH_IMAGE008
Then and from the first element
Figure 369421DEST_PATH_IMAGE008
The most recent elements
Figure 556819DEST_PATH_IMAGE039
As a third element, a third element
Figure 463464DEST_PATH_IMAGE039
With a second element
Figure 445327DEST_PATH_IMAGE010
Exchange positions to obtain
Figure 204467DEST_PATH_IMAGE076
. Will be provided with
Figure 195556DEST_PATH_IMAGE039
As the first element, it is preferable that,
Figure 487866DEST_PATH_IMAGE006
as a second element, a first element
Figure 906209DEST_PATH_IMAGE039
With a second element
Figure 618557DEST_PATH_IMAGE006
If not adjacent in the English letter sequence table, do not operate, the same way
Figure 413338DEST_PATH_IMAGE006
And
Figure 294575DEST_PATH_IMAGE010
are not adjacent in the English alphabetical order list,
Figure 742874DEST_PATH_IMAGE010
and
Figure 725873DEST_PATH_IMAGE038
are not adjacent in the English alphabetical order list,
Figure 543919DEST_PATH_IMAGE038
and
Figure 30395DEST_PATH_IMAGE037
if the English letters are not adjacent in the English letter sequence list, no operation is performed. The final result is
Figure 305387DEST_PATH_IMAGE077
. A schematic of encryption is shown in fig. 3.
Thus, an alphanumeric mapping table is obtained. Because the number of the letter types in different block letter matrixes and the frequency of each letter are different, the alphanumeric mapping tables of the different block letter matrixes are adaptively set according to the frequency and the run length information of the letters, so that each block letter matrix is encrypted according to the alphanumeric mapping tables in the following process, the ciphertext differences of the different block letter matrixes are increased, the letters of the two block letter matrixes are the same, the obtained alphanumeric mapping tables are different, the ciphertexts obtained in the following encryption process are different, on one hand, the disorder among the ciphertexts can be increased, and the cracking difficulty is increased; on the other hand, the calculation of the letter frequency is a very simple method, namely, the encryption method is simple, the calculation amount is small, and a good encryption effect can be achieved.
And S006, encrypting each block letter matrix according to the letter number mapping table and the replaceable letter sequence to obtain a ciphertext.
And when the letter to be encrypted is not the first letter in the block letter matrix, acquiring the order of the ciphertext of the previous letter of the letter to be encrypted in the block letter matrix in an alphanumeric mapping table, and acquiring the element at the first order position of the replaceable letter sequence of the letter to be encrypted as the ciphertext of the letter to be encrypted.
E.g. a block alphabet matrix of
Figure 510104DEST_PATH_IMAGE078
First, the
Figure 958989DEST_PATH_IMAGE039
As a letter to be encrypted, obtaining
Figure 565551DEST_PATH_IMAGE039
The first element in the replaceable letter sequence is used as the letter to be encrypted
Figure 745865DEST_PATH_IMAGE039
Is expressed as
Figure DEST_PATH_IMAGE079
Obtaining, by means of an alphanumeric mapping table
Figure 860714DEST_PATH_IMAGE079
The order in the middle alphanumeric mapping table is taken as the first order, denoted as
Figure 535409DEST_PATH_IMAGE080
(ii) a Will be provided with
Figure DEST_PATH_IMAGE081
As a letter to be encrypted, obtaining
Figure 183428DEST_PATH_IMAGE081
First in alternative letter sequences
Figure 144431DEST_PATH_IMAGE080
One element as a letter to be encrypted
Figure 478067DEST_PATH_IMAGE081
Will be described as
Figure 205720DEST_PATH_IMAGE082
Then byAlphanumeric mapping table, obtaining
Figure 521295DEST_PATH_IMAGE082
The order in the medium alphanumeric mapping table is taken as the first order, and is recorded as
Figure DEST_PATH_IMAGE083
(ii) a Will be provided with
Figure 748139DEST_PATH_IMAGE084
As a letter to be encrypted, obtaining
Figure 664011DEST_PATH_IMAGE084
First in alternative letter sequences
Figure DEST_PATH_IMAGE085
One element as a letter to be encrypted
Figure 637433DEST_PATH_IMAGE084
Is expressed as
Figure 73094DEST_PATH_IMAGE086
Then through the alphanumeric mapping table, obtain
Figure 172637DEST_PATH_IMAGE086
The order in the medium alphanumeric mapping table is taken as the first order, and is recorded as
Figure DEST_PATH_IMAGE087
(ii) a Will be provided with
Figure 14953DEST_PATH_IMAGE039
As a letter to be encrypted, obtaining
Figure 84409DEST_PATH_IMAGE039
First in alternative letter sequences
Figure 374576DEST_PATH_IMAGE087
One element as a letter to be encrypted
Figure 2610DEST_PATH_IMAGE039
Is expressed as
Figure 378228DEST_PATH_IMAGE088
. Thus realizing the block letter matrix
Figure DEST_PATH_IMAGE089
Is encrypted as
Figure 189058DEST_PATH_IMAGE090
At this point, the encryption of the block alphabet matrix is completed. In the embodiment, the next letter is encrypted by combining the ciphertext of the previous letter, so that the ciphertexts of different letters have strong correlation, if one letter is changed, the ciphertexts of all the letters are changed, the disorder of the ciphertexts is increased, the difference between the ciphertexts after encryption and the original plaintext is large, an attacker is further difficult to obtain effective information from the ciphertexts, and the cipher is difficult to crack under the condition of not knowing a secret key, so that the data security is improved.
And taking the total run length and the total frequency of each block letter matrix as a first supplementary key, and taking the maximum run length of each block letter matrix as a second supplementary key. And encrypting the first supplementary key and the second supplementary key by using an asymmetric encryption algorithm, and recording an encryption result as a supplementary ciphertext. It should be noted that, in this embodiment, only the first supplemental key and the second supplemental key are encrypted by using the asymmetric encryption algorithm, and the block alphabet matrix is not directly encrypted by using the asymmetric encryption algorithm, because the asymmetric encryption algorithm has strong security but a slow encryption and decryption speed, and is not suitable for encrypting data with a large data amount, but is only suitable for encrypting data with a small data amount. The data volume of the block letter matrix is large, and the encryption efficiency is low by adopting an asymmetric encryption algorithm, so that the encryption method in the embodiment needs to be adopted for encryption.
And storing the ciphertext of all the block letter matrixes and the supplementary ciphertext in a memory of the MCU singlechip operating system.
And S007, decrypting the ciphertext.
When the ciphertext is decrypted, the ciphertext and the supplementary ciphertext need to be obtained at the same time, firstly, the supplementary ciphertext is decrypted by using an asymmetric encryption algorithm to obtain a first supplementary key and a second supplementary key, the first supplementary key is the total run length and the total frequency of each block letter matrix, and the second supplementary key is the maximum run length of each block letter matrix.
The alphanumeric mapping table for each block alphabet matrix is obtained using the method in step S005. And decrypting the ciphertext according to the ciphertext of each block letter matrix and the alphanumeric mapping table:
sequentially taking each letter in the ciphertext as a first ciphertext, when the first ciphertext is the first letter in the ciphertext, acquiring the first element of the replaceable letter sequence of all the letters as a candidate decryption letter, and acquiring a letter corresponding to a subsequent decryption letter which is the same as the first ciphertext as a plaintext of the first ciphertext; when the first ciphertext is not the first letter in the ciphertext, taking the order of the previous letter in the ciphertext of the first ciphertext in the alphanumeric mapping table as a first order, obtaining the first order elements of the replaceable letter sequences of all letters as candidate decryption letters, and obtaining the letter corresponding to the candidate decryption letter which is the same as the first ciphertext as the plaintext of the first ciphertext.
Similarly, the plaintext of each block letter matrix can be obtained, and further the program code can be obtained.
Through the steps, the encryption and decryption of the program in the MCU singlechip operating system are completed.
According to the embodiment of the invention, the alphanumeric mapping tables of different block alphabetic matrices are set in a self-adaptive manner according to the frequency information of each letter of the block alphabetic matrices, so that the difference between the different block alphabetic matrices is increased, even if the letters of the two block alphabetic matrices are the same, the alphanumeric mapping tables are different, and the corresponding replaced letters are different, thereby on one hand, the disorder between ciphertexts can be increased, and the cracking difficulty is increased; on the other hand, the calculation of the letter frequency is a very simple method, namely, the encryption method is simple, the calculated amount is small, and a good encryption effect can be achieved; the next letter is encrypted by combining the ciphertext of the previous letter, so that the ciphertexts of different letters have strong correlation, if one letter is changed, the ciphertexts of all the following letters are changed, the disorder of the ciphertexts is increased, the difference between the ciphertexts after encryption and the original plaintext is large, an attacker is further difficult to obtain effective information from the ciphertexts, and the ciphertexts are difficult to crack under the condition of not knowing a secret key, so that the safety of program code storage is improved; the data volume of the letter matrix is large, on one hand, the whole encryption easily causes an attacker to intercept and obtain a ciphertext and then tamper the ciphertext, which directly causes a large amount of data errors, on the other hand, the method can decrypt and obtain all the plaintext after the attacker guesses a secret key, and blocks the letter matrix, and encrypts each block letter matrix by using different alphanumeric mapping tables, on the one hand, the attacker cannot cause a large amount of data errors even if tampering the ciphertext of one block letter matrix, but only causes the data errors of the corresponding block letter matrix, and on the other hand, the attacker only causes the content of the block letter matrix corresponding to the part of the secret key to be leaked, and cannot cause all the plaintext to be leaked even if guessing the part of the secret key. The robustness of the encryption method is enhanced through the blocking, so that the program code storage is safer.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like that fall within the spirit and principle of the present invention are intended to be included therein.

Claims (9)

1. A data encryption method of an MCU singlechip operating system is characterized by comprising the following steps:
acquiring a replaceable letter sequence of each letter in the letter sequence; acquiring a letter matrix; partitioning the letter matrix to obtain a plurality of partitioned letter matrices;
acquiring the frequency of each letter in the block letter matrix and the average frequency of the letters;
when the frequency of each letter is less than or equal to 5 times of the average frequency of the letters, randomly arranging all the letters in the letter sequence to obtain an alphanumeric mapping table; otherwise, taking the letters with the frequency more than 5 times of the average frequency of the letters as first candidate letters; acquiring a second candidate letter according to the replaceable letter sequence and the letter sequence of each first candidate letter, acquiring total run length and maximum run length according to the second candidate letter, combining all the first candidate letters in pairs to obtain a first letter combination, and acquiring the larger total frequency according to all the first letter combinations; when the total run length is larger than or equal to the larger total frequency, the character sequence is firstly subjected to large run length disorder operation and then subjected to small run length disorder operation to obtain a disorder sequence, and the disorder sequence is used as a character-number mapping table; when the total run-length is smaller than the larger total frequency, the character sequence is subjected to small run-length disorder operation firstly and then large run-length disorder operation to obtain a disorder sequence, and the disorder sequence is used as an alphanumeric mapping table;
and sequentially taking each letter in the block letter matrix as a letter to be encrypted, when the letter to be encrypted is the first letter in the block letter matrix, taking the first element in the replaceable letter sequence of the letter to be encrypted as a ciphertext of the letter to be encrypted, when the letter to be encrypted is not the first letter in the block letter matrix, acquiring the order of the ciphertext of the previous letter of the letter to be encrypted in the block letter matrix in an alphanumeric mapping table, taking the order as the first order, acquiring the element at the first order position of the replaceable letter sequence of the letter to be encrypted as the ciphertext of the letter to be encrypted, and storing the ciphertext.
2. The data encryption method of the MCU singlechip operating system according to claim 1, wherein the large run out-of-order operation comprises:
dividing an input sequence into a plurality of maximum runs
Figure DEST_PATH_IMAGE001
The sub-sequence of (1), the first in the sub-sequence
Figure 685404DEST_PATH_IMAGE002
Taking the elements as dividing points, wherein the elements are rounded up, taking the elements before the dividing points as first element blocks, taking the dividing points and the elements after the dividing points as second element blocks, and splicing the first element blocks after the second element blocks to obtain disordered subsequences; and splicing all the disordered subsequences according to the sequence of the subsequences to obtain the disordered sequences.
3. The data encryption method of the MCU singlechip operating system according to claim 1, wherein the small run out-of-order operation comprises:
and when the second element is adjacent to the first element in the alphabetical list, acquiring an element which is not adjacent to the first element in the alphabetical list, is positioned behind the first element in the input sequence and is closest to the first element as a third element, and exchanging positions of the third element and the second element.
4. The data encryption method of the MCU singlechip operating system according to claim 1, wherein the acquiring the replaceable letter sequence of each letter in the letter sequence comprises:
the alternative letter sequence for each letter in the letter sequence includes all of the letters in the letter sequence and has a length of 26; all letters in the letter sequence have different elements in the same ordinal position in the alternative letter sequence.
5. The data encryption method of the MCU singlechip operating system according to claim 1, wherein the blocking the alphabet matrix to obtain a plurality of blocked alphabet matrices comprises:
converting the letter matrix into a digital matrix, and decomposing the digital matrix to obtain a sparse matrix; converting the sparse matrix into a sequence curve, converting the sequence curve into a frequency domain, and acquiring the reciprocal of the maximum frequency in the frequency domain as a period;
dividing the period by the number of columns of the letter matrix and rounding upwards to obtain the block length, dividing the letter matrix into a plurality of block letter matrices according to the block length, wherein the number of columns of the block letter matrices is equal to that of the letter matrix, and the number of rows of the block letter matrices is equal to that of the blocks.
6. The data encryption method for the MCU singlechip operating system according to claim 1, wherein the acquiring the frequency of each letter and the letter average frequency in the block letter matrix comprises:
and counting the frequency of each letter and the number of the types of all the letters in the block letter matrix, and taking the reciprocal of the number of the types as the average frequency of the letters.
7. The data encryption method for the MCU singlechip operating system according to claim 1, wherein the obtaining a second candidate letter according to the letter sequence and the replaceable letter sequence of each first candidate letter comprises:
set a value to
Figure 966475DEST_PATH_IMAGE004
The cumulative number of differences of (1), the first element in the alternative letter sequence of the first candidate letter is taken as the fourth element;
and performing difference judgment on the fourth element, including: acquiring the next element of the fourth element in the replaceable letter sequence as a fifth element, and if the fifth element and the fourth element are not adjacent in the letter sequence, adding one to the difference cumulative number to take the fifth element as a new fourth element;
repeating the difference judgment operation on the new fourth element until the fifth element does not exist, stopping iteration, and dividing the accumulated number of differences when the iteration is stopped by the value obtained by subtracting one from the length of the replaceable letter sequence to obtain the difference of the first candidate letter;
and taking the first candidate letter with the difference smaller than a first preset threshold value as a second candidate letter.
8. The data encryption method of the MCU singlechip operating system according to claim 1, wherein the obtaining the total run length and the maximum run length according to the second candidate letter comprises:
expressing each second candidate letter in the block letter matrix by using 1, expressing each element except 1 by using 0, calculating the ratio of the number of 1 to the number of 0 blocks to obtain the run-length of each second candidate letter, and dividing the run-length of each second candidate letter by the maximum value of the run-length of all second candidate letters to obtain the normalized run-length of each second subsequent letter; taking the sum of the normalized runability of all the second candidate letters as the total runability;
and acquiring the frequency of all runs of each second candidate letter in the block letter matrix, and taking the run corresponding to the maximum frequency in the runs of all the second candidate letters as the maximum run.
9. The data encryption method for the MCU singlechip operating system according to claim 1, wherein the obtaining the larger total frequency according to all the first letter combinations comprises:
acquiring the frequency count of each first letter combination in the block letter matrix as the first frequency count of each first letter combination; clustering all the first letter combinations into two types according to the first frequency of all the first letter combinations by using a clustering algorithm, and taking each first letter combination in the category with a large first frequency average value as a second letter combination;
dividing the first frequency count of each second letter combination by the maximum value in the first frequency counts of all the second letter combinations to obtain the frequency count of each second letter combination, wherein the frequency count is larger; and taking the sum of the frequency larger characters of all the second letter combinations as the total frequency larger character.
CN202211495804.4A 2022-11-28 2022-11-28 Data encryption method for MCU singlechip operating system Active CN115544551B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211495804.4A CN115544551B (en) 2022-11-28 2022-11-28 Data encryption method for MCU singlechip operating system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211495804.4A CN115544551B (en) 2022-11-28 2022-11-28 Data encryption method for MCU singlechip operating system

Publications (2)

Publication Number Publication Date
CN115544551A CN115544551A (en) 2022-12-30
CN115544551B true CN115544551B (en) 2023-02-21

Family

ID=84721764

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211495804.4A Active CN115544551B (en) 2022-11-28 2022-11-28 Data encryption method for MCU singlechip operating system

Country Status (1)

Country Link
CN (1) CN115544551B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116506105B (en) * 2023-06-26 2023-09-01 山东极光智能科技有限公司 Data theft and tampering prevention encryption method based on block chain
CN116582263B (en) * 2023-07-12 2023-10-13 深圳中天云联科技发展有限公司 Security protection system for enterprise digital management platform

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107872313A (en) * 2016-09-27 2018-04-03 联车(上海)信息科技有限公司 The encryption method and decryption method of control instruction

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
HU227781B1 (en) * 2006-03-17 2012-02-28 Pal Bela Dr Doemoesi Symmetric key cryptographic apparatus and method for encryption and decryption of information

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107872313A (en) * 2016-09-27 2018-04-03 联车(上海)信息科技有限公司 The encryption method and decryption method of control instruction

Also Published As

Publication number Publication date
CN115544551A (en) 2022-12-30

Similar Documents

Publication Publication Date Title
CN115544551B (en) Data encryption method for MCU singlechip operating system
US7868788B2 (en) System and method for encoding data based on a compression technique with security features
CN116032474B (en) Safety protection system based on big data computer network
CN115865523A (en) Data encryption transmission method for information analysis system
CN116582263B (en) Security protection system for enterprise digital management platform
CN115643110B (en) Application software safety detection method based on running data
CN113572786B (en) Method for encrypting and decrypting plaintext formed by binary intercepted words with different lengths
CN112202729B (en) Dynamic obfuscated encryption and decryption method and device
CN116545771B (en) Intelligent storage method and system for intelligent driving system test data
CN115150818A (en) Communication transmission encryption method based on artificial intelligence
US20190158271A1 (en) Method and system of synchronous encryption to render computer files and messages impervious to pattern recognition and brute force attacks
CN116720211B (en) Dynamic monitoring data security encryption method for heart rehabilitation
CN112769545B (en) Image encryption method based on adjacent pixel Joseph transformation and Mealy state machine
CN115333720B (en) Data transmission method for call center
Wei et al. Analysis and improvement for the performance of Baptista's cryptographic scheme
CN114866657A (en) JPEG image encryption method for selecting safe plaintext and reducing size of ciphertext image file
Ji et al. A Side-Channel Attack on a Masked Hardware Implementation of CRYSTALS-Kyber
CN116405293B (en) Data encryption storage method of safe operation and maintenance system
Licayan et al. Performance Analysis of Playfair Cipher Color Substitution Variants
Al-Kazaz et al. An automatic cryptanalysis of Arabic transposition ciphers using compression
CN112165380A (en) Split type binary data encryption method
Alshayeji et al. A high‐capacity and secure least significant bit embedding approach based on word and letter frequencies
Pestunov Statistical analysis of the MARS block cipher
CN117395078B (en) Network security protection method and system based on big data
CN117407906B (en) Software development data security encryption method based on DES algorithm

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