Data encryption method and device, data decryption method and device, electronic equipment and storage medium
By analyzing and parallel encrypting the data file, the project content is generated to support flexible decryption, and the problem of redundancy of encryption and decryption steps in the prior art is solved, and efficient use of computing resources is achieved.
Patent Information
- Application Number
- CN202311376925.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-23
- Publication Date
- 2025-04-25
AI Technical Summary
When existing encryption algorithms and tools process large amounts of files, they cannot merge batches into one large file for one-time encryption and decryption, resulting in redundant and repetitive encryption and decryption steps, and consume too much computing resources.
By parsing the data file, generating a key file, creating an encrypted project, and encrypting the data subfile in parallel based on the key file, generating the project contents including index, file name, and hash value, and storing the encrypted data subfile into the preset structure file.
The process of streamlined encryption and decryption is realized, reducing the use of computing resources, enabling multiple data subfiles to be encrypted at the same time, and conveniently decrypting a single or multiple data subfiles.
Smart Images

Figure CN119885211A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of data processing technology, and in particular to a method and device for data encryption and decryption, an electronic device, and a storage medium. Background Art
[0002] The rapid decline in the cost of high-throughput sequencing has led to a massive increase in the output of genomic data, which has brought huge challenges to the storage, transmission and confidentiality of data. In order to protect the privacy of data and prevent genetic data from being leaked, data needs to be encrypted. In addition, in order to minimize the pressure of data storage and enhance the convenience of use, more and more encryption strategies are playing a vital role in their respective technical fields.
[0003] At present, most encryption algorithms and tools have an "encryption" and "decryption" process for file processing. However, when the files or data to be encrypted reach a certain level, in order to ensure the independence of the files or data, it is impossible to merge the batches of files into a large file and complete the encryption and decryption process at one time. Therefore, it is necessary to encrypt and decrypt the single files or data one by one, which makes the encryption and decryption steps very redundant and repetitive, resulting in a huge consumption of computing resources. Summary of the invention
[0004] The present invention provides a method and device for data encryption and decryption, an electronic device and a storage medium, the main purpose of which is to simplify the encryption and decryption process and reduce the use of computing resources.
[0005] According to a first aspect of the present disclosure, there is provided a method for data encryption, comprising:
[0006] Parsing a data file to generate a key file, wherein the data file includes at least one data sub-file;
[0007] Creating an encryption project corresponding to the data file;
[0008] Performing parallel encryption processing on the data sub-files based on the key files, and generating project content corresponding to the data sub-files, wherein the project content includes an index, a file name, and a hash value;
[0009] The encrypted data sub-file is stored in a preset structure file, wherein the preset structure file is a sub-directory of the encrypted project.
[0010] Optionally, parsing the data file to generate a key file includes:
[0011] Determining the security level corresponding to the data file and the encryption computing power required to process the data file;
[0012] Based on the security level and the encryption computing power, the key file is generated and stored in a first storage directory.
[0013] Optionally, the creating an encryption item corresponding to the data file includes:
[0014] Reference the key file and create a second storage directory corresponding to the encryption project, wherein the second storage directory is used to store the encrypted data file;
[0015] The encryption project corresponding to the data file is created according to the key file and the second storage directory.
[0016] Optionally, the performing parallel encryption processing on the data sub-file based on the key file and generating project content corresponding to the data sub-file includes:
[0017] Based on the key file, encrypting the data sub-file;
[0018] Calculating the hash value of the encrypted data sub-files and combining the hash values;
[0019] Storing the combined hash value in the preset structure file;
[0020] The project content is generated according to the index, file name and hash value of the data sub-file.
[0021] Optionally, the encrypted data sub-file is stored in a preset structure file, wherein the preset structure file is a sub-directory of the encrypted project, including:
[0022] Classify the encrypted data sub-files according to the project contents;
[0023] According to the result of the classification processing, the encrypted data sub-files are classified and stored in the preset structure files, wherein the preset structure files are stored in the second storage directory.
[0024] According to a second aspect of the present disclosure, a method for data decryption is provided, comprising:
[0025] Determine the data sub-file that needs to be decrypted;
[0026] Acquire a key file referenced by an encryption project, wherein the encryption project is generated by encrypting at least one of the data sub-files;
[0027] Obtaining the project content corresponding to the data sub-file, wherein the project content includes an index, a file name, and a hash value;
[0028] The data sub-file is decrypted based on the key file and the project content.
[0029] Optionally, obtaining the key file referenced by the encryption project includes:
[0030] Based on the encryption project, determining a first storage directory referenced by the key file;
[0031] Obtain the key file stored in the first storage directory.
[0032] Optionally, the decrypting the data sub-file based on the key file and the project content includes:
[0033] Based on the project content, determining a storage location of the encrypted data sub-file;
[0034] The encrypted data sub-file is obtained, and the encrypted data sub-file is decrypted according to the key file.
[0035] According to a third aspect of the present disclosure, there is provided a data encryption device, comprising:
[0036] A parsing unit, used for parsing a data file to generate a key file, wherein the data file includes at least one data sub-file;
[0037] A creation unit, used to create an encryption project corresponding to the data file;
[0038] An encryption unit, used to perform parallel encryption processing on the data sub-files based on the key file, and generate project content corresponding to the data sub-files, wherein the project content includes an index, a file name, and a hash value;
[0039] A storage unit is used to store the encrypted data sub-file into a preset structure file, wherein the preset structure file is a sub-directory of the encrypted project.
[0040] Optionally, the parsing unit includes:
[0041] A first determination module, used to determine the security level corresponding to the data file and the encryption computing power required to process the data file;
[0042] The first generating module is used to generate the key file based on the security level and the encryption computing power, and store the key file in a first storage directory.
[0043] Optionally, the creation unit includes:
[0044] A first creation module, used for referencing the key file and creating a second storage directory corresponding to the encryption project, wherein the second storage directory is used for storing the encrypted data file;
[0045] The second creation module is used to create the encryption project corresponding to the data file according to the key file and the second storage directory.
[0046] Optionally, the encryption unit includes:
[0047] An encryption module, used for encrypting the data sub-file based on the key file;
[0048] A calculation module, used for calculating the hash value of the encrypted data sub-file and combining the hash values;
[0049] A first storage module, used for storing the combined hash value into the preset structure file;
[0050] The second generating module is used to generate the project content according to the index, file name and hash value of the data sub-file.
[0051] Optionally, the storage unit includes:
[0052] A classification module, used for classifying the encrypted data sub-files according to the project contents;
[0053] The second storage module is used to classify and store the encrypted data sub-files into the preset structure files according to the result of the classification processing, wherein the preset structure files are stored in the second storage directory.
[0054] According to a fourth aspect of the present disclosure, a data decryption device is provided, comprising:
[0055] A determination unit, used for determining a data sub-file that needs to be decrypted;
[0056] A first acquisition unit is used to acquire a key file referenced by an encryption project, wherein the encryption project is generated by encrypting at least one of the data sub-files;
[0057] A second acquisition unit is used to acquire the project content corresponding to the data sub-file, wherein the project content includes an index, a file name, and a hash value;
[0058] A decryption unit is used to decrypt the data sub-file based on the key file and the project content.
[0059] Optionally, the first acquiring unit includes:
[0060] A second determination module, configured to determine, based on the encryption project, a first storage directory referenced by the key file;
[0061] An acquisition module is used to acquire the key file stored in the first storage directory.
[0062] Optionally, the decryption unit includes:
[0063] A third determination module, configured to determine a storage location of the encrypted data sub-file based on the project content;
[0064] The decryption module is used to obtain the encrypted data sub-file and decrypt the encrypted data sub-file according to the key file.
[0065] According to a fifth aspect of the present disclosure, there is provided an electronic device, including:
[0066] at least one processor; and
[0067] a memory communicatively connected to the at least one processor; wherein,
[0068] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method described in the first aspect and / or the second aspect.
[0069] According to a sixth aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable the computer to execute the method described in the first aspect and / or the second aspect.
[0070] According to a seventh aspect of the present disclosure, a computer program product is provided, comprising a computer program, wherein when the computer program is executed by a processor, the computer program implements the method as described in the first aspect and / or the second aspect.
[0071] The present disclosure provides a method and device for data encryption and decryption, an electronic device and a storage medium, which parses a data file to generate a key file, wherein the data file includes at least one data sub-file; creates an encryption project corresponding to the data file; performs parallel encryption processing on the data sub-file based on the key file, and generates project content corresponding to the data sub-file, wherein the project content includes an index, a file name, and a hash value; and stores the encrypted data sub-file in a preset structure file, wherein the preset structure file is a subdirectory of the encryption project. Compared with the related art, the embodiment of the present disclosure can encrypt multiple data sub-files at the same time through incremental encryption processing; at the same time, the generated project content can also facilitate the flexible decryption of a single or multiple data sub-files during the decryption process. This achieves a streamlined encryption and decryption process and reduces the use of computing resources.
[0072] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present application, nor is it intended to limit the scope of the present application. Other features of the present application will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0073] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.
[0074] Figure 1 A flowchart of a data encryption method provided by an embodiment of the present disclosure;
[0075] Figure 2 A flowchart of another data encryption method provided by an embodiment of the present disclosure;
[0076] Figure 3 A flowchart of a method for data decryption provided by an embodiment of the present disclosure;
[0077] Figure 4 A flowchart of another data decryption method provided by an embodiment of the present disclosure;
[0078] Figure 5 A flowchart of a method for data encryption and decryption provided in an embodiment of the present disclosure;
[0079] Figure 6 A schematic diagram of the structure of a data encryption device provided by an embodiment of the present disclosure;
[0080] Figure 7 A schematic diagram of the structure of another data encryption device provided by an embodiment of the present disclosure;
[0081] Figure 8 A schematic diagram of the structure of a data decryption device provided in an embodiment of the present disclosure;
[0082] Fig. 9 A schematic diagram of the structure of another data decryption device provided by an embodiment of the present disclosure;
[0083] Fig.10 A schematic block diagram of an exemplary electronic device provided for an embodiment of the present disclosure. DETAILED DESCRIPTION
[0084] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.
[0085] The following describes the data encryption and decryption methods and devices, electronic devices, and storage media according to the embodiments of the present disclosure with reference to the accompanying drawings.
[0086] Figure 1 A flowchart of a data encryption method provided by an embodiment of the present disclosure.
[0087] like Figure 1 As shown, the method comprises the following steps:
[0088] Step 101: parse a data file to generate a key file, wherein the data file includes at least one data sub-file.
[0089] In the embodiments of the present disclosure, data files are files of various forms that need to be encrypted, such as text files in .txt format, or fasta files obtained by high-throughput sequencing; data files are a collection of multiple data sub-files, such as when performing high-throughput sequencing, the genome data obtained are integrated into one data file, and these genome data include many fasta files (data sub-files). It should be noted that the present disclosure does not limit the specific format of the data file.
[0090] When encrypting, you need to parse the data file first to determine the key file that is more suitable for encrypting the data file. Factors such as the size of the data file and the computing power of the computing device performing the encryption process will affect the generation of the key file.
[0091] Step 102: Create an encryption project corresponding to the data file.
[0092] In an embodiment of the present disclosure, when encrypting a data file, an encryption project corresponding to the data file is created, and the encryption project is an environment constructed for encrypting the data file. When creating an encryption project, the specified directory or path is the root directory of the project, which is the main location for storing various files and folders in the project. By specifying a directory or path, related files in the project can be organized together and convenient access to these files can be provided.
[0093] The structure of the encryption project directory is designed according to the encryption requirements, and is usually determined by the type, scale, and organization of the project; the encryption project will reference the addresses of other files, which can be dependencies of the project (such as key files), configuration files, template files, etc. By referencing the addresses of these files, these files can be directly accessed in the project and used where needed. This makes it easy to manage external resources required by the project and makes the project code more modular and extensible. This disclosure is not limited to this.
[0094] Step 103: perform parallel encryption processing on the data sub-files based on the key files, and generate project content corresponding to the data sub-files, wherein the project content includes an index, a file name, and a hash value.
[0095] In the embodiments of the present disclosure, multiple data sub-files in a data file are incrementally encrypted at the same time; especially when processing batch files, the previous method of encrypting individual files one by one is changed, which can reduce the repetitiveness of encryption steps and thus improve the efficiency of encryption processing. It should be noted that the present disclosure does not limit the specific encryption algorithm used for encryption.
[0096] After encrypting the data sub-file, the storage method of the encrypted data sub-file will have a certain impact on the encryption. When designing a storage solution, it is necessary to comprehensively consider factors such as storage space, encryption speed, data integrity, security and compatibility to ensure the security and reliability of the data. At the same time, the storage method of the encrypted data sub-file affects the decryption efficiency and flexibility of the subsequent decryption process. Therefore, after encrypting each data sub-file, the corresponding project content is generated according to the encrypted data sub-file. Record the content related to the encrypted data sub-file, and the project content includes the index, file name, and calculated hash value corresponding to each data sub-file. The index can be used to quickly find and locate the required encrypted file; the file name can be used to identify and distinguish different encrypted files; the hash value can be used to ensure the integrity and correctness of the file content, because any modification to the file content will result in a change in the hash value. At the same time, hash can also be used to quickly verify the consistency of file content, such as during data transmission.
[0097] Step 104: store the encrypted data sub-file into a preset structure file, wherein the preset structure file is a sub-directory of the encrypted project.
[0098] In an embodiment of the present disclosure, a preset structure file is a file that stores encrypted data sub-files and data related to the data sub-files (such as hash values, etc.). By storing the encrypted data sub-files in a preset structure file, data management and search can be made more convenient. The encryption project may include but is not limited to preset structure files; the preset structure file is a subdirectory of the encryption project, and the encrypted data sub-files are stored in the preset structure file, which can be distinguished from other data, so the encrypted data and other data can be easily classified and managed. It should be noted that by storing the encrypted data sub-files in the preset structure file, it can be convenient to search for them when they are used later.
[0099] The present disclosure provides a method for data encryption, which includes parsing a data file to generate a key file, wherein the data file includes at least one data sub-file; creating an encryption project corresponding to the data file; performing parallel encryption processing on the data sub-file based on the key file, and generating project content corresponding to the data sub-file, wherein the project content includes an index, a file name, and a hash value; storing the encrypted data sub-file in a preset structure file, wherein the preset structure file is a subdirectory of the encryption project. Compared with the related art, the embodiment of the present disclosure can encrypt multiple data sub-files at the same time through incremental encryption processing; at the same time, the generated project content can also facilitate the flexible decryption of a single or multiple data sub-files during the decryption process. This achieves a streamlined encryption and decryption process and reduces the use of computing resources.
[0100] In order to clearly illustrate the embodiments of the present disclosure, the embodiments of the present disclosure provide Figure 2 A flowchart of another data encryption method is shown.
[0101] like Figure 2 As shown, the method comprises the following steps:
[0102] Step 201, determining the security level corresponding to the data file and the encryption computing power required to process the data file.
[0103] Step 202, based on the security level and the encryption computing power, generate the key file, and store the key file in a first storage directory.
[0104] Specifically in the disclosed embodiment, an encryption method based on the Advanced Encryption Standard (AES) algorithm is provided, and the fasta file is encrypted by the AES encryption algorithm. When selecting a key, factors such as the security level of the data file and the computing power of the computing device need to be considered. The higher the security level required for the data file, the longer the corresponding key length, and the greater the difficulty of cracking the key. A longer key length may increase the computational complexity of encryption and decryption, thereby having a certain impact on system performance. A shorter key length may provide higher performance, but security may be reduced.
[0105] After determining the key length, it is necessary to generate the corresponding key file and store the key file in the corresponding storage directory. For example, select the AES key and store it in the corresponding directory: "KEY = 'D: / k4medved'#make USBdrive key".
[0106] Step 203, reference the key file and create a second storage directory corresponding to the encryption project, wherein the second storage directory is used to store the encrypted data file.
[0107] Step 204: Create the encryption project corresponding to the data file according to the key file and the second storage directory.
[0108] Specifically, in the disclosed embodiment, creating an encryption project corresponding to a data file includes referencing a key file and specifying a second storage directory for storing encrypted data subfiles for the encryption project. The structure of the encryption project directory is designed according to encryption requirements, and is usually determined according to the type, scale, and organization of the project; the second storage directory is a subdirectory of the encryption project.
[0109] Exemplarily, a human genome project named gComposite (or gComp) is created and a directory is specified for it: G=gComp (path='.. / h38 / ', key=KEY).
[0110] Step 205: Encrypt the data sub-file based on the key file.
[0111] Specifically, in the disclosed embodiment, the data file is encrypted according to the generated key file. One or more data sub-files are encrypted at one time based on the AES encryption algorithm; while protecting the privacy of the data, the process of encrypting individual files one by one is omitted.
[0112] Step 206, calculating the hash value of the encrypted data sub-file and combining the hash values.
[0113] Step 207: store the combined hash value into the preset structure file.
[0114] Step 208: Generate the project content according to the index, file name, and hash value of the data sub-file.
[0115] Specifically in the embodiment of the present disclosure, the preset structure file is a tar structure file, and the hash value of the encrypted data sub-file is stored in the tar structure file.
[0116] At the same time, the project content is generated according to the index, file name, and hash value of the data sub-file. The storage method of the encrypted data sub-file affects the decryption efficiency and flexibility of the subsequent decryption process. Therefore, after each data sub-file is encrypted, the corresponding project content is generated according to the encrypted data sub-file. The content related to the encrypted data sub-file is recorded. The project content includes the index, file name, and calculated hash value corresponding to each data sub-file. The index can be used to quickly find and locate the required encrypted file; the file name can be used to identify and distinguish different encrypted files; and the hash value can be used to ensure the integrity and correctness of the file content, because any modification to the file content will result in a change in the hash value. At the same time, hashes can also be used to quickly verify the consistency of file content, such as during data transmission.
[0117] Step 209: classify the encrypted data sub-files according to the project contents.
[0118] Step 210: According to the result of the classification processing, the encrypted data sub-files are classified and stored in the preset structure files, wherein the preset structure files are stored in the second storage directory.
[0119] Specifically, in the disclosed embodiment, classification processing is performed according to the project content, so that the encrypted data sub-files can be better stored and the data management can be facilitated; it is beneficial to reduce the time of data call and improve the efficiency of decryption during subsequent decryption.
[0120] Figure 3 A flowchart of a method for data decryption provided in an embodiment of the present disclosure.
[0121] like Figure 3 As shown, the method comprises the following steps:
[0122] Step 301: determine the data sub-file that needs to be decrypted.
[0123] In the related art, after all the data sub-files in a data file are encrypted, if you want to decrypt them, you need to decrypt all the encrypted data sub-files, and you have to encrypt and decrypt the data sub-files or data in the data file one by one, which makes the encryption and decryption steps very redundant and repetitive, resulting in a huge consumption of computing resources.
[0124] In an embodiment of the present disclosure, a data subfile that needs to be decrypted is determined, and the data subfile that needs to be decrypted may be one or more data subfiles in a data file. The data subfile that needs to be decrypted may be determined by the file name of the data subfile, or by identification content such as an index; the present disclosure does not limit this. The storage location of the corresponding data subfile is determined according to the project content generated during encryption, so that the data subfile that needs to be decrypted can be flexibly selected, and the encrypted data subfile can be flexibly decrypted.
[0125] Step 302: Acquire a key file referenced by an encryption project, wherein the encryption project is generated by encrypting at least one of the data sub-files.
[0126] In an embodiment of the present disclosure, an encryption project is a project created when encrypting a data file. The encryption project obtains a key file by referencing the address of the generated key file.
[0127] In some embodiments of the present disclosure, the encrypted project is stored in a storage directory specified by the encrypted project.
[0128] As a refinement of an embodiment of the present disclosure, obtaining the key file referenced by the encryption project includes: determining a first storage directory referenced by the key file based on the encryption project; and obtaining the key file stored in the first storage directory.
[0129] Specifically, the key file is directly obtained by obtaining the first storage directory referenced in the encryption project and used to store the key file.
[0130] Step 303: Obtain the project content corresponding to the data sub-file, wherein the project content includes an index, a file name, and a hash value.
[0131] In an embodiment of the present disclosure, after determining the data sub-file that needs to be decrypted, the corresponding project content is obtained. After encrypting each data sub-file, the corresponding project content is generated according to the encrypted data sub-file. The content related to the encrypted data sub-file is recorded, and the project content includes the index, file name, and calculated hash value corresponding to each data sub-file. The index can be used to quickly find and locate the required encrypted file; the file name can be used to identify and distinguish different encrypted files; the hash value can be used to ensure the integrity and correctness of the file content, because any modification to the file content will result in a change in the hash value. At the same time, hash can also be used to quickly verify the consistency of file content, such as during data transmission. According to the project content, the storage location of the data sub-file can be quickly located, thereby improving the efficiency of decryption.
[0132] Step 304: decrypt the data sub-file based on the key file and the project content.
[0133] In the embodiment of the present disclosure, when encrypting a data file, the encrypted data sub-file is stored in a preset structure file and the corresponding project content is generated. Through the project content, the storage location of the data sub-file can be quickly found when decrypting.
[0134] As a refinement of an embodiment of the present disclosure, the decrypting of the data sub-file based on the key file and the project content includes: determining the storage location of the encrypted data sub-file based on the project content; obtaining the encrypted data sub-file, and decrypting the encrypted data sub-file according to the key file.
[0135] Specifically, the storage location of the data subfile to be decrypted is obtained according to the project content corresponding to the data subfile to be decrypted. After obtaining the data subfile to be decrypted, the data subfile to be decrypted is decrypted according to the key file.
[0136] The disclosed embodiment provides a method for data decryption, which determines a data sub-file that needs to be decrypted. Obtain a key file referenced by an encryption project, wherein the encryption project is generated by encrypting at least one of the data sub-files. Obtain project content corresponding to the data sub-file, wherein the project content includes an index, a file name, and a hash value. Decrypt the data sub-file based on the key file and the project content. Compared with the related art, any data sub-file in the data file can be obtained by using the project content generated in the encryption stage, without having to decrypt all the data files. The decryption steps are simplified, the efficiency and flexibility of decryption are improved, and the use of computing resources can be reduced.
[0137] In order to clearly illustrate the embodiments of the present disclosure, the embodiments of the present disclosure provide Figure 4 A flow chart of a method for data encryption and decryption is shown.
[0138] like Figure 4 As shown, the method comprises the following steps:
[0139] Step 401, select an AES key and store it in the corresponding directory.
[0140] Specifically, select the AES key and store it in the corresponding directory: KEY = 'D: / k4medved'#make USB drivekey
[0141] Step 402, create an encryption project.
[0142] Specifically, in the embodiment of the present disclosure, the encryption and decryption of the fasta file is taken as an example. For example, a human genome project named gComposite (or gComp) is created and a directory is specified for it:
[0143] G=gComp(path='.. / h38 / ',key=KEY)
[0144] The program running results are as follows:
[0145] .. / h38 / arh created
[0146] .. / h38 / meta created
[0147] .. / h38 / out created
[0148] gComposite.. / h38 / initialized.
[0149] gComposite key D: / k4medved loaded.
[0150] gComposite meta.. / h38 / meta\meta.csv created.
[0151] gCompositearhive.. / h38 / arh\gcomp.tar created.
[0152] Enter the directory specified by the encryption project and you can see the environment built by gCrypt:
[0153] ls..\h38\
[0154] The program running results are as follows:
[0155] Volume in drive C is System
[0156] Volume Serial Number is AC29-5252
[0157] DirectoryofC:\Users\AndrejsPuckovs\OneDrive\Desktop\projects\Encryption\h38
[0158] 12 / 15 / 2022 05:59 PM <dir>.
[0159] 12 / 15 / 2022 05:59 PM <dir>..
[0160] 12 / 14 / 2022 12:43 PM <dir>+
[0161] 12 / 15 / 2022 05:59 PM <dir>arh
[0162] 12 / 15 / 2022 05:59PM <dir>when
[0163] 12 / 15 / 2022 05:59PM <dir>out
[0164] 0File(s)0bytes
[0165] 6Dir(s)411,400,085,504bytes free
[0166] Where META is the content of the item (index + file name + hash value).
[0167] Step 403: encrypt the data sub-file.
[0168] Specifically, Figure 5 As shown, multiple fasta files can be encrypted in batches at one time.
[0169] Place a FASTA file in the ' / +' directory and make gFrag
[0170] g1=gFrag(G,fn='hg38_chr1.fa')
[0171] The program running results are as follows:
[0172] gFragfile.. / h38 / +\hg38_chr1.fa is hashed(sha256cum={'8894ce506a863fba3cb9b263b4aca9bdaacf26806120267ceae34846c0b4ef7')).
[0173] The encrypted sha256 sum of hg38_chr1.fa is shown above.
[0174] Enter to make grag part of H38 gComposite:
[0175] G=G+g1
[0176] The program running results are as follows:
[0177] 8894ce5f06a863fba3cb9b263b4aca9bdaacf26806120267ceae34846c0b4ef7 fileadded.None
[0178] {'8894ce5f06a863fba3cb9b263b4aca9bdaacf26806120267ceae34846c0b4ef7'}hash added.gComposite meta.. / h38 / meta\meta.csv created.
[0179] Check if gFrag is included in the META structure:
[0180] G.meta
[0181] The program running results are as follows:
[0182]
[0183] The above steps have confirmed that the file is encrypted in AES format and stored in a tar file. Now let's encrypt multiple files at once.
[0184] G=G+gFrag(G,fn='hg38_chr2.fa')+gFrag(G,fn='hg38_chr3.fa')+gFrag(G,fn='hg38_chr4.fa')
[0185] The program running results are as follows:
[0186] Frag file.. / h38 / +\hg38 chr2.1a is hashed(sha256sum=327142201ce7f5c27f10c818a011a90a3d3b44a6d6cca2cf496b0c51 e174def)8894ce5f06a863fba3cb9b263b4aca9bdaacf26806120267ceae34846c0b4ef7fi le added.
[0187] None
[0188] {'327142e201ce7f5c27f10c818a01fa90a3d3b44a6d6cca2ef496b0c51c174def'}hash added.gCompositemeta.. / h38 / meta meta csv created.
[0189] gFragfile.. / h38 / +\hg38_chr3.fa is hashed(sha256sum={'c02aa0a4d3c12ae8c321011c001e6c5ae6feff62b644e94b80e4562c f1lacebo"}).8894ce5f06a863fba3cb9b263b4aca9bdaacf26806120267ceae34846c0b4ef7 file added.None
[0190] {'c02aa0a4d3c12ae8c321011c001e6c5ae6feff626644e94b80e4562cfllacebo'}hash added.Commoditemota.. / h38 / meta meta csy created.
[0191] gFrag file. / h38 / +\hg38_chr4.fa is hashed(sha256sum={'31cb8e9300f2d3b06b6d9ce164fcdb3b7c97ed44b01a9681d87ae87b 455f12de")).8894ce5f06a863fba3cb9b263b4aca9bdaacf26806120267ceae34846c0b4ef7 file added.
[0192] None
[0193] 31cb8e9300f2d3b06b6d9ce164fcdb3b7c97ed44b01a9681d87ae87b455f12de}hashadded.
[0194] Compodite meta / 38motalmeta cay created
[0195] Check if gFrag is included in the META structure:
[0196] G.meta
[0197] The program running results are as follows: 0
[0198]
[0199] Step 404: Decrypt all data files in response to the first decryption instruction.
[0200] Specifically, you can choose to decrypt the entire gComplete into a BIG.fa file.
[0201] G>>gOut(G,out='big.fa')
[0202] 8894ce5f06a863fba3cb9b263b4aca9bdaacf26806120267ceae34846c0b4ef7 Filehg38 chrl.fa exported to gout file.. / h38 / out\big.fa.
[0203] Step 405: Decrypt a portion of the data sub-file in response to the second decryption instruction.
[0204] Specifically, you can flexibly select a file to decrypt, such as hg38_chr1.fa
[0205] G>>gOut(G,out='short.fa', shortlist=['hg38_chr1.fa'])
[0206] 8894ce5f06a863fba3cb9b263b4aca9bdaacf26806120267ceae34846c0b4ef7 Filehg38 chrl.fa exported to gOut file.. / h38 / out short.fa.
[0207] It should be noted that the embodiments of the present disclosure may include multiple steps. For the convenience of description, these steps are numbered, but these numbers do not limit the execution time slots or execution order between the steps; these steps can be implemented in any order, and the embodiments of the present disclosure do not limit this.
[0208] Corresponding to the above data encryption method, the present invention also provides a data encryption device. Since the device embodiment of the present invention corresponds to the above method embodiment, details not disclosed in the device embodiment can be referred to the above method embodiment, and will not be repeated in the present invention.
[0209] Figure 6 A schematic diagram of a data encryption device provided by an embodiment of the present disclosure is shown in FIG. Figure 6 As shown, including:
[0210] The parsing unit 51 is used to parse the data file to generate a key file, wherein the data file includes at least one data sub-file;
[0211] A creation unit 52, used to create an encryption item corresponding to the data file;
[0212] The encryption unit 53 is used to perform parallel encryption processing on the data sub-file based on the key file, and generate project content corresponding to the data sub-file, wherein the project content includes an index, a file name, and a hash value;
[0213] The storage unit 54 is used to store the encrypted data sub-file into a preset structure file, wherein the preset structure file is a sub-directory of the encrypted project.
[0214] The present disclosure provides a data encryption device, which generates a key file by parsing a data file, wherein the data file includes at least one data sub-file; creates an encryption project corresponding to the data file; performs parallel encryption processing on the data sub-file based on the key file, and generates project content corresponding to the data sub-file, wherein the project content includes an index, a file name, and a hash value; stores the encrypted data sub-file in a preset structure file, wherein the preset structure file is a subdirectory of the encryption project. Compared with the related art, the embodiment of the present disclosure can encrypt multiple data sub-files at the same time by means of incremental encryption processing; at the same time, the generated project content can also facilitate the flexible decryption of a single or multiple data sub-files during the decryption process. This achieves a streamlined encryption and decryption process and reduces the use of computing resources.
[0215] Furthermore, in a possible implementation of this embodiment, as Figure 7 As shown, the parsing unit 51 includes:
[0216] A first determination module 511, used to determine the security level corresponding to the data file and the encryption computing power required to process the data file;
[0217] The first generating module 512 is used to generate the key file based on the security level and the encryption computing power, and store the key file in a first storage directory.
[0218] Furthermore, in a possible implementation of this embodiment, as Figure 7 As shown, the creation unit 52 includes:
[0219] A first creation module 521 is used to reference the key file and create a second storage directory corresponding to the encryption project, wherein the second storage directory is used to store the encrypted data file;
[0220] The second creation module 522 is used to create the encryption project corresponding to the data file according to the key file and the second storage directory.
[0221] Furthermore, in a possible implementation of this embodiment, as Figure 7 As shown, the encryption unit 53 includes:
[0222] The encryption module 531 is used to encrypt the data sub-file based on the key file;
[0223] A calculation module 532, used for calculating the hash value of the encrypted data sub-file and combining the hash values;
[0224] A first storage module 533, used to store the combined hash value into the preset structure file;
[0225] The second generating module 534 is used to generate the project content according to the index, file name and hash value of the data sub-file.
[0226] Furthermore, in a possible implementation of this embodiment, as Figure 7 As shown, the storage unit 54 includes:
[0227] A classification module 541 is used to classify the encrypted data sub-files according to the project contents;
[0228] The second storage module 542 is used to classify and store the encrypted data sub-files into the preset structure files according to the classification processing result, wherein the preset structure files are stored in the second storage directory.
[0229] Corresponding to the above data decryption method, the present invention also provides a data decryption device. Since the device embodiment of the present invention corresponds to the above method embodiment, details not disclosed in the device embodiment can be referred to the above method embodiment, and will not be repeated in the present invention.
[0230] Figure 8 A schematic diagram of a data decryption device provided by an embodiment of the present disclosure is shown in FIG. Figure 8 As shown, including:
[0231] A determination unit 61, used to determine the data sub-file that needs to be decrypted;
[0232] A first acquisition unit 62 is used to acquire a key file referenced by an encryption project, wherein the encryption project is generated by encrypting at least one of the data sub-files;
[0233] A second acquisition unit 63 is used to acquire the project content corresponding to the data sub-file, wherein the project content includes an index, a file name, and a hash value;
[0234] The decryption unit 64 is used to decrypt the data sub-file based on the key file and the project content.
[0235] The disclosed embodiment provides a device for data decryption, which determines a data sub-file that needs to be decrypted. Obtain a key file referenced by an encryption project, wherein the encryption project is generated by encrypting at least one of the data sub-files. Obtain project content corresponding to the data sub-file, wherein the project content includes an index, a file name, and a hash value. Decrypt the data sub-file based on the key file and the project content. Compared with the related art, any data sub-file in the data file can be obtained by using the project content generated in the encryption stage, without having to decrypt all the data files. The decryption steps are simplified, the efficiency and flexibility of decryption are improved, and the use of computing resources can be reduced.
[0236] Furthermore, in a possible implementation of this embodiment, as Fig. 9 As shown, the first acquisition unit 62 includes:
[0237] A second determination module 621 is used to determine a first storage directory referenced by the key file based on the encryption project;
[0238] The acquisition module 622 is used to acquire the key file stored in the first storage directory.
[0239] Furthermore, in a possible implementation of this embodiment, as Fig. 9 As shown, the decryption unit 64 includes:
[0240] A third determination module 641 is used to determine the storage location of the encrypted data sub-file based on the project content;
[0241] The decryption module 642 is used to obtain the encrypted data sub-file and decrypt the encrypted data sub-file according to the key file.
[0242] It should be noted that the above explanation of the method embodiment is also applicable to the device of this embodiment, and the principle is the same, which is not limited in this embodiment.
[0243] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.
[0244] Fig.10 A schematic block diagram of an example electronic device 700 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0245] like Fig.10 As shown, the device 700 includes a computing unit 701, which can perform various appropriate actions and processes according to a computer program stored in a ROM (Read-Only Memory) 702 or a computer program loaded from a storage unit 708 to a RAM (Random Access Memory) 703. In the RAM 703, various programs and data required for the operation of the device 700 can also be stored. The computing unit 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An I / O (Input / Output) interface 705 is also connected to the bus 704.
[0246] A number of components in the device 700 are connected to the I / O interface 705, including: an input unit 706, such as a keyboard, a mouse, etc.; an output unit 707, such as various types of displays, speakers, etc.; a storage unit 708, such as a disk, an optical disk, etc.; and a communication unit 709, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 709 allows the device 700 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0247] The computing unit 701 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 701 include, but are not limited to, a CPU (Central Processing Unit), a GPU (Graphic Processing Units), various dedicated AI (Artificial Intelligence) computing chips, various computing units running machine learning model algorithms, a DSP (Digital Signal Processor), and any appropriate processor, controller, microcontroller, etc. The computing unit 701 performs the various methods and processes described above, such as data encryption and decryption methods. For example, in some embodiments, the data encryption and decryption methods may be implemented as a computer software program, which is tangibly included in a machine-readable medium, such as a storage unit 708. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 700 via the ROM 702 and / or the communication unit 709. When the computer program is loaded into the RAM 703 and executed by the computing unit 701, one or more steps of the method described above may be performed. Alternatively, in other embodiments, the computing unit 701 may be configured to execute the aforementioned data encryption and decryption methods in any other appropriate manner (eg, by means of firmware).
[0248] Various embodiments of the systems and techniques described above herein may be implemented in digital electronic circuit systems, integrated circuit systems, FPGAs (Field Programmable Gate Arrays), ASICs (Application-Specific Integrated Circuits), ASSPs (Application Specific Standard Products), SOCs (System On Chips), CPLDs (Complex Programmable Logic Devices), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include: being implemented in one or more computer programs that may be executed and / or interpreted on a programmable system including at least one programmable processor that may be a special purpose or general purpose programmable processor that may receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0249] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0250] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device, or any suitable combination of the foregoing. More specific examples of machine-readable storage media may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a RAM, a ROM, an EPROM (Electrically Programmable Read-Only-Memory) or a flash memory, an optical fiber, a CD-ROM (Compact Dis sc Read-Only Memory), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0251] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (Cathode-Ray Tube) or LCD (Liquid Crystal Display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or a trackball), through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0252] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: LAN (Local Area Network), WAN (Wide Area Network), the Internet, and blockchain networks.
[0253] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship between the client and the server is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services ("Virtual Private Server", or "VPS" for short). The server may also be a server of a distributed system, or a server combined with a blockchain.
[0254] It should be noted that artificial intelligence is a discipline that studies how computers can simulate certain human thought processes and intelligent behaviors (such as learning, reasoning, thinking, planning, etc.), and includes both hardware-level and software-level technologies. Artificial intelligence hardware technologies generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, and big data processing; artificial intelligence software technologies mainly include computer vision technology, speech recognition technology, natural language processing technology, as well as machine learning / deep learning, big data processing technology, knowledge graph technology, and other major directions.
[0255] The various numerical numbers such as first and second involved in the present disclosure are only for the convenience of description and are not used to limit the scope of the embodiments of the present disclosure, but also indicate the order of precedence.
[0256] At least one in the present disclosure can also be described as one or more, and a plurality can be two, three, four or more, which is not limited in the present disclosure. In the embodiments of the present disclosure, for a technical feature, the technical features in the technical feature are distinguished by "first", "second", "third", "A", "B", "C" and "D", etc., and there is no order of precedence or size between the technical features described by the "first", "second", "third", "A", "B", "C" and "D".
[0257] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.
[0258] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.< / dir> < / dir> < / dir> < / dir> < / dir> < / dir>
Claims
1. A method for data encryption, characterized in that: include: Parsing a data file to generate a key file, wherein the data file includes at least one data sub-file; Creating an encryption project corresponding to the data file; Performing parallel encryption processing on the data sub-files based on the key files, and generating project content corresponding to the data sub-files, wherein the project content includes an index, a file name, and a hash value; The encrypted data sub-file is stored in a preset structure file, wherein the preset structure file is a sub-directory of the encrypted project.
2. The method according to claim 1, characterized in that The step of parsing the data file to generate the key file includes: Determining the security level corresponding to the data file and the encryption computing power required to process the data file; Based on the security level and the encryption computing power, the key file is generated and stored in a first storage directory.
3. The method according to claim 1, characterized in that: The step of creating an encryption item corresponding to the data file includes: Reference the key file and create a second storage directory corresponding to the encryption project, wherein the second storage directory is used to store the encrypted data file; The encryption project corresponding to the data file is created according to the key file and the second storage directory.
4. The method according to claim 1, characterized in that: The performing parallel encryption processing on the data sub-file based on the key file and generating project content corresponding to the data sub-file includes: Based on the key file, encrypting the data sub-file; Calculating the hash value of the encrypted data sub-files and combining the hash values; Storing the combined hash value in the preset structure file; The project content is generated according to the index, file name and hash value of the data sub-file.
5. The method according to claim 1 or 3, characterized in that: The encrypted data sub-file is stored in a preset structure file, wherein the preset structure file is a sub-directory of the encrypted project, including: Classify the encrypted data sub-files according to the project contents; According to the result of the classification processing, the encrypted data sub-files are classified and stored in the preset structure files, wherein the preset structure files are stored in the second storage directory.
6. A method for data decryption, characterized in that: include: Determine the data sub-file that needs to be decrypted; Acquire a key file referenced by an encryption project, wherein the encryption project is generated by encrypting at least one of the data sub-files; Obtaining the project content corresponding to the data sub-file, wherein the project content includes an index, a file name, and a hash value; The data sub-file is decrypted based on the key file and the project content.
7. The method according to claim 6, characterized in that The step of obtaining the key file referenced by the encryption project includes: Based on the encryption project, determining a first storage directory referenced by the key file; Obtain the key file stored in the first storage directory.
8. The method according to claim 6, characterized in that The decrypting of the data sub-file based on the key file and the project content includes: Based on the project content, determining a storage location of the encrypted data sub-file; The encrypted data sub-file is obtained, and the encrypted data sub-file is decrypted according to the key file.
9. A data encryption device, characterized in that: include: A parsing unit, used for parsing a data file to generate a key file, wherein the data file includes at least one data sub-file; A creation unit, used to create an encryption project corresponding to the data file; An encryption unit, used to perform parallel encryption processing on the data sub-files based on the key file, and generate project content corresponding to the data sub-files, wherein the project content includes an index, a file name, and a hash value; A storage unit is used to store the encrypted data sub-file into a preset structure file, wherein the preset structure file is a sub-directory of the encrypted project.
10. A data decryption device, characterized in that: include: A determination unit, used for determining at least one data sub-file in a data file that needs to be decrypted; A first acquisition unit is used to acquire a key file referenced by an encryption project, wherein the encryption project is generated by encrypting the data file; A second acquisition unit is used to acquire the project content corresponding to the data sub-file, wherein the project content includes an index, a file name, and a hash value; A decryption unit is used to decrypt the data sub-file based on the key file and the project content.
11. An electronic device, characterized in that: include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 8.
12. A non-transitory computer-readable storage medium storing computer instructions, characterized in that: The computer instructions are used to cause the computer to execute the method according to any one of claims 1-8.
13. A computer program product, characterized in that The invention comprises a computer program which, when executed by a processor, implements the method according to any one of claims 1 to 8.