File encryption method and device, electronic equipment and storage medium
By segmenting files and using hardware encryption, the problem of key-dependent file encryption is solved, achieving keyless encryption and improving file security and decryption flexibility.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-03
- Publication Date
- 2026-04-07
AI Technical Summary
Existing file encryption methods rely on keys, which can lead to decryption failures and significant losses if the key is lost or leaked.
The file to be encrypted is split into fragments, which are then shuffled. Hardware identifiers are used to encrypt the file fragments, resulting in an encrypted file.
File encryption can be achieved without relying on a key, which improves file security and decryption flexibility, and reduces the risk of key loss or leakage.
Smart Images

Figure CN119442257B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of encryption technology, and in particular to a file encryption method, apparatus, electronic device, and storage medium. Background Technology
[0002] As the application of the internet and information technology permeates all aspects of people's lives, people's demands for information security are increasing. How to securely store confidential documents on storage devices, and how to effectively encrypt and decrypt files, have become important research directions in the field of information security.
[0003] In related technologies, file encryption and decryption require an encryption algorithm (generally a symmetric encryption algorithm) and an encryption / decryption key. Encryption is performed using the key and the chosen symmetric encryption algorithm, and decryption is performed using the same key and the same symmetric encryption algorithm used for encryption. Encrypting files using this method creates a strong dependency on the key; without the key, the encrypted file cannot be decrypted, rendering it unusable. For the file owner, the loss or leakage of the key can result in significant losses. Summary of the Invention
[0004] This disclosure aims to at least partially address one of the technical problems in the related art.
[0005] The first aspect of this disclosure provides a file encryption method, including:
[0006] The file to be encrypted is split into multiple file fragments, each of which has a corresponding identifier.
[0007] A first identifier sequence is generated based on the position of each file fragment in the file to be encrypted and its corresponding identifier;
[0008] Based on the scrambled first identifier sequence, the corresponding file segments are reassembled to obtain the reassembled file;
[0009] The hardware corresponding to the preset hardware identifier is invoked to perform hardware encryption on the scrambled first identifier sequence to obtain the encrypted second identifier sequence.
[0010] The encrypted file corresponding to the file to be encrypted is determined based on the encrypted second identifier sequence, the length of the file fragment, the preset hardware identifier, and the reconstructed file.
[0011] A second aspect of this disclosure provides a file encryption device, comprising:
[0012] The first acquisition module is used to perform fragmentation processing on the file to be encrypted in order to obtain multiple file fragments, wherein each file fragment has a corresponding identifier;
[0013] The generation module is used to generate a first identifier sequence based on the position of each file fragment in the file to be encrypted and its corresponding identifier;
[0014] The second acquisition module is used to reassemble the corresponding file segments based on the scrambled first identifier sequence in order to obtain the reassembled file;
[0015] The third acquisition module is used to call the hardware corresponding to the preset hardware identifier to perform hardware encryption on the scrambled first identifier sequence in order to obtain the encrypted second identifier sequence.
[0016] The determining module is used to determine the encrypted file corresponding to the file to be encrypted based on the encrypted second identifier sequence, the length of the file fragment, the preset hardware identifier, and the reconstructed file.
[0017] 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 the file encryption method as proposed in the first aspect of this disclosure.
[0018] A fourth aspect of this disclosure provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements a file encryption method as proposed in a first aspect of this disclosure.
[0019] The file encryption method, apparatus, electronic device, and storage medium disclosed herein have the following beneficial effects:
[0020] In this embodiment, the file to be encrypted is first fragmented to obtain multiple file segments, each with a corresponding identifier. Then, based on the position of each file segment within the file to be encrypted and its corresponding identifier, a first identifier sequence is generated. Next, based on the scrambled first identifier sequence, the corresponding file segments are reassembled to obtain a reassembled file. Hardware corresponding to a preset hardware identifier is invoked to perform hardware encryption on the scrambled first identifier sequence to obtain an encrypted second identifier sequence. Finally, based on the encrypted second identifier sequence, the length of the file segments, the preset hardware identifier, and the reassembled file, the corresponding encrypted file is determined. Thus, by scrambling and reassembling the file to be encrypted, and combining this with the hardware-encrypted scrambled first identifier sequence, the length of the file segments, and the preset hardware identifier, an encrypted file is generated, thereby encrypting the file without relying on a key.
[0021] 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
[0022] 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:
[0023] Figure 1 This is a schematic flowchart of a file encryption method provided in an embodiment of the present disclosure;
[0024] Figure 2 This is a schematic flowchart illustrating a file encryption method provided in another embodiment of this disclosure;
[0025] Figure 3 This is a schematic flowchart illustrating a file encryption method provided in another embodiment of this disclosure;
[0026] Figure 4 This is a schematic diagram of the structure of a file encryption device provided in another embodiment of the present disclosure;
[0027] Figure 5 A block diagram of an exemplary electronic device suitable for implementing embodiments of the present disclosure is shown. Detailed Implementation
[0028] 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 intended to explain this disclosure, and should not be construed as limiting this disclosure.
[0029] The following description, with reference to the accompanying drawings, outlines a file encryption method, apparatus, electronic device, and storage medium according to embodiments of the present disclosure.
[0030] Figure 1 This is a schematic flowchart of the file encryption method provided in the embodiments of this disclosure.
[0031] This disclosure illustrates an example where the file encryption method is configured in a file encryption device. This file encryption device can be applied to any electronic device so that the electronic device can perform file encryption functions.
[0032] Among them, electronic devices can be personal computers (PCs), cloud devices, mobile devices, etc. Mobile devices can be hardware devices with various operating systems, touch screens and / or displays, such as mobile phones, tablets, personal digital assistants, wearable devices, and in-vehicle devices.
[0033] like Figure 1 As shown, the file encryption method may include the following steps:
[0034] Step 101: The file to be encrypted is split into fragments to obtain multiple file segments, each of which has a corresponding identifier.
[0035] Optionally, the file to be encrypted can be divided into fragments based on a preset number of fragments. For example, the preset number of fragments can be 100, 200, 250, etc. This disclosure does not limit this.
[0036] Optionally, the file to be encrypted can be divided into uniform fragments or uneven fragments. This disclosure does not limit this process.
[0037] The identifier for each file segment can be its location within the file to be encrypted. For example, the identifier for the first file segment could be 1 or 0, and the identifier for the second file segment could be 2 or 1, and so on.
[0038] Optionally, before splitting the file to be encrypted into multiple file segments, the file can be converted into a bit array format.
[0039] Step 102: Generate a first identifier sequence based on the position of each file fragment in the file to be encrypted and its corresponding identifier.
[0040] For example, if the file segment identified as 1 is the first file segment in the file to be encrypted, and the file segment identified as 2 is the second file segment in the file to be encrypted, then the first identifier sequence can be [1, 2, 3, ..., n]. Where n is the number of file segments.
[0041] Alternatively, if the file segment identified as 0 is the first file segment in the file to be encrypted, and the file segment identified as 1 is the second file segment in the file to be encrypted, then the first identifier sequence can also be [0, 1, 2, ..., n-1]. Where n is the number of file segments.
[0042] Step 103: Based on the scrambled first identifier sequence, reassemble the corresponding file segments to obtain the reassembled file.
[0043] Specifically, the first identifier sequence is first randomly shuffled, and then the corresponding file segments are reassembled based on the shuffled first identifier sequence to obtain the reassembled file.
[0044] For example, if the first identifier sequence is [1, 2, 3, 4, ..., 200], the shuffled first identifier sequence can be [42, 80, 1, 5, 3, ..., 2, 4], or [15, 30, 5, 3, ..., 20, 140], etc. This disclosure does not limit this.
[0045] If the first identifier sequence after scrambling can be [42, 80, 1, 5, 3, ..., 2, 4], then the first file segment in the reconstructed file is the file segment identified as 42 in the file to be encrypted, the second file segment in the reconstructed file is the file segment identified as 80 in the file to be encrypted, and so on.
[0046] In some possible implementations, after obtaining the reconstructed file, the entire reconstructed file can be inverted. This can further ensure the security of the file to be encrypted.
[0047] Step 104: Call the hardware corresponding to the preset hardware identifier to perform hardware encryption on the scrambled first identifier sequence to obtain the encrypted second identifier sequence.
[0048] The second identifier sequence can be a shuffled version of the first identifier sequence.
[0049] The preset hardware identifier can be a pre-defined identifier of the hardware used to perform hardware encryption on the file to be encrypted. For example, the preset hardware identifier can be the hardware's serial number (SN). This disclosure does not limit this.
[0050] Hardware encryption is typically implemented using dedicated encryption chips or security modules. These chips or modules integrate encryption algorithms and key management functions into the hardware, allowing for direct encryption and decryption of data at the hardware level. Hardware encryption often employs symmetric encryption algorithms (such as Advanced Encryption Standard) or asymmetric encryption algorithms (such as RSA encryption).
[0051] It should be noted that, in this embodiment, the implementation order of steps 103 and 104 is not specifically limited. Step 103 can be executed first, or step 104 can be executed first; this disclosure does not limit this.
[0052] Step 105: Determine the encrypted file corresponding to the file to be encrypted based on the encrypted second identifier sequence, the length of the file segment, the preset hardware identifier, and the reconstructed file.
[0053] In this embodiment of the disclosure, after determining the encrypted second identifier sequence, the length of the file segment, the preset hardware identifier, and the reconstructed file, the encrypted file corresponding to the file to be encrypted can be determined.
[0054] Specifically, the length of the encrypted second identifier sequence, the file fragment, the preset hardware identifier, and the byte length of the reconstructed file can be determined first, as well as their arrangement order in the encrypted file. Then, based on the byte length and arrangement order, the encrypted second identifier sequence, the length of the file fragment, the preset hardware identifier, and the reconstructed file are reconstructed to obtain the encrypted file.
[0055] The encrypted second identifier sequence, the length of the file segment, and the byte length occupied by the preset hardware identifier can be predefined. The encrypted second identifier sequence, the length of the file segment, and the byte length occupied by the preset hardware identifier can be the same or different. This disclosure does not impose any limitations on this.
[0056] The order of arrangement can also be predetermined, for example, the order can be the encrypted second identifier sequence, the preset hardware identifier, the length of the file segment, and the reconstructed file.
[0057] For example, if the preset encrypted second identifier sequence occupies 500 bytes, the file fragment length occupies 2 bytes, and the preset hardware identifier occupies 4 bytes each, and the order is the encrypted second identifier sequence, the preset hardware identifier, the file fragment length, and the reconstructed file, then bytes 1-500 are the encrypted second identifier sequence, bytes 501-504 are the preset hardware identifier, bytes 505-506 are the file fragment length, and the remaining bytes are the reconstructed file.
[0058] In this embodiment, the file to be encrypted is first fragmented to obtain multiple file segments, each with a corresponding identifier. Then, based on the position of each file segment within the file to be encrypted and its corresponding identifier, a first identifier sequence is generated. Next, based on the scrambled first identifier sequence, the corresponding file segments are reassembled to obtain a reassembled file. Hardware corresponding to a preset hardware identifier is invoked to perform hardware encryption on the scrambled first identifier sequence to obtain an encrypted second identifier sequence. Finally, based on the encrypted second identifier sequence, the length of the file segments, the preset hardware identifier, and the reassembled file, the corresponding encrypted file is determined. Thus, by scrambling and reassembling the file to be encrypted, and combining this with the hardware-encrypted scrambled first identifier sequence, the length of the file segments, and the preset hardware identifier, an encrypted file is generated, thereby encrypting the file without relying on a key.
[0059] Figure 2 This is a schematic flowchart of a file encryption method provided in an embodiment of the present disclosure, as shown below. Figure 2 As shown, the file encryption method may include the following steps:
[0060] Step 201: The file to be encrypted is split into fragments to obtain multiple file segments, each of which has a corresponding identifier.
[0061] Step 202: Generate a first identifier sequence based on the position of each file fragment in the file to be encrypted and its corresponding identifier.
[0062] Step 203: Based on the scrambled first identifier sequence, reassemble the corresponding file segments to obtain the reassembled file.
[0063] Step 204: Call the hardware corresponding to the preset hardware identifier to perform hardware encryption on the scrambled first identifier sequence to obtain the encrypted second identifier sequence.
[0064] The specific implementation of steps 201 and 204 can be found in the detailed descriptions of other embodiments in this disclosure, and will not be repeated here.
[0065] Step 205: Convert the encrypted second identifier sequence, the length of the file segment, and the preset hardware identifier into the target format, respectively.
[0066] The target format can be TLV or other formats. This disclosure does not limit it.
[0067] TLV (Type-Length-Value) is a general-purpose format for data encoding and encapsulation. Its structure consists of three parts:
[0068] (1) Type: Indicates the type or identifier of the data. It is usually represented by one byte and defines the meaning of subsequent fields.
[0069] (2) Length: Indicates the length of the subsequent value field. The length can be fixed or variable. The size of the length field can use different numbers of bytes as needed.
[0070] (3) Value: Contains the actual data content. Its length is determined by the length field.
[0071] For example, the target format corresponding to the encrypted second identifier sequence can be F1+03E8+encrypted second identifier sequence. Here, F1 is the type, representing the second identifier sequence, and 03E8 is the length, representing the length of bytes occupied by the encrypted second identifier sequence.
[0072] For example, if the length of a file segment is 254, the target format corresponding to the length of the file segment can be F2+00 01+FE. Here, F2 is the type, indicating the length of the file segment, 00 01 is the length, indicating that the length of the file segment is 1 byte, and FE indicates that the length of the file segment is 254.
[0073] For example, if the preset hardware identifier is 01 02 03 04, the corresponding target format can be F3+04+0102 03 04. Here, F3 is the type, representing the preset hardware identifier, 04 is the length, indicating that the preset hardware identifier occupies a length of 4 bytes, and 01 02 03 04 represents the preset hardware identifier.
[0074] Step 206: The encrypted second identifier sequence of the target format, the length of the file segment of the target format, the preset hardware identifier of the target format, and the reconstructed file are reconstructed in sequence to obtain the encrypted file.
[0075] Optionally, the length of the first byte occupied by the encrypted second identifier sequence of the target format, the length of the second byte occupied by the file fragment of the target format, and the length of the third byte occupied by the preset hardware identifier of the target format can be determined first. Then, based on the length of the first byte, the length of the second byte, the length of the third byte, and the length of the fourth byte occupied by the file to be encrypted, the target total byte length corresponding to the encrypted file can be determined. Then, based on the target total byte length, an empty file is created. Finally, the encrypted second identifier sequence of the target format, the length of the file fragment of the target format, the preset hardware identifier of the target format, and the reconstructed file are added to the empty file in sequence to obtain the encrypted file.
[0076] For example, if the first byte is 1000 bytes long, the second byte is 4 bytes long, the third byte is 6 bytes long, and the fourth byte is 5000 bytes long, then the total target byte length is 6010 bytes. That is, the newly created empty file can store 6010 bytes of content.
[0077] In some embodiments, the filename corresponding to the new file can also be generated based on preset rules.
[0078] In this embodiment of the disclosure, after obtaining the encrypted second identifier sequence, the length of the file segment, and the preset hardware identifier, the encrypted second identifier sequence, the length of the file segment, and the preset hardware identifier can be converted into a target format respectively. Finally, the encrypted second identifier sequence in the target format, the length of the file segment in the target format, the preset hardware identifier in the target format, and the reconstructed file are sequentially reconstructed to obtain the encrypted file. Therefore, the content of each part of the encrypted file can be accurately determined, providing support for decryption.
[0079] Figure 3This is a schematic flowchart of a file encryption method provided in an embodiment of the present disclosure, as shown below. Figure 3 As shown, the file encryption method may include the following steps:
[0080] Step 301: Obtain the performance corresponding to the hardware.
[0081] Step 302: Determine the number of shards based on performance.
[0082] It's important to note that hardware performance refers to its processing power. Different processing powers result in different numbers of shards. The more powerful the hardware, the more shards it can handle.
[0083] Step 303: Based on the number of fragments, the file to be encrypted is evenly divided into fragments to obtain the number of file segments.
[0084] In this embodiment, the file to be encrypted can be evenly divided into segments, so that only the length corresponding to one file segment needs to be stored in the subsequent encrypted file. This saves storage space.
[0085] It should be noted that, since the encrypted file is being processed by uniformly dividing it into segments, the length of the last file segment may differ from the lengths of the other file segments.
[0086] Step 304: Generate a first identifier sequence based on the position of each file fragment in the file to be encrypted and its corresponding identifier. In the case where the length of the last file fragment among multiple file fragments is greater than 0 and not equal to the length of other file fragments, the last file fragment does not have a corresponding identifier.
[0087] In this embodiment of the disclosure, if the length of the last file segment among multiple file segments is greater than 0 but not equal to the length of the other file segments, the last file segment does not have a corresponding identifier. Therefore, when reassembling the file segments subsequently, the last file segment can be ignored, and only file segments of the same length can be reassembled.
[0088] Step 305: Based on the scrambled first identifier sequence, reassemble the corresponding file segments to obtain the reassembled file.
[0089] Step 306: Add the last file fragment to the end of the reconstructed file.
[0090] In this embodiment of the disclosure, since the last file fragment did not participate in the reconstructing, the reconstructed file generated in step 305 does not contain the last file fragment. Therefore, it is necessary to add the last file fragment to the end of the reconstructed file to avoid the reconstructed file losing the content of the file to be encrypted.
[0091] Step 307: Call the hardware corresponding to the preset hardware identifier to perform hardware encryption on the scrambled first identifier sequence to obtain the encrypted second identifier sequence.
[0092] Step 308: Determine the encrypted file corresponding to the file to be encrypted based on the encrypted second identifier sequence, the length of the file fragment, the preset hardware identifier, and the reconstructed file.
[0093] In this embodiment of the disclosure, when the length of the last file segment in a plurality of file segments is greater than 0 and not equal to the length of the other file segments, it is not necessary to configure a corresponding identifier for the last file segment. Thus, when reassembling the file segments to obtain the reassembled file, it is not necessary to consider the last file segment, but to add the last file segment to the end of the reassembled file. Therefore, only the length of one file segment needs to be stored in the encrypted file, which improves the speed of file encryption and reduces the storage content of the encrypted file.
[0094] To implement the above embodiments, this disclosure also proposes a file encryption device.
[0095] Figure 4 This is a schematic diagram of the structure of the file encryption device provided in the embodiments of this disclosure.
[0096] like Figure 4 As shown, the file encryption device 400 may include:
[0097] The first acquisition module 410 is used to perform fragmentation processing on the file to be encrypted in order to obtain multiple file fragments, wherein the file fragments have corresponding identifiers;
[0098] The generation module 420 is used to generate a first identifier sequence based on the position of each file fragment in the file to be encrypted and the corresponding identifier;
[0099] The second acquisition module 430 is used to reassemble the corresponding file segments based on the scrambled first identifier sequence in order to obtain the reassembled file.
[0100] The third acquisition module 440 is used to call the hardware corresponding to the preset hardware identifier to perform hardware encryption on the scrambled first identifier sequence in order to obtain the encrypted second identifier sequence.
[0101] The determination module 450 is used to determine the encrypted file corresponding to the file to be encrypted based on the encrypted second identifier sequence, the length of the file segment, the preset hardware identifier, and the reconstructed file.
[0102] Optionally, module 450 is defined, specifically for:
[0103] The encrypted second identifier sequence, the length of the file segment, and the preset hardware identifier are converted into the target format, respectively.
[0104] The encrypted second identifier sequence of the target format, the length of the file segment of the target format, the preset hardware identifier of the target format, and the reconstructed file are sequentially reconstructed to obtain the encrypted file.
[0105] Optionally, module 450 is defined, specifically for:
[0106] The length of the first byte occupied by the encrypted second identifier sequence of the target format, the length of the second byte occupied by the file fragment of the target format, and the length of the third byte occupied by the preset hardware identifier of the target format are determined.
[0107] Based on the length of the first byte, the length of the second byte, the length of the third byte, and the length of the fourth byte occupied by the file to be encrypted, determine the target total byte length of the encrypted file;
[0108] Create a new empty file based on the target total byte length;
[0109] The encrypted second identifier sequence of the target format, the length of the file segment of the target format, the preset hardware identifier of the target format, and the reconstructed file are added to the empty file in sequence to obtain the encrypted file.
[0110] Optionally, the first acquisition module 410 is specifically used for:
[0111] Obtain the performance corresponding to the hardware;
[0112] Determine the number of shards based on performance;
[0113] Based on the number of fragments, the file to be encrypted is evenly divided into fragments to obtain a number of file segments.
[0114] Optionally, if the length of the last file segment in the number of file segments is greater than 0 but not equal to the length of the other file segments, the last file segment does not have a corresponding identifier.
[0115] Optionally, it also includes adding modules for:
[0116] Add the last file fragment to the end of the reassembled file.
[0117] Optionally, a conversion module is also included for:
[0118] Convert the file to be encrypted into a bit array format.
[0119] Optionally, an inverting module is also included for:
[0120] Invert all the files in the reorganization file.
[0121] The functions and specific implementation principles of the modules described in this embodiment can be found in the above method embodiments, and will not be repeated here.
[0122] The file encryption device of this disclosure first segments the file to be encrypted into multiple file fragments, each fragment having a corresponding identifier. Then, based on the position of each file fragment within the file to be encrypted and its corresponding identifier, a first identifier sequence is generated. Next, based on the scrambled first identifier sequence, the corresponding file fragments are reassembled to obtain a reassembled file. Hardware corresponding to a preset hardware identifier is invoked to perform hardware encryption on the scrambled first identifier sequence to obtain an encrypted second identifier sequence. Finally, based on the encrypted second identifier sequence, the length of the file fragments, the preset hardware identifier, and the reassembled file, the corresponding encrypted file is determined. Thus, by scrambling and reassembling the file to be encrypted, and combining the hardware-encrypted scrambled first identifier sequence, the length of the file fragments, and the preset hardware identifier, an encrypted file is generated, thereby encrypting the file without relying on a key.
[0123] To implement the above embodiments, this disclosure also proposes an electronic device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, it implements the file encryption method proposed in the foregoing embodiments of this disclosure.
[0124] To implement the above embodiments, this disclosure also proposes a 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.
[0125] Figure 5 A block diagram of an exemplary electronic device suitable for implementing embodiments of the present disclosure is shown. Figure 5 The electronic device 12 shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments disclosed herein.
[0126] like Figure 5 As shown, the electronic device 12 is represented in the form of a general-purpose computing device. The components of the electronic device 12 may include, but are not limited to: one or more processors or processing units 16, system memory 28, and bus 18 connecting different system components (including system memory 28 and processing unit 16).
[0127] 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.
[0128] Electronic device 12 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by electronic device 12, including volatile and non-volatile media, removable and non-removable media.
[0129] 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. Electronic 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 5 Not shown; usually referred to as a "hard drive"). Although Figure 5 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.
[0130] A program / utility 40 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.
[0131] Electronic 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 electronic device 12, and / or with any device that enables electronic 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, electronic 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 electronic device 12 via bus 18. It should be understood that, although not shown in the figure, other hardware and / or software modules can be used in conjunction with electronic 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.
[0132] 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.
[0133] The technical solution disclosed herein first segments the file to be encrypted into multiple file fragments, each fragment having a corresponding identifier. Then, based on the position of each file fragment within the file to be encrypted and its corresponding identifier, a first identifier sequence is generated. Next, based on the scrambled first identifier sequence, the corresponding file fragments are reassembled to obtain a reassembled file. Hardware corresponding to a preset hardware identifier is invoked to perform hardware encryption on the scrambled first identifier sequence, resulting in an encrypted second identifier sequence. Finally, based on the encrypted second identifier sequence, the length of the file fragments, the preset hardware identifier, and the reassembled file, the corresponding encrypted file is determined. Thus, by scrambling and reassembling the file to be encrypted, and combining this with the hardware-encrypted scrambled first identifier sequence, the length of the file fragments, and the preset hardware identifier, an encrypted file is generated, thereby encrypting the file without relying on a key.
[0134] 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.
[0135] 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.
[0136] 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.
[0137] 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.
[0138] 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.
[0139] 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.
[0140] 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.
[0141] 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: The file to be encrypted is split into multiple file fragments, each of which has a corresponding identifier. A first identifier sequence is generated based on the position of each file fragment in the file to be encrypted and its corresponding identifier; Based on the scrambled first identifier sequence, the corresponding file segments are reassembled to obtain the reassembled file; The hardware corresponding to the preset hardware identifier is invoked to perform hardware encryption on the scrambled first identifier sequence to obtain the encrypted second identifier sequence. The encrypted second identifier sequence, the length of the file segment, and the preset hardware identifier are respectively converted into the target format; The length of the first byte occupied by the encrypted second identifier sequence of the target format, the length of the second byte occupied by the file segment of the target format, and the length of the third byte occupied by the preset hardware identifier of the target format are determined. Based on the length of the first byte, the length of the second byte, the length of the third byte, and the length of the fourth byte occupied by the file to be encrypted, determine the target total byte length of the encrypted file corresponding to the file to be encrypted; Create a new empty file based on the target total byte length; The encrypted second identifier sequence of the target format, the length of the file segment of the target format, the preset hardware identifier of the target format, and the reconstructed file are sequentially added to the empty file to obtain the encrypted file.
2. The method according to claim 1, characterized in that, The process of fragmenting the file to be encrypted to obtain multiple file segments includes: Obtain the performance corresponding to the hardware; Based on the performance described, determine the number of shards; Based on the number of fragments, the file to be encrypted is uniformly fragmented to obtain the number of file segments.
3. The method according to claim 2, characterized in that, If the length of the last file segment in the specified number of file segments is greater than 0 and not equal to the length of the other file segments, then the last file segment does not have a corresponding identifier.
4. The method according to claim 3, characterized in that, After reconstructing the corresponding file segments based on the scrambled first identifier sequence to obtain the reconstructed file, the process further includes: The last file fragment is added to the end of the reconstructed file.
5. The method according to any one of claims 1-4, characterized in that, Before performing the fragmentation process on the file to be encrypted to obtain multiple file segments, the method further includes: The file to be encrypted is converted into a bit array.
6. The method according to claim 5, characterized in that, Before determining the encrypted file corresponding to the file to be encrypted based on the encrypted second identifier sequence, the length of the file fragment, the preset hardware identifier, and the reconstructed file, the method further includes: Invert all of the recombined files.
7. A file encryption device, characterized in that, include: The first acquisition module is used to perform fragmentation processing on the file to be encrypted in order to obtain multiple file fragments, wherein each file fragment has a corresponding identifier; The generation module is used to generate a first identifier sequence based on the position of each file fragment in the file to be encrypted and its corresponding identifier; The second acquisition module is used to reassemble the corresponding file segments based on the scrambled first identifier sequence in order to obtain the reassembled file; The third acquisition module is used to call the hardware corresponding to the preset hardware identifier to perform hardware encryption on the scrambled first identifier sequence in order to obtain the encrypted second identifier sequence. The determining module is used to determine the encrypted file corresponding to the file to be encrypted based on the encrypted second identifier sequence, the length of the file fragment, the preset hardware identifier, and the reconstructed file; The determining module is specifically used for: The encrypted second identifier sequence, the length of the file segment, and the preset hardware identifier are respectively converted into the target format; The length of the first byte occupied by the encrypted second identifier sequence of the target format, the length of the second byte occupied by the file segment of the target format, and the length of the third byte occupied by the preset hardware identifier of the target format are determined. Based on the length of the first byte, the length of the second byte, the length of the third byte, and the length of the fourth byte occupied by the file to be encrypted, determine the target total byte length of the encrypted file corresponding to the file to be encrypted; Create a new empty file based on the target total byte length; The encrypted second identifier sequence of the target format, the length of the file segment of the target format, the preset hardware identifier of the target format, and the reconstructed file are sequentially added to the empty file to obtain the encrypted file.
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.
Citation Information
Patent Citations
File encryption method and device, file decryption method and device and storage medium
CN111814182A
System and method for improving encryption performance of hardware password equipment,
CN114036544A