CN117235754A - Data encryption and decryption method, device, equipment and medium - Google Patents
Data encryption and decryption method, device, equipment and medium Download PDFInfo
- Publication number
- CN117235754A CN117235754A CN202311131059.XA CN202311131059A CN117235754A CN 117235754 A CN117235754 A CN 117235754A CN 202311131059 A CN202311131059 A CN 202311131059A CN 117235754 A CN117235754 A CN 117235754A
- Authority
- CN
- China
- Prior art keywords
- data
- character string
- encrypted data
- data block
- encrypted
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 60
- 230000000903 blocking effect Effects 0.000 claims abstract description 12
- 238000003860 storage Methods 0.000 claims description 9
- 125000004122 cyclic group Chemical group 0.000 claims description 6
- 230000008569 process Effects 0.000 description 12
- 238000010586 diagram Methods 0.000 description 11
- 238000004590 computer program Methods 0.000 description 7
- 238000005336 cracking Methods 0.000 description 7
- 238000005516 engineering process Methods 0.000 description 6
- 238000012545 processing Methods 0.000 description 6
- 238000012986 modification Methods 0.000 description 5
- 230000004048 modification Effects 0.000 description 5
- 230000006870 function Effects 0.000 description 4
- 230000000694 effects Effects 0.000 description 3
- 101100134058 Caenorhabditis elegans nth-1 gene Proteins 0.000 description 2
- 230000004075 alteration Effects 0.000 description 2
- 241001522296 Erithacus rubecula Species 0.000 description 1
- 238000004891 communication Methods 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 230000010365 information processing Effects 0.000 description 1
- 238000004519 manufacturing process Methods 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 238000003672 processing method Methods 0.000 description 1
Landscapes
- Storage Device Security (AREA)
Abstract
The application discloses a data encryption and decryption method, a device, equipment and a medium, which comprise the following steps: carrying out data blocking on the original data to be encrypted to obtain n data blocks; encrypting any one of the n data blocks by using a preset character string to obtain a first encrypted data block; encrypting other unencrypted n-1 data blocks in the n data blocks according to the preset character string and the first encrypted data block to obtain n-1 encrypted data blocks; and obtaining target encrypted data corresponding to the original data according to the first encrypted data block and the n-1 encrypted data blocks. According to the application, the preset character string and the first encrypted data block are combined to encrypt each data block by adopting different keys, so that the security of each data block is higher, and due to the fact that the keys of each data block are different, even if a few data blocks are cracked, only partial data of original data can be obtained, and all data of the original data cannot be easily obtained, so that the security of stored data is further improved.
Description
Technical Field
The present application relates to the field of data security technologies, and in particular, to a data encryption and decryption method, device, apparatus, and medium.
Background
With the rapid development of network communication and computer technology, various data almost all realize digital storage. In storing data, the data is typically stored encrypted using a fixed key and associated algorithms.
Although the use of the fixed key is convenient and quick, once the fixed key is revealed, the probability of cracking the encrypted data is greatly increased. Therefore, how to improve the security of stored data is a problem that needs to be solved currently.
Disclosure of Invention
The embodiment of the application solves the technical problem of lower security of data encryption in the prior art by providing the data encryption and decryption method, the device, the equipment and the medium, and achieves the technical effect of improving the security of stored data.
In a first aspect, the present application provides a data encryption method, including:
carrying out data blocking on the original data to be encrypted to obtain n data blocks; n is a positive integer;
encrypting any one of the n data blocks by using a preset character string to obtain a first encrypted data block;
encrypting other unencrypted n-1 data blocks in the n data blocks according to the preset character string and the first encrypted data block to obtain n-1 encrypted data blocks;
and obtaining target encrypted data corresponding to the original data according to the first encrypted data block and the n-1 encrypted data blocks.
Further, encrypting other unencrypted n-1 data blocks in the n data blocks according to the preset character string and the first encrypted data block to obtain n-1 encrypted data blocks, including:
m traverses from 1 to n-1, and sequentially executes target encryption steps to obtain n-1 encrypted data blocks and an n+1th character string; the target encryption step comprises the following steps:
encrypting the (m+1) th data block by using the (m+1) th character string to obtain an (m+1) th encrypted data block; when m=1, the second character string is obtained by encrypting the preset character string by using the first encrypted data block;
and encrypting the (m+1) th character string by using the (m+1) th encrypted data block to obtain the (m+2) th character string.
Further, encrypting the m+1-th string using the m+1-th encrypted data block includes:
judging whether the data length of the (m+1) th encrypted data block exceeds a preset length;
when the data length of the (m+1) -th encrypted data block exceeds a preset length, encrypting the (m+1) -th character string by using a part of the data segment of the (m+1) -th encrypted data block.
Further, after obtaining the second string, the method further comprises:
the preset string is discarded.
In a second aspect, the present application provides a data decryption method, the method comprising:
obtaining a result character string and an nth encrypted data block to be decrypted from target encrypted data to be decrypted, wherein the target encrypted data comprises n encrypted data blocks, and the nth encrypted data block is a data block for finally implementing encryption operation in the n encrypted data blocks; n is a positive integer;
decrypting the result character string by using the nth encrypted data block to obtain an nth character string;
decrypting the n encrypted data blocks according to the nth character string to obtain a preset character string and n decrypted data blocks, and taking the n decrypted data blocks as original data after decryption of target encrypted data; the preset character string is an encryption key corresponding to the first data block for implementing encryption operation.
Further, decrypting the n encrypted data blocks according to the nth character string to obtain a preset character string and n decrypted data blocks, including:
traversing from n to 2, and sequentially executing target decryption steps to obtain a preset character string and n decrypted data blocks; the target decryption step includes:
decrypting the kth encrypted data block by using the kth character string to obtain a kth data block;
decrypting the kth character string by using the kth-1 encrypted data block to obtain a kth-1 character string;
when k=2, the first character string is a preset character string, and the target decryption step further includes:
and decrypting the first encrypted data block by using the preset character string to obtain the first data block.
In a third aspect, the present application provides a data encryption apparatus, the apparatus comprising:
the dividing module is used for carrying out data blocking on the original data to be encrypted to obtain n data blocks; n is a positive integer;
the initial encryption module is used for encrypting any one of the n data blocks by using a preset character string to obtain a first encrypted data block;
the cyclic encryption module is used for encrypting other unencrypted n-1 data blocks in the n data blocks according to the preset character string and the first encrypted data block to obtain n-1 encrypted data blocks;
and the encrypted data determining module is used for obtaining target encrypted data corresponding to the original data according to the first encrypted data block and the n-1 encrypted data blocks.
In a fourth aspect, the present application provides a data decryption apparatus, the apparatus comprising:
the acquisition module is used for acquiring a result character string and an nth encrypted data block to be decrypted from target encrypted data to be decrypted, wherein the target encrypted data comprises n encrypted data blocks, and the nth encrypted data block is a data block for finally implementing encryption operation in the n encrypted data blocks; n is a positive integer;
the initial decryption module is used for decrypting the result character string by using the nth encrypted data block to obtain the nth character string;
the cyclic decryption module is used for decrypting the n encrypted data blocks according to the nth character string to obtain a preset character string and n decrypted data blocks, and taking the n decrypted data blocks as original data after target encrypted data decryption; the preset character string is an encryption key corresponding to the first data block for implementing encryption operation.
In a fifth aspect, the present application provides an electronic device, comprising:
a processor;
a memory for storing processor-executable instructions;
wherein the processor is configured to execute to implement a data encryption method as provided in the first aspect and/or a data decryption method as provided in the second aspect.
In a sixth aspect, the application provides a non-transitory computer readable storage medium, which when executed by a processor of an electronic device, causes the electronic device to perform implementing a data encryption method as provided in the first aspect and/or a data decryption method as provided in the second aspect.
One or more technical solutions provided in the embodiments of the present application at least have the following technical effects or advantages:
in this embodiment, the original data is subjected to data blocking, any one data block is encrypted by using a preset character string to obtain a first encrypted data block, and other n-1 data blocks are encrypted by combining the preset character string and the first encrypted data block to obtain n encrypted data blocks. Therefore, the embodiment avoids the means of encrypting the data by adopting the fixed key in the related technology, but blocks the original data, combines the preset character string and the first encrypted data block and adopts different keys to encrypt each data block, so that the security of each data block is higher, and even if a few data blocks are cracked due to different keys of each data block, only partial data of the original data can be obtained, and all data of the original data can not be obtained easily, thereby further improving the security of the stored data.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for the description of the embodiments will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present application, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a schematic flow chart of a data encryption method provided by the application;
fig. 2 is a schematic diagram of an encryption sequence in a data encryption process according to the present application;
FIG. 3 is a schematic flow chart of a data decryption method according to the present application;
fig. 4 is a schematic diagram of a decryption sequence in a data decryption process according to the present application;
fig. 5 is a schematic structural diagram of a data encryption device according to the present application;
fig. 6 is a schematic structural diagram of a data decryption device according to the present application;
fig. 7 is a schematic structural diagram of an electronic device according to the present application.
Detailed Description
The embodiment of the application solves the technical problem of lower security of data encryption in the prior art by providing the data encryption and decryption method.
The technical scheme of the embodiment of the application aims to solve the technical problems, and the overall thought is as follows:
a method of encrypting data, the method comprising: carrying out data blocking on the original data to be encrypted to obtain n data blocks; n is a positive integer; encrypting any one of the n data blocks by using a preset character string to obtain a first encrypted data block; encrypting other unencrypted n-1 data blocks in the n data blocks according to the preset character string and the first encrypted data block to obtain n-1 encrypted data blocks; and obtaining target encrypted data corresponding to the original data according to the first encrypted data block and the n-1 encrypted data blocks.
In this embodiment, the original data is subjected to data blocking, any one data block is encrypted by using a preset character string to obtain a first encrypted data block, and other n-1 data blocks are encrypted by combining the preset character string and the first encrypted data block to obtain n encrypted data blocks. Therefore, the embodiment avoids the means of encrypting the data by adopting the fixed key in the related technology, but blocks the original data, combines the preset character string and the first encrypted data block and adopts different keys to encrypt each data block, so that the security of each data block is higher, and even if a few data blocks are cracked due to different keys of each data block, only partial data of the original data can be obtained, and all data of the original data can not be obtained easily, thereby further improving the security of the stored data.
In order to better understand the above technical solutions, the following detailed description will refer to the accompanying drawings and specific embodiments.
First, the term "and/or" appearing herein is merely an association relationship describing associated objects, meaning that there may be three relationships, e.g., a and/or B, may represent: a exists alone, A and B exist together, and B exists alone. In addition, the character "/" herein generally indicates that the front and rear associated objects are an "or" relationship.
In the related art, data is stored in an encrypted manner mainly through a fixed key. The fixed key is a string of characters, and new data is obtained by performing a series of binary operations with the original data (i.e. the data to be encrypted). Since the new data is calculated, the new data has no readable meaning, and the encryption effect is realized. The decryption process is to use the encrypted data and the fixed key to carry out the encryption reverse operation to restore the original key.
However, the encryption and decryption of the data can be conveniently and quickly realized by using the fixed key, but once the fixed key is leaked, the probability of cracking the encrypted data is greatly increased. Therefore, encryption using a fixed key has a problem of low data security.
In order to solve the above-described problems, the present embodiment provides a data encryption method as shown in fig. 1, which includes steps S11 to S14. The method shown in fig. 1 may be applied to a processor of a storage device. It should be noted that, in this embodiment, parameters (such as each encryption key) and encryption algorithm involved in the encryption process are not fixed, complex and various, and may be implemented by using a processor with a relatively good computing capability according to actual situations, and may also be implemented by installing corresponding special software on the processor, which also improves the security of the stored data to a certain extent.
Step S11, data blocking is carried out on the original data to be encrypted, and n data blocks are obtained; n is a positive integer;
step S12, encrypting any one of the n data blocks by using a preset character string to obtain a first encrypted data block;
step S13, encrypting other unencrypted n-1 data blocks in the n data blocks according to the preset character string and the first encrypted data block to obtain n-1 encrypted data blocks;
and step S14, obtaining target encrypted data corresponding to the original data according to the first encrypted data block and the n-1 encrypted data blocks.
Regarding step S11, performing data blocking on the original data to be encrypted to obtain n data blocks; n is a positive integer.
The original data is divided into n data blocks, and the data lengths of the n data blocks can be identical, different or partially identical, and can be specifically selected according to practical situations.
The value of n can also be selected according to actual conditions, for example, when the data volume of the original data is large, n can take a larger value; when the data amount of the original data is small, n may take a small value.
With respect to step S12, any one of the n data blocks is encrypted using the preset character string, resulting in a first encrypted data block.
The preset character string may be a randomly generated character string, a character string randomly intercepted from a sequence library, or a character string calculated according to a preset rule, and may specifically be selected according to actual situations. The length of the preset character string can be selected according to practical situations, for example, when the confidentiality level of the original data is higher, a longer preset character string can be adopted; when the security level of the original data is low, a shorter preset string may be employed.
In step S11, n data blocks are obtained, one data block may be randomly selected from the n data blocks as a first data block, and the first data block is encrypted by using a preset character string as an encryption key, so as to obtain a first encrypted data block; one data block may be selected as the first data block according to the sequence of the n data blocks in the original data, and the data block may be encrypted using a preset character string as an encryption key, for example, the first data block in the original data may be used as the first data block, or the last data block in the original data may be used as the first data block.
And encrypting the first data block by taking the preset character string as an encryption key to obtain a first encrypted data block. The encryption algorithm used may be selected randomly from the encryption algorithm library, or may be selected according to a preset rule in the encryption algorithm library, which is not limited in this embodiment.
Regarding step S13, the other unencrypted n-1 data blocks in the n data blocks are encrypted according to the preset string and the first encrypted data block, so as to obtain n-1 encrypted data blocks.
Step S13 is a circulation step, specifically, encrypting the preset character string and the derivative character string thereof continuously by using the encrypted data block to obtain a new character string, and encrypting the new data block to be encrypted by using the new character string to obtain a new encrypted data block. Step S13 will now be described with reference to fig. 2:
step A1, encrypting a preset character string (also a first character string) by using a first encrypted data block (corresponding to a data block 1 (encrypted) in FIG. 2) to obtain a second character string; encrypting the second data block (corresponding to the data block 2 in fig. 2) by using the second character string to obtain a second encrypted data block (corresponding to the data block 2 (encrypted) in fig. 2);
step A2, encrypting the second character string by using the second encrypted data block to obtain a third character string; encrypting a third data block (corresponding to the data block 3 in fig. 2) by using a third character string to obtain a third encrypted data block (corresponding to the data block 3 (encrypted) in fig. 2);
and step A3, circulating until all the data blocks are encrypted, and obtaining n encrypted data blocks and an n+1th character string. The n encrypted data blocks include a first encrypted data block, a second encrypted data block, a third encrypted data block, and the remaining n-3 encrypted data blocks.
The present embodiment describes the content of fig. 2 in another way:
and B, traversing m from 1 to n-1, and sequentially executing the target encryption steps to obtain n-1 encrypted data blocks and an n+1th character string.
The target encryption step comprises the following steps:
step B1, encrypting the (m+1) th data block by using the (m+1) th character string to obtain the (m+1) th encrypted data block; when m=1, the second string is obtained by encrypting the preset string by using the first encrypted data block. The encryption algorithms adopted when different character strings encrypt corresponding data blocks can be identical or partially identical, and can also be completely different, so that the cracking difficulty of each obtained encrypted data block is higher.
And B2, encrypting the (m+1) th character string by using the (m+1) th encrypted data block to obtain the (m+2) th character string. Where m+2 may be at most n+1. The encryption algorithms adopted when different encryption data blocks encrypt the corresponding character strings can be identical or partially identical, and can also be completely different, so that the cracking difficulty of each derived character string is higher.
In the process of executing step B2, that is, in the process of encrypting the (m+1) -th string using the (m+1) -th encrypted data block, it is necessary to determine whether the data length of the (m+1) -th encrypted data block exceeds a preset length, and when the data length of the (m+1) -th encrypted data block exceeds the preset length, encrypting the (m+1) -th string using a partial data segment of the (m+1) -th encrypted data block.
When the data length of the (m+1) -th encrypted data block exceeds the preset length, which means that the data length of the (m+1) -th encrypted data block is too long, if the (m+1) -th encrypted data block is taken as an encryption key together, the burden of the processor is increased, and meanwhile, the encryption efficiency of the processor is reduced.
In addition, in step S13, the preset character string and the derivative character string thereof are continuously encrypted to obtain a new character string, and n+1 character strings (including the preset character string) can be finally obtained. In actual operation, only the n+1th character string may be stored, that is, the preset character string and the derivative character strings other than the n+1th character string may be discarded. In actual operation, the first encrypted data block, the n-1 encrypted data blocks and the n+1th character string can be spliced to form target encrypted data corresponding to the original data.
Although the target encrypted data contains a secret key (namely an n+1th character string), the encryption algorithm is uncertain, so that the target encrypted data is difficult to crack; further, the algorithm for encrypting the data block to be encrypted in each round of operation is variable, the derivative character string obtained by each round of encryption and the corresponding encryption algorithm are variable, so that the difficulty of an illegal user in cracking target encrypted data to obtain original data and a preset character string is overlapped layer by layer, even if the illegal user uses the (n+1) th character string to crack the target encrypted data, only part of the data can be cracked, and further the safety of stored data is higher.
With respect to step S14, target encrypted data corresponding to the original data is obtained from the first encrypted data block and the n-1 encrypted data blocks.
Splicing the first encrypted data block and n-1 encrypted data blocks to obtain pre-encrypted data; and then splicing the encrypted data with the n+1th character string to obtain target encrypted data corresponding to the original data.
In summary, in this embodiment, the original data is subjected to data blocking, any one of the data blocks is encrypted by using the preset character string, so as to obtain a first encrypted data block, and then the other n-1 data blocks are encrypted by combining the preset character string and the first encrypted data block, so as to obtain n encrypted data blocks. Therefore, the embodiment avoids the means of encrypting the data by adopting the fixed key in the related technology, but blocks the original data, combines the preset character string and the first encrypted data block and adopts different keys to encrypt each data block, so that the security of each data block is higher, and even if a few data blocks are cracked due to different keys of each data block, only partial data of the original data can be obtained, and all data of the original data can not be obtained easily, thereby further improving the security of the stored data.
Based on the same inventive concept, the present embodiment provides a data decryption method as shown in fig. 3, which includes steps S31 to S33. The method shown in fig. 2 may be applied to a processor of a storage device. The method shown in fig. 1 corresponds to the method shown in fig. 2, and the decryption process involved in the method shown in fig. 2 is the inverse operation of the encryption process in the method shown in fig. 1. It should be noted that, parameters (such as each encryption key) and encryption algorithms involved in the decryption process in this embodiment are complex and various, and may be implemented by using a processor with a relatively good computing capability according to actual situations, or may be implemented by installing corresponding special software on the processor, which also improves the security of the stored data to a certain extent.
Step S31, obtaining a result character string and an nth encrypted data block to be decrypted from target encrypted data to be decrypted, wherein the target encrypted data comprises n encrypted data blocks, and the nth encrypted data block is a data block for finally implementing encryption operation in the n encrypted data blocks; n is a positive integer;
step S32, decrypting the result character string by using the nth encrypted data block to obtain an nth character string;
step S33, decrypting the n encrypted data blocks according to the nth character string to obtain a preset character string and n decrypted data blocks, and taking the n decrypted data blocks as original data after decryption of target encrypted data; the preset character string is an encryption key corresponding to the first data block for implementing encryption operation.
The target encrypted data includes each encrypted data block and an n+1th character string (i.e., a result character string). The specific decryption process will now be described with reference to fig. 4 as follows:
step C1, decrypting the (n+1) th character string by using the (n) th encrypted data block as a decryption key to obtain an (n) th character string; decrypting the nth encrypted data block by using the nth character string as a decryption key to obtain the nth data block;
step C2, decrypting the nth character string by using the nth-1 encrypted data block as a decryption key to obtain the nth-1 character string; decrypting the n-1 th encrypted data block by using the n-1 th character string as a decryption key to obtain an n-1 th data block;
and C3, circulating until all the encrypted data blocks are decrypted, and obtaining n data blocks and a preset character string.
The present embodiment describes the content of fig. 4 in another way:
step D, traversing k from n to 2, and sequentially executing a target decryption step to obtain a preset character string and n decrypted data blocks; the target decryption step includes:
step D1, decrypting the kth encrypted data block by using the kth character string to obtain the kth data block;
step D2, decrypting the kth character string by using the kth-1 encrypted data block to obtain the kth-1 character string;
when k=2, the first string is a preset string, and the target decryption step further includes step D3: and decrypting the first encrypted data block by using the preset character string to obtain the first data block.
In summary, although the target encrypted data contains the key (i.e. the n+1th character string), the difficulty of cracking the target encrypted data is greater due to uncertainty of the encryption algorithm; further, in the encryption process, the algorithm for encrypting the data block to be encrypted in each round of encryption operation is not fixed, the derivative character string obtained by each round of encryption and the corresponding encryption algorithm are not fixed, so that the difficulty of an illegal user in cracking target encrypted data to obtain original data and a preset character string is overlapped layer by layer, even if the illegal user uses the n+1th character string to crack the target encrypted data, only part of data can be cracked, and further the security of stored data is higher.
Therefore, the risk of reduced security of the stored data caused by the leakage of the fixed key in the related technology is avoided, the original data is segmented, the preset character string and the first encrypted data block are combined to encrypt each data block by adopting different keys, so that the security of each data block is higher, even if a few data blocks are cracked, only part of the data of the original data can be obtained, and all the data of the original data can not be obtained easily, and the security of the stored data is further improved.
Based on the same inventive concept, the present embodiment provides a data encryption apparatus as shown in fig. 5, the apparatus including:
the dividing module 51 is configured to perform data blocking on the original data to be encrypted to obtain n data blocks; n is a positive integer;
an initial encryption module 52, configured to encrypt any one of the n data blocks by using a preset string to obtain a first encrypted data block;
the cyclic encryption module 53 is configured to encrypt n-1 data blocks, which are not encrypted, of the n data blocks according to the preset string and the first encrypted data block, to obtain n-1 encrypted data blocks;
the encrypted data determining module 54 is configured to obtain target encrypted data corresponding to the original data according to the first encrypted data block and the n-1 encrypted data blocks.
Further, the round encryption module 53 is specifically configured to perform the following steps:
m traverses from 1 to n-1, and sequentially executes target encryption steps to obtain n-1 encrypted data blocks and an n+1th character string; the target encryption step comprises the following steps:
encrypting the (m+1) th data block by using the (m+1) th character string to obtain an (m+1) th encrypted data block; when m=1, the second character string is obtained by encrypting the preset character string by using the first encrypted data block;
and encrypting the (m+1) th character string by using the (m+1) th encrypted data block to obtain the (m+2) th character string.
Further, the round encryption module 53 is specifically further configured to:
when the m+1-th character string is encrypted by using the m+1-th encrypted data block, judging whether the data length of the m+1-th encrypted data block exceeds a preset length;
when the data length of the (m+1) -th encrypted data block exceeds a preset length, encrypting the (m+1) -th character string by using a part of the data segment of the (m+1) -th encrypted data block.
Further, the device further comprises a discarding module, configured to discard the preset string after the second string is obtained.
Based on the same inventive concept, the present embodiment provides a data decryption apparatus as shown in fig. 6, the apparatus including:
an obtaining module 61, configured to obtain a result string and an nth encrypted data block to be decrypted from target encrypted data to be decrypted, where the target encrypted data includes n encrypted data blocks, and the nth encrypted data block is a data block in which an encryption operation is performed last in the n encrypted data blocks; n is a positive integer;
an initial decryption module 62, configured to decrypt the result string using the nth encrypted data block to obtain an nth string;
a cyclic decryption module 63, configured to decrypt the n encrypted data blocks according to the nth string, obtain a preset string and n decrypted data blocks, and use the n decrypted data blocks as original data after decryption of the target encrypted data; the preset character string is an encryption key corresponding to the first data block for implementing encryption operation.
Further, the round robin decryption module 64 is specifically configured to:
traversing from n to 2, and sequentially executing target decryption steps to obtain a preset character string and n decrypted data blocks; the target decryption step includes:
decrypting the kth encrypted data block by using the kth character string to obtain a kth data block;
decrypting the kth character string by using the kth-1 encrypted data block to obtain a kth-1 character string;
when k=2, the first character string is a preset character string, and the target decryption step further includes:
and decrypting the first encrypted data block by using the preset character string to obtain the first data block.
Based on the same inventive concept, the present embodiment provides an electronic device as shown in fig. 7, including:
a processor 71;
a memory 72 for storing instructions executable by the processor 71;
wherein the processor 71 is configured to execute to implement a data encryption method and/or a data decryption method as provided above.
Based on the same inventive concept, the present embodiment provides a non-transitory computer-readable storage medium, which when executed by the processor 71 of the electronic device, enables the electronic device to perform implementing a data encryption method and/or a data decryption method as provided above.
Since the electronic device described in this embodiment is an electronic device used to implement the method for processing information in the embodiment of the present application, those skilled in the art will be able to understand the specific implementation of the electronic device in this embodiment and various modifications thereof based on the method for processing information described in the embodiment of the present application, so how the method in the embodiment of the present application is implemented in this electronic device will not be described in detail herein. Any electronic device used by those skilled in the art to implement the information processing method in the embodiment of the present application is within the scope of the present application.
It will be appreciated by those skilled in the art that embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present application have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. It is therefore intended that the following claims be interpreted as including the preferred embodiments and all such alterations and modifications as fall within the scope of the application.
It will be apparent to those skilled in the art that various modifications and variations can be made to the present application without departing from the spirit or scope of the application. Thus, it is intended that the present application also include such modifications and alterations insofar as they come within the scope of the appended claims or the equivalents thereof.
Claims (10)
1. A method of encrypting data, the method comprising:
carrying out data blocking on the original data to be encrypted to obtain n data blocks; n is a positive integer;
encrypting any one of the n data blocks by using a preset character string to obtain a first encrypted data block;
encrypting other unencrypted n-1 data blocks in the n data blocks according to the preset character string and the first encrypted data block to obtain n-1 encrypted data blocks;
and obtaining target encrypted data corresponding to the original data according to the first encrypted data block and the n-1 encrypted data blocks.
2. The method of claim 1, wherein encrypting the other unencrypted n-1 data blocks of the n data blocks according to the predetermined string and the first encrypted data block to obtain n-1 encrypted data blocks, comprises:
m traverses from 1 to n-1, and sequentially executes target encryption steps to obtain n-1 encrypted data blocks and an n+1th character string; the target encryption step comprises the following steps:
encrypting the (m+1) th data block by using the (m+1) th character string to obtain an (m+1) th encrypted data block; when m=1, the second character string is a character string obtained by encrypting the preset character string by using the first encrypted data block;
and encrypting the (m+1) th character string by using the (m+1) th encrypted data block to obtain the (m+2) th character string.
3. The method of claim 2, wherein encrypting the m+1-th string using the m+1-th encrypted data block comprises:
judging whether the data length of the (m+1) -th encrypted data block exceeds a preset length;
and encrypting the (m+1) -th character string by using a part of data segments of the (m+1) -th encrypted data block when the data length of the (m+1) -th encrypted data block exceeds the preset length.
4. The method of claim 2, wherein after obtaining the second string, the method further comprises:
discarding the preset character string.
5. A method of decrypting data, the method comprising:
obtaining a result character string and an nth encrypted data block to be decrypted from target encrypted data to be decrypted, wherein the target encrypted data comprises n encrypted data blocks, and the nth encrypted data block is a data block for finally implementing encryption operation in the n encrypted data blocks; n is a positive integer;
decrypting the result character string by using the nth encryption data block to obtain an nth character string;
decrypting the n encrypted data blocks according to the nth character string to obtain a preset character string and n decrypted data blocks, and taking the n decrypted data blocks as original data after decryption of the target encrypted data; the preset character string is an encryption key corresponding to the first data block for implementing encryption operation.
6. The method of claim 5, wherein decrypting the n encrypted data blocks according to the nth string results in a predetermined string and n decrypted data blocks, comprising:
traversing from n to 2, and sequentially executing target decryption steps to obtain the preset character string and n decrypted data blocks; the target decryption step includes:
decrypting the kth encrypted data block by using the kth character string to obtain a kth data block;
decrypting the kth character string by using the kth-1 encrypted data block to obtain a kth-1 character string;
when k=2, the first string is the preset string, and the target decryption step further includes:
and decrypting the first encrypted data block by using the preset character string to obtain the first data block.
7. A data encryption device, the device comprising:
the dividing module is used for carrying out data blocking on the original data to be encrypted to obtain n data blocks; n is a positive integer;
the initial encryption module is used for encrypting any one of the n data blocks by using a preset character string to obtain a first encrypted data block;
the cyclic encryption module is used for encrypting other unencrypted n-1 data blocks in the n data blocks according to the preset character string and the first encrypted data block to obtain n-1 encrypted data blocks;
and the encrypted data determining module is used for obtaining target encrypted data corresponding to the original data according to the first encrypted data block and the n-1 encrypted data blocks.
8. A data decryption apparatus, the apparatus comprising:
the system comprises an acquisition module, a decryption module and a decryption module, wherein the acquisition module is used for acquiring a result character string and an nth encrypted data block to be decrypted from target encrypted data to be decrypted, the target encrypted data comprises n encrypted data blocks, and the nth encrypted data block is the data block for finally implementing encryption operation in the n encrypted data blocks; n is a positive integer;
the initial decryption module is used for decrypting the result character string by using the nth encryption data block to obtain an nth character string;
the cyclic decryption module is used for decrypting the n encrypted data blocks according to the nth character string to obtain a preset character string and n decrypted data blocks, and taking the n decrypted data blocks as original data after the target encrypted data is decrypted; the preset character string is an encryption key corresponding to the first data block for implementing encryption operation.
9. An electronic device, comprising:
a processor;
a memory for storing the processor-executable instructions;
wherein said processor is configured to execute to implement a data encryption method as claimed in any one of claims 1 to 4 and/or a data decryption method as claimed in any one of claims 5 to 6.
10. A non-transitory computer readable storage medium, which when executed by a processor of an electronic device, causes the electronic device to perform implementing a data encryption method according to any one of claims 1 to 4 and/or a data decryption method according to any one of claims 5 to 6.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311131059.XA CN117235754A (en) | 2023-08-31 | 2023-08-31 | Data encryption and decryption method, device, equipment and medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311131059.XA CN117235754A (en) | 2023-08-31 | 2023-08-31 | Data encryption and decryption method, device, equipment and medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN117235754A true CN117235754A (en) | 2023-12-15 |
Family
ID=89097680
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202311131059.XA Pending CN117235754A (en) | 2023-08-31 | 2023-08-31 | Data encryption and decryption method, device, equipment and medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN117235754A (en) |
-
2023
- 2023-08-31 CN CN202311131059.XA patent/CN117235754A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109510703B (en) | Data encryption and decryption method and device | |
US9515821B2 (en) | Apparatus and method for data encryption | |
US20170177899A1 (en) | Encrypted data deduplication in cloud storage | |
CN113641648B (en) | Distributed cloud secure storage method, system and storage medium | |
CN106817358B (en) | Encryption and decryption method and device for user resources | |
CN108431819B (en) | Method and system for protecting client access to service of DRM agent of video player | |
EP3437248A1 (en) | Key update for masked keys | |
CN114553589B (en) | Cloud file secure transmission method based on multi-stage encryption | |
CN112532379A (en) | File protection method and device | |
CN109660328A (en) | Symmetric block encryption method, apparatus, equipment and medium | |
CN114826590A (en) | Packet mode encryption method, packet mode decryption method, packet mode encryption device, packet mode decryption device and packet mode decryption equipment | |
CN113326518B (en) | Data processing method and device | |
CN112818404B (en) | Data access permission updating method, device, equipment and readable storage medium | |
CN110365620B (en) | Stream data privacy protection method and device | |
CN103457721B (en) | A kind of method and device of Mass production password | |
JPWO2015166701A1 (en) | ENCRYPTION METHOD, PROGRAM, AND SYSTEM | |
CN112487464A (en) | Encrypted data sharing method and device based on block chain | |
EP4084484B1 (en) | Method and device for encryption of video stream, communication equipment, and storage medium | |
CN114866312B (en) | Shared data determining method and device for protecting data privacy | |
CN108809889B (en) | Data deterministic deletion method based on data block random position negation | |
CN117235754A (en) | Data encryption and decryption method, device, equipment and medium | |
CN115865461A (en) | Method and system for distributing data in high-performance computing cluster | |
US11455404B2 (en) | Deduplication in a trusted execution environment | |
CN116996323A (en) | Data encryption and decryption method and device | |
CN117221878B (en) | Information security control method and device based on wireless network equipment |
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 |