File encryption method and device, electronic equipment and storage medium
By compressing bioinformatics files and encrypting only the structural information part, the problems of compression ratio loss and waste of storage space caused by existing encryption methods are solved, and efficient encryption and compression processing is achieved.
Patent Information
- Application Number
- CN202311212933.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-18
- Publication Date
- 2025-03-18
AI Technical Summary
The existing encryption methods require encrypting the entire file when encrypting the file, resulting in a higher loss of compression ratio and waste of storage space and compression time.
By compressing the target file, the compressed target file information is obtained, including the structure information of the target file; specifying the target encryption address as the address corresponding to the structure information; using a preset encryption algorithm to encrypt the structure information pointed to by the target encryption address to obtain the encrypted compressed file.
When encrypting and compressing the target file, this method only encrypts the structure information part, avoids encrypting the entire file, reduces the loss of compression ratio, and saves storage space and compression time.
Smart Images

Figure CN119649919A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of data processing technology, and in particular to a file encryption method and device, an electronic device, and a storage medium. Background Art
[0002] With the rapid decline in the cost of high-throughput sequencing, the output of genomic data has increased significantly, bringing huge challenges to the storage, transmission and confidentiality of genomic data. Genomic data is mainly stored in the form of bioinformatics files. In order to alleviate the pressure of storage space, bioinformatics files need to be compressed before storage. In the process of compressing and decompressing bioinformatics files, in order to protect the privacy of data, bioinformatics files need to be encrypted. In order to reduce the impact of encryption on compression performance, more and more encryption methods are playing a role in their respective technical fields.
[0003] Existing encryption methods include symmetric encryption, asymmetric encryption, one-way encryption, key exchange, etc. However, when encrypting a file, the encryption method in the related technology needs to encrypt the entire file, resulting in a high loss of compression ratio, causing a waste of storage space and compression time. Summary of the invention
[0004] The present invention provides a method and device for encrypting a file, an electronic device and a storage medium. The main purpose is to solve the problem that the encryption method in the related art needs to encrypt the entire file when encrypting a file, resulting in a high loss of compression ratio, resulting in a waste of storage space and compression time.
[0005] According to a first aspect of the present disclosure, a method for encrypting a file is provided, comprising:
[0006] Compressing the target file to obtain compressed target file information, wherein the target file information includes structural information of the target file;
[0007] Specifying the target encrypted address as the address corresponding to the structure information of the target file;
[0008] The structural information of the target file pointed to by the target encrypted address is encrypted by a preset encryption algorithm to obtain an encrypted compressed file corresponding to the target file.
[0009] Optionally, before specifying the target encryption address as the address corresponding to the structure information of the target file, the method further includes:
[0010] Detecting whether an encryption instruction for the target file is received;
[0011] If it is determined that the encryption instruction has not been received, compressing the target file and not encrypting the target file;
[0012] The designated target encrypted address is an address corresponding to the structure information of the target file, including:
[0013] If it is determined that the encryption instruction is received, the target file is encrypted, and the target encryption address is designated as the address corresponding to the structural information of the target file.
[0014] Optionally, compressing the target file to obtain compressed target file information includes:
[0015] Compressing the target file by using a preset compression tool, and obtaining composition information of the compressed target file, wherein the composition information includes version information, metadata information, and structure information;
[0016] The file information is constructed according to the version information, the metadata information and the structure information, and the structure information is designated as the target file information.
[0017] Optionally, encrypting the structure information of the target file pointed to by the target encrypted address by using a preset encryption algorithm includes:
[0018] Detecting whether the version information and / or the metadata information is encrypted;
[0019] If it is determined that the version information and / or the metadata information is to be encrypted, then encrypting the target file is stopped and a first error message is output;
[0020] If it is determined that the version information and / or the metadata information is not encrypted, the structural information of the target file pointed to by the target encrypted address is encrypted using a preset encryption algorithm.
[0021] Optionally, encrypting the structure information of the target file pointed to by the target encrypted address by using a preset encryption algorithm further includes:
[0022] Obtaining encrypted sorting information of the structure information of the target file pointed to by the target encrypted address;
[0023] An encryption key is generated according to the encrypted sorting information, and the encryption key can be used to encrypt the target file and decrypt the encrypted compressed file corresponding to the target file.
[0024] Optionally, after encrypting the structure information of the target file pointed to by the target encrypted address by using a preset encryption algorithm to obtain an encrypted compressed file corresponding to the target file, the method further includes:
[0025] In response to a decryption command for the encrypted compressed file, decrypt the encrypted compressed file based on the encryption key to obtain a decrypted compressed file;
[0026] The decrypted compressed file is decompressed to obtain a decompressed target file.
[0027] According to a second aspect of the present disclosure, there is provided a device for encrypting a file, comprising:
[0028] A compression unit, used to compress the target file to obtain compressed target file information, wherein the target file information includes structural information of the target file;
[0029] A designation unit, used to designate a target encryption address as an address corresponding to the structure information of the target file;
[0030] The encryption unit is used to encrypt the structural information of the target file pointed to by the target encryption address through a preset encryption algorithm to obtain an encrypted compressed file corresponding to the target file.
[0031] Optionally, the device further comprises:
[0032] A detection unit, used to detect whether an encryption instruction for the target file is received;
[0033] The compression unit is further configured to, when it is determined that the encryption instruction has not been received, compress the target file and not encrypt the target file;
[0034] The designation unit is further configured to, when it is determined that the encryption instruction is received, encrypt the target file and designate the target encryption address as an address corresponding to the structural information of the target file.
[0035] Optionally, the compression unit includes:
[0036] A compression module, used to compress the target file by using a preset compression tool, and obtain composition information of the compressed target file, wherein the composition information includes version information, metadata information and structure information;
[0037] A construction module is used to construct file information according to the version information, metadata information and structure information, and designate the structure information as the target file information.
[0038] Optionally, the encryption unit includes:
[0039] A detection module, used to detect whether the version information and / or the metadata information is encrypted;
[0040] a stop module, configured to stop encrypting the target file and output a first error message when it is determined that the version information and / or the metadata information is to be encrypted;
[0041] The encryption module is used to encrypt the structure information of the target file pointed to by the target encryption address by using a preset encryption algorithm when it is determined that the version information and / or the metadata information is not encrypted.
[0042] Optionally, the encryption unit further includes:
[0043] An acquisition module, used for acquiring encrypted sorting information of the structure information of the target file pointed to by the target encrypted address;
[0044] A generation module is used to generate an encryption key according to the encrypted sorting information, and the encryption key can be used to encrypt the target file and decrypt the encrypted compressed file corresponding to the target file.
[0045] Optionally, the device further comprises:
[0046] a decryption unit, configured to, in response to a decryption command for the encrypted compressed file, decrypt the encrypted compressed file based on the encryption key to obtain a decrypted compressed file;
[0047] The decompression unit is used to decompress the decrypted compressed file to obtain a decompressed target file.
[0048] According to a third aspect of the present disclosure, there is provided an electronic device, including:
[0049] at least one processor; and
[0050] a memory communicatively connected to the at least one processor; wherein,
[0051] 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.
[0052] According to a fourth 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.
[0053] According to a fifth 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 above.
[0054] The file encryption method and device, electronic device and storage medium provided by the present disclosure compress the target file to obtain compressed target file information, wherein the target file information includes the structure information of the target file; designate the target encryption address as the address corresponding to the structure information of the target file; encrypt the structure information of the target file pointed to by the target encryption address through a preset encryption algorithm to obtain an encrypted compressed file corresponding to the target file. Compared with the related art, when encrypting and compressing the target file, the embodiment of the present disclosure encrypts the structure information part of the target file to complete the encryption and compression processing of the target file, without encrypting the entire target file, thereby reducing the loss of compression ratio and saving storage space and compression time.
[0055] 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
[0056] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.
[0057] Figure 1 A flowchart of a file encryption method provided by an embodiment of the present disclosure;
[0058] Figure 2 A schematic diagram of a process for obtaining file information of a compressed target file provided by an embodiment of the present disclosure;
[0059] Figure 3 An example diagram of small data provided by an embodiment of the present disclosure;
[0060] Figure 4 A test comparison result diagram provided by an embodiment of the present disclosure;
[0061] Figure 5 Another test comparison result diagram provided by an embodiment of the present disclosure;
[0062] Figure 6 Another test comparison result diagram provided by an embodiment of the present disclosure;
[0063] Figure 7 A schematic diagram of the structure of a file encryption device provided by an embodiment of the present disclosure;
[0064] Figure 8 A schematic diagram of the structure of another file encryption device provided by an embodiment of the present disclosure;
[0065] Fig. 9A schematic block diagram of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0066] 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.
[0067] The following describes the file encryption method and device, electronic device, and storage medium according to the embodiments of the present disclosure with reference to the accompanying drawings.
[0068] Figure 1 A flowchart of a file encryption method provided by an embodiment of the present disclosure.
[0069] like Figure 1 As shown, the method comprises the following steps:
[0070] Step 101, compress the target file to obtain compressed target file information, wherein the target file information includes structural information of the target file.
[0071] In the disclosed embodiments, the target files include but are not limited to: FASTA files, SAM / BAM files, VCF files, GFF / GTF files, GFF3 files, SRA files, BED files, WIG files, CRAM files, GVF files, etc., wherein FASTA files: text files used to store biological sequences, including DNA, RNA or protein sequences. It consists of a sequence identification line starting with the symbol ">" and a sequence line immediately following it. SAM / BAM files: used to store aligned sequencing data. SAM (Sequence Alignment / Map) files are in text format, while BAM files are binary compressed formats of SAM files. These files contain detailed information on sequencing reads aligned to a reference sequence, such as sequence, alignment position, alignment quality, etc. VCF files: used to store genetic variation data, such as single nucleotide polymorphisms (SNPs) and small fragment insertions / deletions (Indels). VCF (Variant Call Format) files record information such as the location of the variation, the reference sequence, the type of variation, and the genotype of the corresponding sample. GFF / GTF files: used to store genome annotation information, such as the location and annotations of genes, transcripts, exons, and splice sites. GFF (General Feature Format) and GTF (Gene Transfer Format) files store annotation information in text format. GFF3 files: similar to GFF / GTF files, used to store genome annotation information, but with more stringent specifications and structures. SRA files: a compressed file format used to store raw data from high-throughput sequencing. SRA (Sequence Read Archive) files usually contain unprocessed sequencing reads data, which can be decompressed and processed when needed. BED files: used to store information about genomic regions, such as exons, promoters, and binding sites of genes. BED (Browser Extensible Data) files contain the chromosome location, start and end coordinates of the region, etc. WIG files: used to store numerical data within the genome, such as gene expression levels, chromosome binding site signals, etc. WIG (Wiggle) files contain a series of coordinates and corresponding values. CRAM file: Similar to BAM file, it is used to store aligned high-throughput sequencing data, but uses a more efficient compression algorithm to reduce storage space. GVF file: A file format used to store genomic variation and annotation information. GVF (Genomic Variation Format) files contain variation information between different samples, and can record single nucleotide variation, structural variation, and genotype, etc. Due to the large amount of data in Fastq files, they can contain millions to billions of sequences.It is widely used in the storage and analysis of sequencing data generated by high-throughput sequencing technology, and is used in bioinformatics research such as genome assembly, gene expression analysis, and variation detection.
[0072] To facilitate understanding of the embodiments of the present disclosure, the subsequent embodiments are described using Fastq files as an example. Fastq files are usually composed of four lines: the first line starts with the symbol "@", followed by a unique identifier used to identify the ID of the sequence. The second line is the sequence line, which contains the base sequence of DNA or RNA. The third line starts with the symbol "+", which is usually used to separate the sequence line and the quality line. The fourth line is the quality line, which contains the quality value of each base corresponding to the sequence line. The quality value indicates the credibility of the sequencing of each base, and is often represented by ASCII characters.
[0073] The compressed target file has three components, and the structural information of the target file is: one of the three components of the compressed target file.
[0074] The structural information of the target file includes but is not limited to: data type, address information, offset, etc., wherein the data type is: the data type of the actual data in the target file, such as: the type of gene data, the type of quality index, etc.; the address information is: the storage address information of the actual data in the compressed target file, and it should be noted that the address information is required to obtain the actual data in the compressed target file; the offset is: a computer assembly language, which refers to the distance between the actual address of the storage unit and the segment address of the segment where it is located as the intra-segment offset, also known as "effective address or offset", and the offset is required to accurately determine the address information. Specifically, for the offset, please refer to the description in the relevant technology, so it will not be repeated here.
[0075] Step 102: specify the target encrypted address as the address corresponding to the structure information of the target file.
[0076] In the disclosed embodiment, the address corresponding to the structural information of the target file needs to be used as the target encryption address, so that when the target file is encrypted, only the structural information part of the target file is encrypted.
[0077] Step 103: encrypt the structure information of the target file pointed to by the target encryption address by using a preset encryption algorithm to obtain an encrypted compressed file corresponding to the target file.
[0078] In the embodiments of the present disclosure, the preset encryption algorithm is: a custom-selected encryption algorithm, such as the AES (Advanced Encryption Standard) encryption algorithm, the DES (Data Encryption Standard) encryption algorithm, etc. Specifically, the selection of the preset encryption algorithm can be determined according to actual conditions, and the embodiments of the present disclosure do not limit it.
[0079] The encrypted compressed file is: the compressed target file that has been encrypted. The reason for encrypting the structural information part of the target file can be explained from two perspectives. Perspective 1: From the encryption perspective, the structural information part of the target file stores information about the structure (data type, address information, offset, etc.), which is necessary for decompression. If this part is encrypted, the data in the compressed target file will become inaccessible. Perspective 2: From the performance perspective, the amount of data stored in the structural information part of the target file is small but more important. Encrypting the structural information part of the target file can greatly reduce the impact on the original compression performance.
[0080] The file encryption method provided by the present disclosure compresses the target file to obtain compressed target file information, wherein the target file information includes the structure information of the target file; specifies the target encryption address as the address corresponding to the structure information of the target file; encrypts the structure information of the target file pointed to by the target encryption address through a preset encryption algorithm to obtain an encrypted compressed file corresponding to the target file. Compared with the related art, when encrypting and compressing the target file, the embodiment of the present disclosure encrypts the structure information part of the target file to complete the encryption and compression processing of the target file, without encrypting the entire target file, thereby reducing the loss of compression ratio and saving storage space and compression time.
[0081] In one implementable manner of the disclosed embodiment, when compressing a target file, it is possible to customize whether to encrypt the compressed target file. When it is determined that the compressed target file is to be encrypted, an encryption instruction for the target file needs to be input to encrypt the compressed target file; when it is determined that the compressed target file is not to be encrypted, the target file can be directly compressed without any operation. Therefore, in order to determine whether to encrypt the compressed target file, the following method can also be used but is not limited to: detecting whether an encryption instruction for the target file is received; if it is determined that the encryption instruction is not received, compressing the target file and not encrypting the target file; the designated target encryption address is the address corresponding to the structural information of the target file, including: if it is determined that the encryption instruction is received, encrypting the target file and designating the target encryption address as the address corresponding to the structural information of the target file.
[0082] In one possible implementation of the embodiment of the present disclosure, as a refinement of the above step 101, in order to more clearly understand the components of the compressed target file and the target file information, the embodiment of the present disclosure provides a flow chart of obtaining the file information of the compressed target file, such as Figure 2 As shown, including:
[0083] Step 201 : compress the target file by using a preset compression tool, and obtain composition information of the compressed target file, wherein the composition information includes version information, metadata information and structure information.
[0084] In the embodiment of the present disclosure, the preset compression tool is: a custom-selected compression tool, such as: CoLord, etc. Specifically, the selection of the preset compression tool can be determined according to actual conditions, and the embodiment of the present disclosure does not limit it.
[0085] Among them, the composition information of the compressed target file is: the information corresponding to the components of the compressed target file. The compressed target file consists of three parts, namely, a version information part (info), a metadata information part (meta) and a structure information part (footer). The version information part (info) includes but is not limited to: the version information of the preset compression tool, the version number of the preset compression tool, a timestamp, an input description (read number, base number, original size, in bytes), a specific command, etc.; the metadata information part (meta) includes but is not limited to: the actual data of the target file (dna (gene data), qual (quality index), header (header file)), parameters and options (for example: quality bin threshold), etc.; for the structure information part (footer), please refer to the relevant instructions of the above step 101, so it will not be repeated here.
[0086] Step 202: construct file information according to the version information, metadata information and structure information, and designate the structure information as the target file information.
[0087] In the embodiment of the present disclosure, the file information is constructed in the process of compressing the target file. In the process of compressing the target file, a preset compression tool can automatically construct the file information. When specifying the structural information as the target file information, it is necessary to query the file information and specify it after obtaining the structural information.
[0088] In one implementable manner of the disclosed embodiment, in order to reduce the impact on the original compression performance, when encrypting and compressing the target file, only the structural information of the target file needs to be encrypted, and the version information and / or the metadata information of the target file are not encrypted. Therefore, when encrypting and compressing the target file, it can be implemented in but not limited to the following manner: detecting whether the version information and / or the metadata information are encrypted; if it is determined that the version information and / or the metadata information are encrypted, stopping the encryption of the target file and outputting a first error message; if it is determined that the version information and / or the metadata information are not encrypted, encrypting the structural information of the target file pointed to by the target encryption address by a preset encryption algorithm.
[0089] Among them, the first error information is: a custom set prompt information, for example: an encryption process error, an encryption program error, etc. By detecting whether the version information and / or the metadata information is encrypted, the structural information of the target file can be encrypted more accurately when the target file is encrypted and compressed, thereby reducing the impact on the original compression performance and saving storage space and compression time.
[0090] In one possible implementation of the disclosed embodiment, when the target file is encrypted and compressed, an encryption key is generated synchronously, which can be used to encrypt the target file and decrypt the encrypted compressed file corresponding to the target file. Regarding the generation of the encryption key, the following method can also be used but is not limited to: obtaining the encryption sorting information of the structural information of the target file pointed to by the target encryption address; generating an encryption key according to the encryption sorting information, and the encryption key can be used to encrypt the target file and decrypt the encrypted compressed file corresponding to the target file. Among them, the encryption key is a fixed file randomly generated in the process of encrypting and compressing the target file, and both encryption and decryption need to use this file.
[0091] At the same time, in order to intuitively understand the encryption compression of the target file, the embodiment of the present disclosure provides an example diagram of small data, such as Figure 3 As shown, the normal mode is an unencrypted state, and the encrypted mode is a state after the structural information of the target file is encrypted. It can be seen that in the encrypted mode, only the structural information part of the target file needs to be encrypted and sorted, and an encryption key is generated, and the other data parts remain consistent with the original data.
[0092] In one implementable manner of the disclosed embodiment, after obtaining the encrypted compressed file corresponding to the target file, if the content of the encrypted compressed file is to be viewed again, the encrypted compressed file needs to be decompressed. Since the encrypted compressed file is a compressed file that has been encrypted, the encrypted compressed file needs to be decrypted before being decompressed. Therefore, in order to view the content of the encrypted compressed file, the following method may also be used but is not limited to: in response to a decryption command for the encrypted compressed file, the encrypted compressed file is decrypted based on the encryption key to obtain a decrypted compressed file; and the decompressed compressed file is decompressed to obtain a decompressed target file.
[0093] In combination with all the above embodiments, in order to verify the performance of the encryption method described in the present disclosure, the present disclosure also provides a comparative embodiment of encrypted compression and unencrypted compression. Therefore, in order to more intuitively verify the performance of the method described in the present disclosure, it can also be implemented in but not limited to the following manner:
[0094] Select CoLord as the preset compression tool, select AES encryption algorithm as the preset encryption algorithm, select NovaSeq_HG002_5x.fq, NovaSeq_HG003_5x.fq, and NovaSeq_HG004_5x.fq as the target files, and use the preset compression tool CoLord to compress the target Fastq files without encryption:
[0095] Step 1: After downloading the preset compression tool CoLord, enter the command cd "colord&&make" to compile;
[0096] Step 2: Enter the compression command ". / colord compress-pbraw-G fasta.file-t 16-q org-v input.fileoutput.file" in the "bin" directory;
[0097] Step 3: Enter the decompression command ". / colord decompress-G fasta.file-voutput.fileinput.file" in the "bin" directory;
[0098] Step 4: Record the test results.
[0099] Use the preset compression tool CoLord to encrypt and compress the target file (encrypt the structural information of the target file):
[0100] Step 1: After downloading the preset compression tool CoLord, enter the command cd "colord&&make" to compile;
[0101] Step 2: Enter the command ". / gen-key.sh aes_key" in the current directory to generate a key;
[0102] Step 3: Enter the compression command ". / colord compress-pbraw-G fasta.file-t 16-q org-vE aes-K aes_keyinput.fileoutput.file" in the "bin" directory;
[0103] Step 4: Enter the decompression command ". / colord decompress-G fasta.file-v-Eaes-K aes_keyoutput.fileinput.file" in the "bin" directory;
[0104] Step 5: Record the test results.
[0105] Both compression tests adopted the single variable principle. The only variable was whether encryption was added to the compression tool and used. The test comparison results were as follows: Figure 4 , Figure 5 , Figure 6 As shown in the figure, the p values calculated by Student's t test were all greater than 0.05. Figure 4In , it indicates that the compression ratio after compression using the encryption method disclosed in the present invention is slightly different from the compression ratio of the unencrypted compression, proving that the encryption method disclosed in the present invention has a smaller loss in compression ratio than the encryption method in the related art; in Figure 5 In , it is indicated that the time consumption after compression using the encryption method disclosed in the present invention is slightly different from the time consumption of compression without encryption, proving that the encryption method disclosed in the present invention saves compression time compared with the encryption method in the related art; in Figure 6 It is shown that the compressed memory after compression and decompression using the encryption method described in the present invention is slightly different from the compressed memory without encryption and decompression, which proves that the encryption method described in the present invention saves storage space compared with the encryption method in the related art.
[0106] Based on the above embodiments, the use of the encryption method disclosed in the present invention has little impact on the original compression performance. The test results show that the compression performance after using the encryption method disclosed in the present invention is: the compression ratio can be controlled below 0.1, and the impact on the running time and memory is also controlled within the second level and kb level.
[0107] In summary, the embodiments of the present disclosure can achieve the following effects:
[0108] When encrypting and compressing a target file, the disclosed embodiment completes the encryption and compression processing of the target file by encrypting the structural information portion of the target file, without encrypting the entire target file, thereby reducing the loss of compression ratio and saving storage space and compression time.
[0109] Corresponding to the above-mentioned file encryption method, the present invention also provides a file encryption device. Since the device embodiment of the present invention corresponds to the above-mentioned method embodiment, the details not disclosed in the device embodiment can be referred to the above-mentioned method embodiment, and will not be repeated in the present invention.
[0110] Figure 7 A schematic diagram of a file encryption device provided by an embodiment of the present disclosure is shown in FIG. Figure 7 As shown, including:
[0111] A compression unit 71, used to compress the target file to obtain compressed target file information, wherein the target file information includes structure information of the target file;
[0112] A designating unit 72, configured to designate a target encrypted address as an address corresponding to the structure information of the target file;
[0113] The encryption unit 73 is used to encrypt the structure information of the target file pointed to by the target encryption address by using a preset encryption algorithm to obtain an encrypted compressed file corresponding to the target file.
[0114] The file encryption device provided by the present disclosure compresses the target file to obtain compressed target file information, wherein the target file information includes the structure information of the target file; specifies the target encryption address as the address corresponding to the structure information of the target file; encrypts the structure information of the target file pointed to by the target encryption address through a preset encryption algorithm to obtain an encrypted compressed file corresponding to the target file. Compared with the related art, when encrypting and compressing the target file, the embodiment of the present disclosure encrypts the structure information part of the target file to complete the encryption and compression processing of the target file, without encrypting the entire target file, thereby reducing the loss of compression ratio and saving storage space and compression time.
[0115] Furthermore, in a possible implementation of the embodiment of the present disclosure, as Figure 8 As shown, the device also includes:
[0116] A detection unit 74, used to detect whether an encryption instruction for the target file is received;
[0117] The compression unit 71 is further configured to, when it is determined that the encryption instruction has not been received, compress the target file and not encrypt the target file;
[0118] The designation unit 72 is further configured to, when it is determined that the encryption instruction is received, encrypt the target file and designate the target encryption address as the address corresponding to the structure information of the target file.
[0119] Furthermore, in a possible implementation of the embodiment of the present disclosure, as Figure 8 As shown, the compression unit 71 includes:
[0120] The compression module 711 is used to compress the target file by using a preset compression tool, and obtain the composition information of the compressed target file, wherein the composition information includes version information, metadata information and structure information;
[0121] The construction module 712 is used to construct file information according to the version information, metadata information and structure information, and designate the structure information as the target file information.
[0122] Furthermore, in a possible implementation of the embodiment of the present disclosure, as Figure 8 As shown, the encryption unit 73 includes:
[0123] A detection module 731, used to detect whether the version information and / or the metadata information is encrypted;
[0124] A stop module 732, configured to stop encrypting the target file and output a first error message when it is determined that the version information and / or the metadata information is to be encrypted;
[0125] The encryption module 733 is used to encrypt the structure information of the target file pointed to by the target encryption address by using a preset encryption algorithm when it is determined that the version information and / or the metadata information is not encrypted.
[0126] Furthermore, in a possible implementation of the embodiment of the present disclosure, as Figure 8 As shown, the encryption unit 73 also includes:
[0127] An acquisition module 734 is used to acquire encrypted sorting information of the structure information of the target file pointed to by the target encrypted address;
[0128] The generation module 735 is used to generate an encryption key according to the encrypted sorting information, and the encryption key can be used to encrypt the target file and decrypt the encrypted compressed file corresponding to the target file.
[0129] Furthermore, in a possible implementation of the embodiment of the present disclosure, as Figure 8 As shown, the device also includes:
[0130] The decryption unit 75 is used to respond to the decryption command of the encrypted compressed file and decrypt the encrypted compressed file based on the encryption key to obtain a decrypted compressed file;
[0131] The decompression unit 76 is used to decompress the decrypted compressed file to obtain a decompressed target file.
[0132] It should be noted that the above explanation of the method embodiment is also applicable to the device of the embodiment of the present disclosure, and the principle is the same, which is no longer limited in the embodiment of the present disclosure.
[0133] 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.
[0134] Fig. 9A schematic block diagram of an example electronic device 900 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 gene sequencers, computer clusters, laptop computers, desktop computers, workbenches, 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.
[0135] like Fig. 9 As shown, the device 900 includes a computing unit 901, which can perform various appropriate actions and processes according to a computer program stored in a ROM (Read-Only Memory) 902 or a computer program loaded from a storage unit 908 to a RAM (Random Access Memory) 903. In the RAM 903, various programs and data required for the operation of the device 900 can also be stored. The computing unit 901, the ROM 902, and the RAM 903 are connected to each other via a bus 904. An I / O (Input / Output) interface 905 is also connected to the bus 904.
[0136] A number of components in the device 900 are connected to the I / O interface 905, including: an input unit 906, such as a keyboard, a mouse, etc.; an output unit 907, such as various types of displays, speakers, etc.; a storage unit 908, such as a disk, an optical disk, etc.; and a communication unit 909, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 909 allows the device 900 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0137] The computing unit 901 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 901 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 901 performs the various methods and processes described above, such as a method for file encryption. For example, in some embodiments, the method for file encryption may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 908. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 900 via the ROM 902 and / or the communication unit 909. When the computer program is loaded into the RAM 903 and executed by the computing unit 901, one or more steps of the method described above may be performed. Alternatively, in other embodiments, the computing unit 901 may be configured to execute the aforementioned file encryption method in any other appropriate manner (eg, by means of firmware).
[0138] 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 dedicated 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.
[0139] 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.
[0140] 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 electrical connections based on one or more lines, portable computer disks, hard disks, RAM, ROM, EPROM (Electrically Programmable Read-Only-Memory) or flash memory, optical fiber, CD-ROM (Compact Disc Read-Only Memory), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0141] 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 pointing device (e.g., a mouse or 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).
[0142] 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.
[0143] 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.
[0144] 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.
[0145] 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.
[0146] 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.
Claims
1. A method for encrypting a file, characterized in that: include: Compressing the target file to obtain compressed target file information, wherein the target file information includes structural information of the target file; Specifying the target encrypted address as the address corresponding to the structure information of the target file; The structural information of the target file pointed to by the target encrypted address is encrypted by a preset encryption algorithm to obtain an encrypted compressed file corresponding to the target file.
2. The method according to claim 1, characterized in that Before specifying the target encryption address as the address corresponding to the structure information of the target file, the method further includes: Detecting whether an encryption instruction for the target file is received; If it is determined that the encryption instruction has not been received, compressing the target file and not encrypting the target file; The designated target encrypted address is an address corresponding to the structure information of the target file, including: If it is determined that the encryption instruction is received, the target file is encrypted, and the target encryption address is designated as the address corresponding to the structural information of the target file.
3. The method according to claim 1, characterized in that The target file is compressed to obtain compressed target file information including: Compressing the target file by using a preset compression tool, and obtaining composition information of the compressed target file, wherein the composition information includes version information, metadata information, and structure information; The file information is constructed according to the version information, the metadata information and the structure information, and the structure information is designated as the target file information.
4. The method according to claim 3, characterized in that The encrypting the structure information of the target file pointed to by the target encryption address by using a preset encryption algorithm comprises: Detecting whether the version information and / or the metadata information is encrypted; If it is determined that the version information and / or the metadata information is to be encrypted, then encrypting the target file is stopped and a first error message is output; If it is determined that the version information and / or the metadata information is not encrypted, the structure information of the target file pointed to by the target encrypted address is encrypted using a preset encryption algorithm.
5. The method according to claim 1, characterized in that The encrypting the structure information of the target file pointed to by the target encryption address by using a preset encryption algorithm further includes: Obtaining encrypted sorting information of the structure information of the target file pointed to by the target encrypted address; An encryption key is generated according to the encrypted sorting information, and the encryption key can be used to encrypt the target file and decrypt the encrypted compressed file corresponding to the target file.
6. The method according to claim 5, characterized in that After encrypting the structure information of the target file pointed to by the target encryption address by using a preset encryption algorithm to obtain an encrypted compressed file corresponding to the target file, the method further includes: In response to a decryption command for the encrypted compressed file, decrypt the encrypted compressed file based on the encryption key to obtain a decrypted compressed file; The decrypted compressed file is decompressed to obtain a decompressed target file.
7. A file encryption device, characterized in that: include: A compression unit, used to compress the target file to obtain compressed target file information, wherein the target file information includes structural information of the target file; A designation unit, used to designate a target encryption address as an address corresponding to the structure information of the target file; The encryption unit is used to encrypt the structural information of the target file pointed to by the target encryption address through a preset encryption algorithm to obtain an encrypted compressed file corresponding to the target file.
8. 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 6.
9. 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-6.
10. 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 6.