File encryption method, device, equipment and storage medium
By splitting a file into segments and reassembling them using a software encryption algorithm to generate an encrypted file, the problem of complex key management is solved, achieving efficient file encryption without key management, which is suitable for the security protection of large files.
Patent Information
- Application Number
- CN202310905088.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-21
- Publication Date
- 2025-11-18
- Estimated Expiration
- 2043-07-21
AI Technical Summary
In software-based file encryption methods, key management is complex and risky, affecting the encryption effect.
The original file is divided into multiple file segments, the target sequence is determined, and the target sequence is encrypted using a software encryption algorithm. The content is then reassembled to generate an encrypted file. Security is achieved through the algorithm, rather than key management.
No key management is required, which improves the security and efficiency of file encryption. It is especially suitable for encrypting large files such as high-definition portrait photos, and improves the efficiency and security of face verification.
Smart Images

Figure CN118821156B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of file encryption technology, and in particular to a file encryption method, apparatus, device and storage medium. Background Technology
[0002] Currently, file encryption technologies are categorized into hardware-based encryption and software-based encryption based on whether dedicated hardware devices are used. Software-based encryption refers to encryption methods that do not require dedicated hardware devices. Among related technologies, software-based encryption typically uses general-purpose encryption algorithms, which require keys for encryption and decryption. In some practical application scenarios, key management is complex and risky, thus affecting encryption effectiveness. Summary of the Invention
[0003] This disclosure aims to at least partially address one of the technical problems in the related art.
[0004] The first aspect of this disclosure proposes a file encryption method, comprising: obtaining an original file to be encrypted; dividing the original file into multiple file segments based on preset rules, and determining a target sequence for the multiple file segments; encrypting the target sequence using a software encryption algorithm to obtain an encrypted sequence, and recombining the original file content corresponding to the multiple file segments based on the target sequence to obtain recombined content; and generating an encrypted file corresponding to the original file based on the target information and the recombined content, wherein the target information includes at least the encrypted sequence.
[0005] A second aspect of this disclosure provides a file encryption device, comprising: an acquisition module for acquiring an original file to be encrypted; a segmentation module for segmenting the original file into multiple file segments based on preset rules and determining a target sequence for the multiple file segments; an encryption module for encrypting the target sequence using a software encryption algorithm to obtain an encrypted sequence, and recombining the original file content corresponding to the multiple file segments based on the target sequence to obtain recombined content; and a generation module for generating an encrypted file corresponding to the original file based on the target information and the recombined content, wherein the target information includes at least the encryption sequence.
[0006] A third aspect of this disclosure provides an electronic device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, it implements a file encryption method as proposed in a first aspect of this disclosure.
[0007] The fourth aspect of this disclosure provides a non-transitory computer-readable storage medium having a computer program stored thereon that, when executed by a processor, implements the file encryption method as proposed in the first aspect of this disclosure.
[0008] The fifth aspect of this disclosure provides a computer program product that, when executed by an instruction processor, performs a file encryption method as described in the first aspect of this disclosure.
[0009] In this embodiment, the original file to be encrypted is obtained, and it is divided into multiple file segments based on preset rules. The target sequences of the multiple file segments are determined, and the target sequences are encrypted using a software encryption algorithm to obtain an encrypted sequence. The original file content corresponding to the multiple file segments is reassembled based on the target sequence to obtain reassembled content. An encrypted file corresponding to the original file is generated based on the target information and the reassembled content. The target information includes at least the encrypted sequence, which enables the reassembly of the original file content and the encryption of the reassembled sequence information. The encrypted file is then generated based on the encrypted sequence and the reassembled content. This file encryption process does not require a key; instead, it uses an algorithm to protect the security of file usage. Therefore, key management is not required, which improves the security of file encryption.
[0010] Additional aspects and advantages of this disclosure will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of this disclosure. Attached Figure Description
[0011] The above and / or additional aspects and advantages of this disclosure will become apparent and readily understood from the following description of the embodiments taken in conjunction with the accompanying drawings, in which:
[0012] Figure 1 This is a schematic flowchart of a file encryption method proposed in an embodiment of this disclosure;
[0013] Figure 2 This is a schematic flowchart of a file encryption method proposed in another embodiment of this disclosure;
[0014] Figure 3 This is a schematic flowchart of a file encryption method proposed in another embodiment of this disclosure;
[0015] Figure 4 This is a schematic diagram of the overall file encryption process proposed in the embodiments of this disclosure;
[0016] Figure 5 This is a schematic diagram of the structure of a file encryption device according to another embodiment of this disclosure;
[0017] Figure 6 A block diagram of an exemplary computer device suitable for implementing embodiments of the present disclosure is shown. Detailed Implementation
[0018] Embodiments of this disclosure are described in detail below, examples of which are illustrated in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are used only to explain this disclosure, and should not be construed as limiting this disclosure. Rather, embodiments of this disclosure include all variations, modifications, and equivalents falling within the spirit and scope of the appended claims.
[0019] It should be noted that the execution subject of the file encryption method in this embodiment can be a file encryption device, which can be implemented by software and / or hardware. The device can be configured in an electronic device, which may include, but is not limited to, a terminal, a server, etc.
[0020] Figure 1 This is a schematic flowchart of a file encryption method proposed in an embodiment of this disclosure, as shown below. Figure 1 As shown, the encryption methods for this file include:
[0021] S101: Obtain the original file to be encrypted.
[0022] In this embodiment of the disclosure, the original file to be encrypted can be any possible type of file, such as document, audio, image, etc., and there is no limitation thereto.
[0023] In some embodiments, the original file may be in the form of a byte array, that is, in this embodiment, the original file byte array may be encrypted.
[0024] S102: Based on preset rules, the original file is divided into multiple file segments, and the target sequence of the multiple file segments is determined.
[0025] Furthermore, embodiments of this disclosure can perform segmentation (also known as packet splitting) on the original file to obtain multiple file fragments, such as file fragment 1, 2, ..., N. The number of file fragments (i.e., the total number of packets) can be represented by blockCount. It is understood that the segmentation of file fragments here only determines the sequence number of the file fragments and does not involve the specific file content.
[0026] In this embodiment, the original file can be divided into multiple file segments using any rules. For example, the original file can be divided into multiple file segments of random length, or the original file can be divided into multiple file segments of equal length. There are no restrictions on this.
[0027] The sequence obtained by sorting multiple file fragments is called the target sequence (also known as the packet sequence), which can be represented by nIndex. The target sequence nIndex can be in the form of an array, i.e., packet sequence array [].
[0028] The target sequence nIndex can be, for example, a sequence of multiple file segments ordered in sequence, i.e., [1, 2, 3, 4, 5, ... N]; or, the target sequence can be a sequence of multiple file segments ordered randomly, for example, [20, 5, 9, 17, N, ... 6], without any restrictions.
[0029] In some embodiments, in order to shorten the byte length of the target sequence, this embodiment can use hex strings to represent the target sequence, that is, each byte represents a file segment, without the need to separate them with commas.
[0030] S103: Use a soft encryption algorithm to encrypt the target sequence to obtain an encrypted sequence, and reassemble the original file content corresponding to multiple file segments based on the target sequence to obtain the reassembled content.
[0031] Furthermore, in this embodiment, a software encryption algorithm is invoked to encrypt the target sequence nIndex. The encrypted sequence is called the encrypted sequence (i.e., the ciphertext string), which can be represented by nIndex'. The software encryption algorithm can be any possible software encryption algorithm, and there are no restrictions on it.
[0032] In practical applications, to further enhance file security, the original file to be encrypted can specify a decryption terminal, meaning only the decryption terminal can access the original file. Therefore, in this embodiment, during the encryption of the target sequence nIndex using a software encryption algorithm, the serial number Sn (also known as the module number) of the specified decryption terminal can be input. In other words, the software encryption algorithm encrypts the target sequence nIndex based on the serial number Sn to obtain the encrypted sequence.
[0033] The original file content (in byte array form) refers to the content corresponding to each file segment in the original file. For example, file segment 1 corresponds to a piece of original file content, file segment 2 corresponds to a piece of original file content, and so on. The original file content corresponding to multiple file segments is sequentially concatenated to form the entire original file.
[0034] In this embodiment, the original file content corresponding to multiple file segments can be recombined based on the target sequence nIndex. That is, the original file content corresponding to multiple file segments is rearranged according to the order of the target sequence nIndex, and the resulting file content is called the recombined content.
[0035] S104: Generate an encrypted file corresponding to the original file based on the target information and the reconstructed content.
[0036] The target information is used to describe any possible information of the original file. In this embodiment, the target information may include the above-mentioned encrypted sequence nIndex' and other possible information, without limitation.
[0037] In this embodiment, an encrypted file corresponding to the original file can be generated based on the target information (encrypted sequence nIndex') and the reconstructed content.
[0038] Specifically, in this embodiment, a new file (nfile) is first determined. This new file nfile includes a file header and a content area. In this embodiment, the target information is written to the file header of the new file, and the reconstructed content is written to the content area of the new file nfile. The new file nfile after writing is used as an encrypted file. It can be understood that the new file nfile in this embodiment is also in the form of a byte array.
[0039] To decrypt the data, simply reverse the steps outlined above.
[0040] In practical applications, this file encryption algorithm can be used for large file encryption scenarios, especially high-definition portrait photos. When performing facial recognition verification on high-definition portrait photos, many software encryption methods on the market cannot support large-capacity image encryption. Using this encryption method will improve the efficiency and security of facial recognition verification.
[0041] It should be noted that the acquisition, storage, and application of data and information involved in the technical solution of this application all comply with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0042] In this embodiment, the original file to be encrypted is obtained, and it is divided into multiple file segments based on preset rules. The target sequences of the multiple file segments are determined, and the target sequences are encrypted using a software encryption algorithm to obtain an encrypted sequence. The original file content corresponding to the multiple file segments is reassembled based on the target sequence to obtain reassembled content. An encrypted file corresponding to the original file is generated based on the target information and the reassembled content. The target information includes at least the encrypted sequence, which enables the reassembly of the original file content and the encryption of the reassembled sequence information. The encrypted file is then generated based on the encrypted sequence and the reassembled content. This file encryption process does not require a key; instead, it uses an algorithm to protect the security of file usage. Therefore, key management is not required, which improves the security of file encryption.
[0043] Figure 2 This is a flowchart illustrating a file encryption method according to another embodiment of this disclosure, as shown below. Figure 2 As shown, the encryption methods for this file include:
[0044] S201: Obtain the original file to be encrypted.
[0045] For a detailed explanation of S201, please refer to the above embodiments, which will not be repeated here.
[0046] S202: Obtain the file length of the original file and determine the segment length of the file fragment based on the file length.
[0047] In the process of dividing the original file into multiple file segments, the file length of the original file can be obtained first, that is, the length of the original file's byte array, which can be represented by filesize.
[0048] Furthermore, the segment length of each file segment is determined based on the file length (filesize), which can be represented by blocksize.
[0049] In some implementations, the total number of packets (blockCount) can be preset, and then the ratio of the file length (filesize) to the total number of packets (blockCount) can be calculated as the segment length (blocksize), i.e.: blocksize = filesize / blockCount.
[0050] In practical applications, to improve processing speed, the range of the total number of packets (blockCount) can be limited, for example, from 200 to 255. This implementation can obtain a random number from this range as the total number of packets, and further calculate the fragment length (blocksize) based on the filesize divided by the random number.
[0051] S203: Split the original file based on the fragment length to obtain multiple file fragments.
[0052] In other words, this embodiment divides the original file into multiple file segments of equal length (blocksize).
[0053] In practical applications, if the length (number of bytes) of the remainder after splitting is less than the segment length blocksize, then the remainder is taken as the last file segment, and its length can be represented by lastblocksize.
[0054] S204: Determine the initial sequence of multiple file fragments.
[0055] In determining the target sequence nIndex of multiple file segments in this embodiment, the initial sequence of multiple file segments is first determined. For example, if the total number of packets blockCount in this embodiment is 200, then the initial sequence is: [0,1,2....199].
[0056] S205: Randomize the initial sequence to obtain the target sequence.
[0057] Furthermore, the initial sequence is scrambled to obtain the target sequence nIndex, for example: [41, 1, 80... 2]. In this embodiment, scrambling the initial sequence further enhances the security of the encrypted file.
[0058] S206: Use a soft encryption algorithm to encrypt the target sequence to obtain an encrypted sequence, and reassemble the original file content corresponding to multiple file segments based on the target sequence to obtain the reassembled content.
[0059] S207: Generate an encrypted file corresponding to the original file based on the target information and the reconstructed content.
[0060] For detailed explanations of S206-S207, please refer to the above embodiments, and they will not be repeated here.
[0061] In this embodiment, the original file to be encrypted is obtained, and it is divided into multiple file segments based on preset rules. Target sequences for these file segments are determined, and the target sequences are encrypted using a software encryption algorithm to obtain encrypted sequences. The original file content corresponding to the multiple file segments is then reassembled based on the target sequences to obtain reassembled content. Finally, an encrypted file corresponding to the original file is generated based on the target information and the reassembled content. The target information includes at least the encrypted sequence, enabling the reassembly of the original file content and the encryption of the reassembled sequence information. The encrypted file is then generated based on the encrypted sequence and the reassembled content. This encryption process does not require a key; instead, it uses an algorithm to protect the file's security, thus eliminating the need for key management and improving file encryption security. Furthermore, this embodiment further enhances the security of the encrypted file by scrambling the initial sequence.
[0062] Figure 3 This is a flowchart illustrating a file encryption method according to another embodiment of this disclosure, as shown below. Figure 3 As shown, the encryption methods for this file include:
[0063] S301: Obtain the original file to be encrypted.
[0064] S302: Based on preset rules, the original file is divided into multiple file segments, and the target sequence of the multiple file segments is determined.
[0065] S303: Use a soft encryption algorithm to encrypt the target sequence to obtain an encrypted sequence.
[0066] For detailed descriptions of S301-S303, please refer to the above embodiments, which will not be repeated here.
[0067] S304: Traverse the target sequence and determine the starting position of each traversed file segment in the original file.
[0068] In this embodiment of the disclosure, during the process of recombining the original file content corresponding to multiple file segments based on the target sequence, the file segments in the target sequence nIndex (e.g., [41,1,80...2]) are first traversed, and the starting position of each traversed file segment in the original file is determined.
[0069] S305: Based on the starting position and the length of the file segment, determine the original file content corresponding to the traversed file segment.
[0070] Specifically, in this embodiment, the content starting from the beginning position of the original file and having a blocksize length is used as the original file content corresponding to the file segment traversed this time.
[0071] For example, if the file segment 41 is traversed this time, then in this embodiment, the file content starting from the beginning position of file segment 41 and having a length of blocksize in the original file (byte array) will be taken as the original file content corresponding to file segment 41.
[0072] S306: Concatenate the original file contents of the traversed file segments one by one to obtain the reconstructed content.
[0073] Furthermore, the original file content of the traversed file segments is spliced together to obtain the reconstructed content.
[0074] S307: Write the encrypted sequence, fragment length, and sequence number into the file header in the target format, write the reconstructed content into the content area of the new file, and the new file after writing is used as the encrypted file.
[0075] In this embodiment of the disclosure, the target information may include, for example, the encrypted sequence nIndex', the fragment length blocksize, and the serial number Sn of the decryption terminal.
[0076] In the process of writing target information into the header of the new file nfile, this embodiment writes each type of target information (i.e., nIndex', blocksize, Sn) into the header of the new file nfile in the target format. The target format can be any possible format, such as TLV format, and there is no limitation on it.
[0077] Specifically, in this embodiment, the length nLenght (2 bytes) of the encrypted sequence nIndex' and its content can first be written in TLV format to the beginning of the new file nfile at the position nLenght. For example, if the length of the encrypted sequence nIndex' is 1000 bytes, then the TLV format of nIndex' is written to the beginning of the new file nfile as: F1 03E8 nIndex' content, where F1 = content type, and Len occupies 2 bytes = 03E8.
[0078] Furthermore, the fragment length `blocksize` is appended to the header of the new file `nfile` in TLV format. For example, if `blocksize` = 254 bytes, the corresponding TLV format is `F2 00 01FE`, where `F2` is the content type and `Len` occupies 2 bytes = `00 01`.
[0079] Furthermore, the serial number Sn is appended to the header of the new file nfile in TLV format. For example, Sn = 01 0203 04, corresponding to the TLV format = F3 04 01 02 03 04, where F3 is the content type and Len occupies 2 bytes = 04.
[0080] In some embodiments, before writing the target information into the header of the new file, the embodiments of this disclosure may also calculate the number of bytes occupied by the encrypted sequence nIndex', the fragment length blocksize, and the TLV format (i.e., the target format) of the sequence number Sn, and calculate the total number of bytes occupied by the three items nHeadLength; further, the sum of the total number of bytes occupied nHeadLength and the file length filesize is calculated as the file length of the new file nfile, that is: the byte array of the length of the new file nfile is defined by nHeadLength + filesize.
[0081] Therefore, this embodiment can use various target information such as encryption sequence, byte length, and sequence number to encrypt the original file, thereby improving the encryption effect.
[0082] In some embodiments, when the remainder after segmentation is less than the fragment length, this embodiment can read the remainder fragment length (lastblocksize) from the end of the original file and append it to the end of the content area.
[0083] In other embodiments, after writing the reconstructed content to a new file nfile, this embodiment can also invert all the reconstructed content in the new file nfile (a byte array), and the inverted nfile is used as the encrypted file. This further enhances the security of the encrypted file.
[0084] In this embodiment, the original file to be encrypted is obtained, and it is divided into multiple file segments based on preset rules. Target sequences for these file segments are determined, and a software encryption algorithm is used to encrypt the target sequences to obtain encrypted sequences. The original file content corresponding to the multiple file segments is then reassembled based on the target sequences to obtain reassembled content. Finally, an encrypted file corresponding to the original file is generated based on the target information and the reassembled content. The target information includes at least the encrypted sequence, enabling the reassembly of the original file content and the encryption of the reassembled sequence information. The encrypted file is then generated based on the encrypted sequence and the reassembled content. This encryption process does not require a key; instead, it uses an algorithm to protect the file's security, thus eliminating the need for key management and improving file encryption security. Furthermore, this embodiment can utilize various target information such as encrypted sequences, byte lengths, and sequence numbers to encrypt the original file, enhancing the encryption effect.
[0085] In a specific instance Figure 4 This is a schematic diagram of the overall file encryption process proposed in the embodiments of this disclosure, such as... Figure 4As shown, first, the original file (file) and sequence number sn are input, and file is converted into a byte array. Next, the file length (filesize) is obtained, and the size of each packet (file segment) is calculated based on filesize. Appropriate random fine-tuning is added to obtain the segment length (blocksize), and the total number of packets (blockcount) is calculated. Further, a packet sequence array (i.e., the initial sequence) is generated based on the total number of packets (blockcount). After scrambling, a new packet sequence (nIndex) (i.e., the target sequence) is obtained. Then, the soft encryption algorithm is called, and sn is input to obtain the encrypted nIndex' (hex), i.e., the encrypted sequence. Then, the TLV format of nIndex', the TLV format of blockcount, and the TLV format of sn are calculated, along with the total number of bytes occupied by these three items, to obtain nHeadLength. This is then named nHeadLength. The `th+filesize` method redefines the length of the `nfile` byte array and generates a new filename `nfile` according to the rules, ready to be written to `nfile`. Further, the length `nLength` (2 bytes) of `nIndex` and its content are written to the first `nLength` position of `nfile` in TLV format, and `blocksize` and `sn` are appended to `nfile` in TLV format. Further, the `nIndex` array is traversed, the starting position of each packet is calculated, and the packet is appended to `nfile` from the last position in `file`, for example, 41 (packet number) * `blocksize`, forming the copy block area to create the content of `nfile`. Further, if the remainder `lastblocksize` is greater than 0, the content of length `lastblocksize` is read from the end of `file` and appended to the end of `nfile`, and the entire `nfile` byte array is inverted, overwriting the `nfile` byte array. Finally, the `nfile` byte array is written to the file, outputting the new file, i.e., the encrypted file.
[0086] Figure 5 This is a schematic diagram of the structure of a file encryption device according to another embodiment of this disclosure, as shown below. Figure 5 As shown, the file encryption device 50 includes:
[0087] Module 501 is used to obtain the original file to be encrypted;
[0088] The segmentation module 502 is used to segment the original file into multiple file segments based on preset rules and determine the target sequence of the multiple file segments;
[0089] Encryption module 503 is used to encrypt the target sequence using a software encryption algorithm to obtain an encrypted sequence, and to reassemble the original file content corresponding to multiple file segments based on the target sequence to obtain the reassembled content; and
[0090] The generation module 504 is used to generate an encrypted file corresponding to the original file based on the target information and the reconstructed content, wherein the target information includes at least an encrypted sequence.
[0091] In some embodiments, the segmentation module 502 is specifically used to: obtain the file length of the original file and determine the segment length of the file fragment based on the file length; and segment the original file based on the segment length to obtain multiple file fragments.
[0092] In some embodiments, the segmentation module 502 is specifically used to: determine an initial sequence of multiple file segments; and to shuffle the initial sequence to obtain a target sequence.
[0093] In some embodiments, the generation module 504 is specifically used to: write target information into the header of a new file, write the original file content corresponding to multiple file fragments into the content area of the new file, and the new file after writing is used as an encrypted file.
[0094] In some embodiments, the target information also includes the fragment length of the file segment and the serial number of the decryption terminal. The generation module 504 is specifically used to write the encrypted sequence, fragment length, and serial number into the file header in the target format, respectively.
[0095] In some embodiments, the generation module 504 is also used to: calculate the total number of bytes occupied by the target format of the encrypted sequence, fragment length, and sequence number; and calculate the sum of the total number of bytes occupied and the file length as the file length of the new file.
[0096] In some embodiments, the encryption module 503 is specifically used to: use a soft encryption algorithm to encrypt the target sequence based on the sequence number to obtain an encrypted sequence.
[0097] In some embodiments, the encryption module 503 is specifically used for: traversing the target sequence and determining the starting position of each traversed file segment in the original file; determining the original file content corresponding to the traversed file segment based on the starting position and the segment length of the file segment; and sequentially concatenating the original file content of the traversed file segments to obtain the reconstructed content.
[0098] In some embodiments, the generation module 504 is specifically used to: in response to the remainder portion after segmentation being less than the fragment length, read the content of the remainder fragment length from the end of the original file and write it to the end of the content area.
[0099] In some embodiments, the generation module is specifically used to: invert the recombined content.
[0100] In this embodiment, the original file to be encrypted is obtained, and it is divided into multiple file segments based on preset rules. The target sequences of the multiple file segments are determined, and the target sequences are encrypted using a software encryption algorithm to obtain an encrypted sequence. The original file content corresponding to the multiple file segments is reassembled based on the target sequence to obtain reassembled content. An encrypted file corresponding to the original file is generated based on the target information and the reassembled content. The target information includes at least the encrypted sequence, which enables the reassembly of the original file content and the encryption of the reassembled sequence information. The encrypted file is then generated based on the encrypted sequence and the reassembled content. This file encryption process does not require a key; instead, it uses an algorithm to protect the security of file usage. Therefore, key management is not required, which improves the security of file encryption.
[0101] To implement the above embodiments, this disclosure also proposes a non-transitory computer-readable storage medium storing a computer program, which, when executed by a processor, implements the file encryption method proposed in the foregoing embodiments of this disclosure.
[0102] To implement the above embodiments, this disclosure also proposes a computer program product that, when executed by an instruction processor, performs a file encryption method as proposed in the foregoing embodiments of this disclosure.
[0103] Figure 6 A block diagram of an exemplary computer device suitable for implementing embodiments of the present disclosure is shown. Figure 6 The computer device 12 shown is merely an example and should not be construed as limiting the functionality and scope of use of the embodiments disclosed herein.
[0104] like Figure 6 As shown, the computer device 12 is represented in the form of a general-purpose computing device. The components of the computer device 12 may include, but are not limited to: one or more processors or processing units 16, system memory 28, and a bus 18 connecting different system components (including system memory 28 and processing unit 16).
[0105] Bus 18 represents one or more of several bus architectures, including a memory bus or memory controller, a peripheral bus, a graphics acceleration port, a processor, or a local bus using any of the various bus architectures. Examples of these architectures include, but are not limited to, the Industry Standard Architecture (ISA) bus, the Micro Channel Architecture (MAC) bus, the Enhanced ISA bus, the Video Electronics Standards Association (VESA) local bus, and the Peripheral Component Interconnect (PCI) bus.
[0106] Computer device 12 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by computer device 12, including volatile and non-volatile media, removable and non-removable media.
[0107] Memory 28 may include computer system readable media in the form of volatile memory, such as Random Access Memory (RAM) 30 and / or cache memory 32. Computer device 12 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, storage system 34 may be used to read and write non-removable, non-volatile magnetic media (…). Figure 6 Not shown; usually referred to as a "hard drive"). Although Figure 6 Not shown, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk") and an optical disc drive for reading and writing to a removable non-volatile optical disc (e.g., a compact disc read-only memory (CD-ROM), a digital video disc read-only memory (DVD-ROM), or other optical media) may be provided. In these cases, each drive may be connected to bus 18 via one or more data media interfaces. Memory 28 may include at least one program product having a set (e.g., at least one) of program modules configured to perform the functions of the embodiments of this disclosure.
[0108] A program / utility 50 having a set (at least one) of program modules 42 may be stored, for example, in memory 28. Such program modules 42 include, but are not limited to, an operating system, one or more application programs, other program modules, and program data. Each or some combination of these examples may include an implementation of a network environment. Program modules 42 typically perform the functions and / or methods described in the embodiments of this disclosure.
[0109] Computer device 12 can also communicate with one or more external devices 14 (e.g., keyboard, pointing device, display 24, etc.), and with one or more devices that enable a user to interact with computer device 12, and / or with any device that enables computer device 12 to communicate with one or more other computing devices (e.g., network card, modem, etc.). This communication can be performed via input / output (I / O) interface 22. Furthermore, computer device 12 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via network adapter 20. As shown, network adapter 20 communicates with other modules of computer device 12 via bus 18. It should be understood that, although not shown in the figures, other hardware and / or software modules can be used in conjunction with computer device 12, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0110] The processing unit 16 executes various functional applications and data processing by running programs stored in the system memory 28, such as implementing the methods mentioned in the foregoing embodiments.
[0111] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of this disclosure. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.
[0112] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this disclosure, "a plurality of" means at least two, such as two, three, etc., unless otherwise explicitly specified.
[0113] Any process or method description in the flowchart or otherwise herein can be understood as representing a module, segment, or portion of code comprising one or more executable instructions for implementing custom logic functions or processes, and the scope of preferred embodiments of this disclosure includes additional implementations in which functions may be performed not in the order shown or discussed, including substantially simultaneously or in reverse order depending on the functions involved, as will be understood by those skilled in the art to which embodiments of this disclosure pertain.
[0114] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (such as a computer-based system, a processor-included system, or other system that can fetch and execute instructions from, an instruction execution system, apparatus, or device). For the purposes of this specification, "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transmit programs for use by, or in conjunction with, an instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of computer-readable media include: an electrical connection having one or more wires (electronic device), a portable computer disk drive (magnetic device), random access memory (RAM), read-only memory (ROM), erasable and editable read-only memory (EPROM or flash memory), fiber optic devices, and portable optical disc read-only memory (CDROM). Alternatively, the computer-readable medium may be paper or other suitable media on which the program can be printed, since the program can be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, interpreting, or otherwise processing as necessary, and then stored in a computer memory.
[0115] It should be understood that various parts of this disclosure can be implemented using hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented using software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.
[0116] Those skilled in the art will understand that all or part of the steps of the methods in the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, the program includes one or a combination of the steps of the method embodiments.
[0117] Furthermore, the functional units in the various embodiments of this disclosure can be integrated into a processing module, or each unit can exist physically separately, or two or more units can be integrated into a module. The integrated module can be implemented in hardware or as a software functional module. If the integrated module is implemented as a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium.
[0118] The storage medium mentioned above can be a read-only memory, a disk, or an optical disk, etc. Although embodiments of the present disclosure have been shown and described above, it is to be understood that the above embodiments are exemplary and should not be construed as limiting the present disclosure. Those skilled in the art can make changes, modifications, substitutions, and variations to the above embodiments within the scope of the present disclosure.
Claims
1. A file encryption method, characterized in that, include: Obtain the original file to be encrypted; The original file is divided into multiple file segments based on preset rules, and the target sequence of the multiple file segments is determined. The target sequence is encrypted using a software encryption algorithm to obtain an encrypted sequence, and the original file content corresponding to the multiple file fragments is reassembled based on the target sequence to obtain reassembled content; as well as An encrypted file corresponding to the original file is generated based on the target information and the reconstructed content, wherein the target information includes at least the encryption sequence; The step of determining the target sequence of the plurality of file fragments includes: Determine the initial sequence of the plurality of file segments; and The initial sequence is shuffled to obtain the target sequence; The step of generating an encrypted file corresponding to the original file based on the target information and the reconstructed content includes: The target information is written into the header of the new file, and the reconstructed content is written into the content area of the new file. The new file after writing is used as the encrypted file. The target information further includes the segment length of the file fragment and the serial number of the decryption terminal. Writing the target information into the header of the new file includes: The encrypted sequence, the fragment length, and the sequence number are written into the file header in the target format, respectively. The step of encrypting the target sequence using a soft encryption algorithm to obtain an encrypted sequence includes: The target sequence is encrypted using the aforementioned soft encryption algorithm based on the sequence number to obtain the encrypted sequence.
2. The method according to claim 1, characterized in that, The process of dividing the original file into multiple file segments based on preset rules includes: Obtain the file length of the original file, and determine the segment length of the file segment based on the file length; The original file is segmented based on the segment length to obtain the multiple file segments.
3. The method according to claim 2, characterized in that, Before writing the encrypted sequence, the fragment length, and the sequence number into the file header in the target format, the method further includes: Calculate the total number of bytes occupied by the target format of the encrypted sequence, the fragment length, and the sequence number; and The sum of the total number of bytes occupied and the file length is used as the file length of the new file.
4. The method according to claim 1, characterized in that, The step of reconstructing the original file content corresponding to the multiple file fragments based on the target sequence to obtain reconstructed content includes: Traverse the target sequence and determine the starting position of each traversed file segment in the original file; Based on the starting position and the length of the file segment, determine the original file content corresponding to the traversed file segment; and The original file content of each traversed file segment is then concatenated to obtain the reconstructed content.
5. The method according to claim 1, characterized in that, The step of writing the reorganized content into the content area of the new file further includes: In response to the remainder portion after segmentation being less than the fragment length, the content of the remainder fragment length is read from the end of the original file and written to the end of the content region.
6. The method according to claim 1, characterized in that, After writing the reorganized content into the content area of the new file, the method further includes: The recombined content is inverted.
7. A file encryption device, characterized in that, The device includes: The acquisition module is used to acquire the original file to be encrypted; The segmentation module is used to segment the original file into multiple file segments based on preset rules, and to determine the target sequence of the multiple file segments; An encryption module is used to encrypt the target sequence using a software encryption algorithm to obtain an encrypted sequence, and to reassemble the original file content corresponding to the multiple file segments based on the target sequence to obtain reassembled content; and A generation module is used to generate an encrypted file corresponding to the original file based on the target information and the reconstructed content, wherein the target information includes at least the encryption sequence; The segmentation module includes: A determining unit, configured to determine the initial sequence of the plurality of file segments; and A sorting processing unit is used to perform random sorting processing on the initial sequence to obtain the target sequence; The generation module includes: The writing unit is used to write the target information into the header of the new file, write the reconstructed content into the content area of the new file, and the new file after writing is used as the encrypted file. The target information further includes the segment length of the file fragment and the serial number of the decryption terminal. The writing unit is also used for: The encrypted sequence, the fragment length, and the sequence number are written into the file header in the target format, respectively. The encryption module includes: An encryption processing unit is used to encrypt the target sequence based on the sequence number using the soft encryption algorithm to obtain the encrypted sequence.
8. An electronic device, characterized in that, It includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, it implements the file encryption method as described in any one of claims 1-6.
9. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the file encryption method as described in any one of claims 1-6.
10. A computer program product, characterized in that, It includes a computer program that, when executed by a processor, implements the file encryption method as described in any one of claims 1-6.
Citation Information
Patent Citations
File secure transmission method and file secure transmission device
CN105721463A
File encryption method and mobile terminal
CN106355109A