File fragment storage method, fragment file recombination method, device and file protection system
1. A file fragment storage method is characterized by comprising the following steps:
acquiring files to be fragmented and the number of fragments; the file to be fragmented comprises a plurality of bytes;
setting a plurality of fragment files according to the fragment number;
and according to the random number corresponding to each byte, putting each byte into the fragment file corresponding to the random number for storage.
2. The method for storing file slices according to claim 1, further comprising:
and acquiring a random number corresponding to each byte from a pre-acquired random number sequence according to the position of each byte in the file to be fragmented.
3. The method for storing file slices according to claim 1, further comprising:
and determining the fragment file corresponding to the random number according to the random number and the number of the fragments.
4. A fragmented file reorganization method is characterized by comprising the following steps:
acquiring a random number sequence and a plurality of fragment files; the random number sequence comprises a plurality of random numbers, and each fragment file comprises at least one byte;
creating a recombined file;
and sequentially extracting bytes corresponding to the random numbers from each fragment file according to the random number sequence, and sequentially placing the bytes into the recombined file.
5. The fragmented file reassembly method of claim 4, further comprising:
determining the fragment files corresponding to the random numbers according to the random numbers and the number of the fragment files;
and determining bytes corresponding to the random numbers according to the positions of the random numbers in the random number sequence and the fragment files corresponding to the random numbers.
6. A file shard storage device, comprising:
the fragment acquisition module is used for acquiring files to be fragmented and the number of fragments; the file to be fragmented comprises a plurality of bytes;
the fragment file setting module is used for setting a plurality of fragment files according to the number of the fragments;
and the storage module is used for storing each byte in the fragment file corresponding to the random number according to the random number corresponding to each byte.
7. The file shard storage device of claim 6, further comprising:
and the random number acquisition module is used for acquiring the random number corresponding to each byte from the pre-acquired random number sequence according to the position of each byte in the file to be fragmented.
8. The file shard storage device of claim 6, further comprising:
and the fragment file determining module is used for determining the fragment file corresponding to the random number according to the random number and the number of the fragments.
9. A fragmented file reorganization apparatus, comprising:
the acquisition module is used for acquiring a random number sequence and a plurality of fragment files; the random number sequence comprises a plurality of random numbers, and each fragment file comprises at least one byte;
the recombined file creating module is used for creating a recombined file;
and the extraction module is used for sequentially extracting bytes corresponding to the random numbers from the fragment files according to the random number sequence and sequentially placing the bytes into the recombined file.
10. The sliced file reassembling device according to claim 9, further comprising:
the fragment file module is used for determining fragment files corresponding to the random numbers according to the random numbers and the number of the fragment files;
and the byte determining module is used for determining the bytes corresponding to the random numbers according to the positions of the random numbers in the random number sequence and the fragment files corresponding to the random numbers.
11. A file protection system, comprising:
the file fragmentation storage device of any of claims 6 to 8;
the fragmented file reassembly device of any of claims 9 to 10.
Background
The distributed storage system stores the file content in a slice form, and the file content can be recovered according to different slices under the condition that the structure of the file system is clear. The same slice is segmented according to the file sequence, so that information leakage can occur after the slice content is acquired.
At present, the method for solving the problem of the leakage of the slicing content is to adopt algorithms such as DES, SM4, SM2 or RSA and the like to prevent the slicing file from being stolen, tampered and repudiated in an encryption and signature mode, but once an encryption system is cracked, the above safety measures are similar to the nominal ones: the traditional encryption system is based on prime number operation, and an attacker can decode in time by adopting a quantum computer.
Disclosure of Invention
The embodiments of the present invention mainly aim to provide a file fragment storage method, a fragment file reassembly device, and a file protection system, so as to safely protect files and prevent the files from being maliciously stolen and then decoded.
In order to achieve the above object, an embodiment of the present invention provides a file fragment storage method, including:
acquiring files to be fragmented and the number of fragments; the file to be fragmented comprises a plurality of bytes;
setting a plurality of fragment files according to the number of fragments;
and according to the random number corresponding to each byte, putting each byte into the fragment file corresponding to the random number for storage.
An embodiment of the present invention further provides a file fragment storage device, including:
the fragment acquisition module is used for acquiring files to be fragmented and the number of fragments; the file to be fragmented comprises a plurality of bytes;
the fragment file setting module is used for setting a plurality of fragment files according to the number of fragments;
and the storage module is used for storing each byte in the fragment file corresponding to the random number according to the random number corresponding to each byte.
The file fragment storage method and the device provided by the embodiment of the invention set a plurality of fragment files according to the number of fragments, and store each byte in the fragment file corresponding to the random number according to the random number corresponding to each byte of the file to be fragmented, so that the file can be safely protected, and the file can be prevented from being maliciously stolen and then decoded.
The embodiment of the invention also provides a fragmented file recombination method, which comprises the following steps:
acquiring a random number sequence and a plurality of fragment files; the random number sequence comprises a plurality of random numbers, and each fragment file comprises at least one byte;
creating a recombined file;
and sequentially extracting bytes corresponding to the random numbers from each fragment file according to the random number sequence, and sequentially putting the bytes into the recombined file.
An embodiment of the present invention further provides a fragmented file reassembly device, including:
the acquisition module is used for acquiring a random number sequence and a plurality of fragment files; the random number sequence comprises a plurality of random numbers, and each fragment file comprises at least one byte;
the recombined file creating module is used for creating a recombined file;
an extraction module for sequentially extracting bytes corresponding to the random numbers from the fragment files according to the random number sequence and sequentially placing the bytes into the recombined file
The fragment file recombination method and the device of the embodiment of the invention sequentially extract the bytes corresponding to the random numbers from the fragment files according to the random number sequence, and sequentially put the bytes into the recombined files, so that the files can be safely protected, and the files can be prevented from being maliciously stolen and then decoded.
An embodiment of the present invention further provides a file protection system, including:
the file fragment storage device is described above;
the fragmented file reassembly device as described above.
The file protection system of the embodiment of the invention can safely protect the file and prevent the file from being maliciously stolen and then decoded.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art that other drawings can be obtained based on these drawings without creative efforts.
FIG. 1 is a flowchart of a file fragment storage method according to an embodiment of the present invention;
FIG. 2 is a diagram of file fragmentation in a first embodiment of the present invention;
FIG. 3 is a diagram illustrating document fragmentation and reassembly in a second embodiment of the present invention;
FIG. 4 is a flowchart of a fragmented file reassembly method according to an embodiment of the present invention;
FIG. 5 is a flowchart of a fragmented file reassembly method according to a first embodiment of the present invention;
FIG. 6 is a flow diagram of file modification in an embodiment of the present invention;
FIG. 7 is a block diagram of a file fragmentation storage device in an embodiment of the present invention;
FIG. 8 is a block diagram illustrating an exemplary embodiment of an apparatus for reorganizing fragmented files;
fig. 9 is a block diagram of the structure of the file protection system in the embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
As will be appreciated by one skilled in the art, embodiments of the present invention may be embodied as a system, apparatus, device, method, or computer program product. Accordingly, the present disclosure may be embodied in the form of: entirely hardware, entirely software (including firmware, resident software, micro-code, etc.), or a combination of hardware and software.
In view of the fact that the security measures are similar to those of the virtual file after the encryption system in the prior art is cracked, embodiments of the present invention provide a file fragment storage method, a fragment file reassembly device, and a file protection system, wherein file contents are randomly fragmented into N new files, semantic meanings of the file contents are disturbed, and then the files are respectively stored in a distributed storage medium. When an operator needs to operate a file, all the fragment files need to be read from the distributed storage medium, the fragment files are recombined into new files and then the file operation is carried out, and the operated files are written in the fragments again, so that the files can be safely protected, and the files are prevented from being maliciously stolen and then decoded. The present invention will be described in detail below with reference to the accompanying drawings.
Fig. 1 is a flowchart of a file fragment storage method according to an embodiment of the present invention. Fig. 2 is a schematic diagram of file fragmentation in the first embodiment of the present invention. FIG. 3 is a diagram illustrating document fragmentation and reassembly in a second embodiment of the present invention. As shown in fig. 1 to fig. 3, the file fragment storage method includes:
s101: acquiring files to be fragmented and the number of fragments; the file to be fragmented comprises a plurality of bytes.
In the first embodiment, as shown in fig. 2, a file F to be fragmented and a number N of fragments are obtained. N in fig. 2 is 4. The file F to be fragmented includes 8 bytes: ABCDEFGH.
In the second embodiment, as shown in fig. 3, a file to be fragmented (message file) M and the number of fragments N are obtained. N in fig. 2 is 4. The file M to be fragmented comprises 7 bytes: ABCDEFG.
S102: and setting a plurality of fragment files according to the number of the fragments.
In specific implementation, N fragmentation files may be set according to the number of N fragmentation.
In the first embodiment, if N in fig. 2 is 4, four shard files are set: f0, f1, f2 and f 3.
In the second embodiment, if N in fig. 3 is 4, four shard files are set: m0, m1, m2 and m 3.
S103: and according to the random number corresponding to each byte, putting each byte into the fragment file corresponding to the random number for storage.
Before executing S103, the method further includes: and acquiring the random number corresponding to each byte from the pre-acquired random number sequence according to the position of each byte in the file to be fragmented.
In specific implementation, the ith byte of the file F to be fragmented corresponds to the ith random number in the random number sequence, and the ith byte of the file M to be fragmented corresponds to the ith random number in the random number sequence.
In the first embodiment, as shown in fig. 2, the first random number in the random number sequence is 3, the second random number is 4, the third random number is 5, the fourth random number is 10, the fifth random number is 8, the sixth random number is 22, the seventh random number is 30, and the eighth random number is 5; then the first byte a of the file F to be fragmented corresponds to the first random number 3, the second byte B corresponds to the second random number 4, the third byte C corresponds to the third random number 5, the fourth byte D corresponds to the fourth random number 10, the fifth byte E corresponds to the fifth random number 8, the sixth byte F corresponds to the sixth random number 22, the seventh byte G corresponds to the seventh random number 30, and the eighth byte H corresponds to the eighth random number 5.
In the second embodiment, as shown in fig. 3, the first random number in the random number sequence is 10, the second random number is 5, the third random number is 3, the fourth random number is 7, the fifth random number is 8, the sixth random number is 0, the seventh random number is 1, the eighth random number is 9, and the ninth random number is 3; then the first byte a of the file M to be fragmented corresponds to the first random number 10, the second byte B corresponds to the second random number 5, the third byte C corresponds to the third random number 3, the fourth byte D corresponds to the fourth random number 7, the fifth byte E corresponds to the fifth random number 8, the sixth byte F corresponds to the sixth random number 0, and the seventh byte G corresponds to the seventh random number 1.
Before executing S103, the method further includes: and determining the fragment file corresponding to the random number according to the random number and the number of the fragments.
In specific implementation, the ith random number R [ i ] corresponds to the p ═ R [ i ]% N +1 sharded files, that is, the remainder obtained by dividing the ith random number by the sharded number N is p-1, and the ith random number corresponds to the pth sharded file.
Taking fig. 2 as an example, the first random number 3 corresponds to the fourth shard file f3, the second random number 4 corresponds to the first shard file f0, the third random number 5 corresponds to the second shard file f1, the fourth random number 10 corresponds to the third shard file f2, the fifth random number 8 corresponds to the first shard file f0, the sixth random number 22 corresponds to the third shard file f2, the seventh random number 30 corresponds to the third shard file f2, and the eighth random number 5 corresponds to the second shard file f 1.
Taking fig. 3 as an example, the first random number 10 corresponds to the third sharded file m2, the second random number 5 corresponds to the second sharded file m1, the third random number 3 corresponds to the fourth sharded file m3, the fourth random number 7 corresponds to the fourth sharded file m3, the fifth random number 8 corresponds to the first sharded file m0, the sixth random number 0 corresponds to the first sharded file m0, and the seventh random number 1 corresponds to the second sharded file m 1.
S103 specifically comprises the following steps: and putting each byte into the tail part of the fragment file corresponding to the random number according to the random number corresponding to each byte for storage, wherein the fragment files are positioned in different distributed storage media.
Taking fig. 2 as an example, according to the first random number 3 corresponding to the first byte a of the file F to be fragmented, a is placed into the tail of the fourth fragmentation file F3 corresponding to the first random number 3, B is placed into the tail of the first fragmentation file F0 corresponding to the second random number 4 according to the second random number 4 corresponding to the second byte B, C is placed into the tail of the second fragmentation file F1 corresponding to the third random number 5 according to the third random number 5 corresponding to the third byte C, D is placed into the tail of the third fragmentation file F2 corresponding to the fourth random number 10 according to the fourth random number 10 corresponding to the fourth byte D, E is placed into the tail of the first fragmentation file F0 corresponding to the fifth random number 8 according to the fifth random number 8 corresponding to the fifth byte E, F is placed into the tail of the third fragmentation file F2 corresponding to the sixth random number 22 according to the sixth random number 22 corresponding to the sixth byte F, g is placed at the end of the third sharded file f2 corresponding to the seventh random number 30 according to the seventh random number 30 corresponding to the seventh byte G, and H is placed at the end of the second sharded file f1 corresponding to the eighth random number 5 according to the eighth random number 5 corresponding to the eighth byte H.
Therefore, the first sliced file f0 stores bytes BE, the second sliced file f1 stores bytes CH, the third sliced file f2 stores bytes DFG, and the fourth sliced file f3 stores bytes a.
Taking fig. 3 as an example, according to the first random number 10 corresponding to the first byte a of the file M to be fragmented, a is placed into the tail of the third fragmented file M2 corresponding to the first random number 10, B is placed into the tail of the second fragmented file M1 corresponding to the second random number 5 according to the second random number 5 corresponding to the second byte B, C is placed into the tail of the fourth fragmented file M3 corresponding to the third random number 3 according to the third byte C, D is placed into the tail of the fourth fragmented file M3 corresponding to the fourth random number 7 according to the fourth random number 7 corresponding to the fourth byte D, E is placed into the tail of the first fragmented file M0 corresponding to the fifth random number 8 according to the fifth byte E, F is placed into the fragment of the first fragmented file M0 corresponding to the sixth random number 0 according to the sixth random number 0 corresponding to the sixth byte F, g is placed at the tail of the second sliced file m1 corresponding to the seventh random number 1 according to the seventh random number 1 corresponding to the seventh byte G.
Therefore, the byte stored in the first fragmented file m0 is EF, the byte stored in the second fragmented file m1 is BG, the byte stored in the third fragmented file m2 is a, and the byte stored in the fourth fragmented file m3 is CD.
In the first embodiment, after executing S103, the method further includes: and sending each fragment file to the distributed storage medium, and generating a local temporary storage file to store the storage address of the distributed storage medium where each fragment file is located.
As shown in fig. 3, in the second embodiment, after executing S103, the method further includes: and randomly selecting each transmission link corresponding to each fragmented file, and transmitting each fragmented file to the receiving end through the corresponding transmission link. For each fragmented file, one link L ═ random% | L | can be randomly selected from L transmission links for transmission. For example, the first fragmented file m0 and the fourth fragmented file m3 are transmitted to the distributed storage medium at the receiving end through the last link for storage, the second fragmented file m1 is transmitted to the distributed storage medium at the receiving end through the first link for storage, and the third fragmented file m2 is transmitted to the distributed storage medium at the receiving end through the second link for storage. The structure of the transmitted fragment file is { Msg _ ID + fragment file content }, and Msg _ ID is the ID of the file to be fragmented.
The execution main body of the file fragment storage method shown in fig. 1 may be the sending end. As can be seen from the process shown in fig. 1, the file fragment storage method according to the embodiment of the present invention sets a plurality of fragment files according to the number of fragments, and stores each byte in the fragment file corresponding to the random number according to the random number corresponding to each byte of the file to be fragmented, so that the file can be safely protected, and the file can be prevented from being maliciously stolen and then decoded.
Fig. 4 is a flowchart of a fragmented file reassembly method in an embodiment of the present invention. Fig. 5 is a flowchart of a fragmented file reassembly method in a first embodiment of the present invention. As shown in fig. 4-5, the fragmented file reassembly method includes:
s201: acquiring a random number sequence and a plurality of fragment files; the random number sequence comprises a plurality of random numbers, and each fragment file comprises a plurality of bytes.
In the first embodiment, the local temporary storage file is read to obtain the storage address of the fragmented file, and then the fragmented files f0, f1, f2, and f3 are read from the respective distributed media according to the storage address of the fragmented file. The first sliced file f0 includes byte BE, the second sliced file f1 includes byte CH, the third sliced file f2 includes byte DFG, and the fourth sliced file f3 includes byte a. The random number sequence defined by the file fragmentation storage device and the fragmentation file reorganization device in advance synchronously is [3,4,5,10,8,22,30, 5.
In the second embodiment, a plurality of sliced files m0, m1, m2 and m3 from each transmission link are acquired. The first sliced file m0 includes byte EF, the second sliced file m1 includes byte BG, the third sliced file m2 includes byte a, and the fourth sliced file m3 includes byte CD. The random number sequence defined by the sending end and the receiving end synchronously in advance is [10,5,3,7,8,0,1,9, 3.
S202: a reorganization file is created.
In the first embodiment, let the regrouped file be F'.
In the second embodiment, let the reassembly file (message file) be M'.
S203: and sequentially extracting bytes corresponding to the random numbers from each fragment file according to the random number sequence, and sequentially putting the bytes into the recombined file.
Before executing S203, the method further includes: and determining the fragment files corresponding to the random numbers according to the random numbers and the number of the fragment files.
In specific implementation, the ith random number R [ i ] corresponds to the p ═ R [ i ]% N +1 sharded files, that is, the remainder obtained by dividing the ith random number by the sharded number N is p-1, and the ith random number corresponds to the p-th sharded file.
In the first embodiment, as shown in fig. 2, the first random number 3 corresponds to the fourth shard file f3, the second random number 4 corresponds to the first shard file f0, the third random number 5 corresponds to the second shard file f1, the fourth random number 10 corresponds to the third shard file f2, the fifth random number 8 corresponds to the first shard file f0, the sixth random number 22 corresponds to the third shard file f2, the seventh random number 30 corresponds to the third shard file f2, and the eighth random number 5 corresponds to the second shard file f 1.
In the second embodiment, as shown in fig. 3, the first random number 10 corresponds to the third sharded file m2, the second random number 5 corresponds to the second sharded file m1, the third random number 3 corresponds to the fourth sharded file m3, the fourth random number 7 corresponds to the fourth sharded file m3, the fifth random number 8 corresponds to the first sharded file m0, the sixth random number 0 corresponds to the first sharded file m0, and the seventh random number 1 corresponds to the second sharded file m 1.
Before executing S203, the method further includes: and determining bytes corresponding to the random numbers according to the positions of the random numbers in the random number sequence and the fragment files corresponding to the random numbers.
In the first embodiment, as shown in fig. 2, the first random number 3 corresponds to the fourth sharded file f3, and then the first random number 3 corresponds to the first byte a in the fourth sharded file f 3; the second random number 4 corresponds to the first sharded file f0, and the second random number 4 corresponds to the first byte B in the first sharded file f 0; the third random number 5 corresponds to the second sharded file f1, and the third random number 5 corresponds to the first byte C in the second sharded file f 1; the fourth random number 10 corresponds to the third sharded file f2, and the fourth random number 10 corresponds to the first byte D in the third sharded file f 2; the fifth random number 8 corresponds to the first sharded file f0, since the second random number 4 has been corresponded to the first byte B in the first sharded file f0 previously, the fifth random number 8 corresponds to the second byte E in the first sharded file f 0; the sixth random number 22 corresponds to the third sharded file F2, since the fourth random number 10 has been previously corresponding to the first byte D in the third sharded file F2, the sixth random number 22 corresponds to the second byte F in the third sharded file F2; the seventh random number 30 corresponds to the third sharded file F2, since the fourth random number 10 has previously corresponded to the first byte D in the third sharded file F2, the sixth random number 22 has corresponded to the second byte F in the third sharded file F2, and the seventh random number 30 corresponds to the third byte G in the third sharded file F2; the eighth random number 5 corresponds to the second sharded file f1, and since the third random number 5 has previously corresponded to the first byte C in the second sharded file f1, the eighth random number 5 corresponds to the second byte H in the second sharded file f 1.
In the second embodiment, as shown in fig. 3, the first random number 10 corresponds to the third sharded file m2, and then the first random number 10 corresponds to the first byte a in the third sharded file m 2; the second random number 5 corresponds to the second sharded file m1, and the second random number 5 corresponds to the first byte B in the second sharded file m 1; the third random number 3 corresponds to the fourth sharded file m3, and the third random number 3 corresponds to the first byte C in the fourth sharded file m 3; the fourth random number 7 corresponds to the fourth sharded file m3, since the third random number 3 has been previously corresponding to the first byte C in the fourth sharded file m3, the fourth random number 7 corresponds to the second byte D in the fourth sharded file m 3; the fifth random number 8 corresponds to the first sharded file m0, and the fifth random number 8 corresponds to the first byte E in the first sharded file m 0; the sixth random number 0 corresponds to the first sharded file m0, since the fifth random number 8 corresponds to the first byte E in the first sharded file m0 previously, the sixth random number 0 corresponds to the second byte F in the first sharded file m 0; the seventh random number 1 corresponds to the second sharded file m1, and since the second random number 5 has previously corresponded to the first byte B in the second sharded file m1, the seventh random number 1 corresponds to the second byte G in the second sharded file m 1.
S203 specifically includes: and sequentially extracting bytes corresponding to the random numbers from the fragment files according to the random number sequence, and sequentially putting the bytes into the head of the recombined file for storage to generate the recombined file.
In the first embodiment, as shown in fig. 2, the first random number 3 corresponds to the first byte a in the fourth sliced file F3, the second random number 4 corresponds to the first byte B in the first sliced file F0, the third random number 5 corresponds to the first byte C in the second sliced file F1, the fourth random number 10 corresponds to the first byte D in the third sliced file F2, the fifth random number 8 corresponds to the second byte E in the first sliced file F0, the sixth random number 22 corresponds to the second byte F in the third sliced file F2, the seventh random number 30 corresponds to the third byte G in the third sliced file F2, the eighth random number 5 corresponds to the second byte H in the second sliced file F1, A, B, C, D, E, F, G and H are sequentially put into the header of the file F' in the order of random numbers in the random number sequence, the reconstructed file content is ABCDEFGH.
In the second embodiment, as shown in fig. 3, a first random number 10 corresponds to a first byte a in the third sliced file M2, a second random number 5 corresponds to a first byte B in the second sliced file M1, a third random number 3 corresponds to a first byte C in the fourth sliced file M3, a fourth random number 7 corresponds to a second byte D in the fourth sliced file M3, a fifth random number 8 corresponds to a first byte E in the first sliced file M0, a sixth random number 0 corresponds to a second byte F in the first sliced file M0, and a seventh random number 1 corresponds to a second byte G in the second sliced file M1, then A, B, C, D, E, F and G are sequentially placed into the header of the reconstructed file M' according to the arrangement order of the random numbers in the random number sequence, and the reconstructed file content is efabcdg.
The execution subject of the fragmented file reassembly method shown in fig. 4 may be a distributed storage medium located at the receiving end. As can be seen from the flow shown in fig. 4, the fragment file reassembly method according to the embodiment of the present invention sequentially extracts bytes corresponding to each random number from each fragment file according to the random number sequence, and sequentially puts the bytes into the reassembly file, so as to safely protect the file and prevent the file from being maliciously stolen and then decoded.
FIG. 6 is a flow chart of file modification in an embodiment of the present invention. As shown in fig. 6, before performing operations such as file reading, rewriting (modifying), or searching, the fragmented file is loaded into the memory and a copy of the fragmented file is recorded in the local storage. When the file is modified, the file is firstly recombined according to a file recombination method, then the content of the recombined file is modified, then the original fragmented file written in the distributed storage medium is deleted, the modified file is fragmented again according to a file fragmentation storage method and then written in the distributed storage medium, and finally the fragmented file copy in the local storage is deleted.
Based on the same inventive concept, the embodiment of the invention also provides a file fragment storage device, and as the principle of solving the problems of the device is similar to the file fragment storage method, the implementation of the device can refer to the implementation of the method, and repeated parts are not described again.
Fig. 7 is a block diagram of a structure of a file fragmentation storage device in an embodiment of the present invention. As shown in fig. 7, the file fragment storage device includes:
the fragment acquisition module is used for acquiring files to be fragmented and the number of fragments; the file to be fragmented comprises a plurality of bytes;
the fragment file setting module is used for setting a plurality of fragment files according to the number of fragments;
and the storage module is used for storing each byte in the fragment file corresponding to the random number according to the random number corresponding to each byte.
In one embodiment, the method further comprises the following steps:
and the random number acquisition module is used for acquiring the random number corresponding to each byte from the pre-acquired random number sequence according to the position of each byte in the file to be fragmented.
In one embodiment, the method further comprises the following steps:
and the fragment file determining module is used for determining the fragment file corresponding to the random number according to the random number and the number of the fragments.
In summary, the file fragment storage device according to the embodiment of the present invention sets a plurality of fragment files according to the number of fragments, and stores each byte in the fragment file corresponding to the random number according to the random number corresponding to each byte of the file to be fragmented, so as to safely protect the file and prevent the file from being maliciously stolen and then decoded.
Fig. 8 is a block diagram of a fragmented file reorganization apparatus according to an embodiment of the present invention. As shown in fig. 8, the fragmented file reassembly device includes:
the acquisition module is used for acquiring a random number sequence and a plurality of fragment files; the random number sequence comprises a plurality of random numbers, and each fragment file comprises at least one byte;
the recombined file creating module is used for creating a recombined file;
and the extraction module is used for sequentially extracting bytes corresponding to the random numbers from the fragment files according to the random number sequence and sequentially putting the bytes into the recombined file.
In one embodiment, the method further comprises the following steps:
the fragment file module is used for determining fragment files corresponding to the random numbers according to the random numbers and the number of the fragment files;
and the byte determining module is used for determining the bytes corresponding to the random numbers according to the positions of the random numbers in the random number sequence and the fragment files corresponding to the random numbers.
In summary, the fragmented file reassembly device according to the embodiment of the present invention sequentially extracts bytes corresponding to each random number from each fragmented file according to the random number sequence, and sequentially puts the bytes into the reassembled file, so that the file can be safely protected, and the file can be prevented from being maliciously stolen and then decoded.
Based on the same inventive concept, the embodiment of the invention also provides a file protection system. Fig. 9 is a block diagram of the structure of the file protection system in the embodiment of the present invention. As shown in fig. 9, the file protection system includes:
the file fragment storage device is described above;
the fragmented file reassembly device as described above.
The specific process of the file protection system of the embodiment of the invention is as follows:
1. and acquiring the file to be fragmented and the number of fragments, wherein the file to be fragmented comprises a plurality of bytes.
2. And setting a plurality of fragment files according to the number of the fragments.
3. And acquiring the random number corresponding to each byte from the pre-acquired random number sequence according to the position of each byte in the file to be fragmented.
4. And determining the fragment file corresponding to the random number according to the random number and the number of the fragments.
5. And putting each byte into the tail part of the fragment file corresponding to the random number according to the random number corresponding to each byte for storage, wherein the fragment files are positioned in different distributed storage media.
6. Acquiring a random number sequence and a plurality of fragment files; the random number sequence comprises a plurality of random numbers, and each fragmented file comprises a plurality of bytes.
7. A reorganization file is created.
8. And determining the fragment files corresponding to the random numbers according to the random numbers and the number of the fragment files.
9. And determining bytes corresponding to the random numbers according to the positions of the random numbers in the random number sequence and the fragment files corresponding to the random numbers.
10. And sequentially extracting bytes corresponding to the random numbers from the fragment files according to the random number sequence, and sequentially putting the bytes into the head of the recombined file for storage to generate the recombined file.
In summary, the file protection system provided by the embodiment of the present invention employs a distributed randomized fragmentation message storage manner, which can break up message semantics in a distributed medium, reduce the risk of deciphering, and solve the content security problem caused by medium leakage during distributed storage. Even if part of the medium leaks, the content of the medium can still be protected.
The above-mentioned embodiments are intended to illustrate the objects, technical solutions and advantages of the present invention in further detail, and it should be understood that the above-mentioned embodiments are only exemplary embodiments of the present invention, and are not intended to limit the scope of the present invention, and any modifications, equivalent substitutions, improvements and the like made within the spirit and principle of the present invention should be included in the scope of the present invention.
Those of skill in the art will further appreciate that the various illustrative logical blocks, units, and steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both. To clearly illustrate the interchangeability of hardware and software, various illustrative components, elements, and steps have been described above generally in terms of their functionality. Whether such functionality is implemented as hardware or software depends upon the particular application and design requirements of the overall system. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present embodiments.
The various illustrative logical blocks, or elements, or devices described in connection with the embodiments disclosed herein may be implemented or performed with a general purpose processor, a digital signal processor, an Application Specific Integrated Circuit (ASIC), a field programmable gate array or other programmable logic device, discrete gate or transistor logic, discrete hardware components, or any combination thereof designed to perform the functions described herein. A general-purpose processor may be a microprocessor, but in the alternative, the processor may be any conventional processor, controller, microcontroller, or state machine. A processor may also be implemented as a combination of computing devices, e.g., a digital signal processor and a microprocessor, a plurality of microprocessors, one or more microprocessors in conjunction with a digital signal processor core, or any other similar configuration.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module may be stored in RAM memory, flash memory, ROM memory, EPROM memory, EEPROM memory, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art. For example, a storage medium may be coupled to the processor such the processor can read information from, and write information to, the storage medium. In the alternative, the storage medium may be integral to the processor. The processor and the storage medium may reside in an ASIC, which may be located in a user terminal. In the alternative, the processor and the storage medium may reside in different components in a user terminal.
In one or more exemplary designs, the functions described above in connection with the embodiments of the invention may be implemented in hardware, software, firmware, or any combination of the three. If implemented in software, the functions may be stored on or transmitted over as one or more instructions or code on a computer-readable medium. Computer-readable media includes both computer storage media and communication media that facilitate transfer of a computer program from one place to another. Storage media may be any available media that can be accessed by a general purpose or special purpose computer. For example, such computer-readable media can include, but is not limited to, RAM, ROM, EEPROM, CD-ROM or other optical disk storage, magnetic disk storage or other magnetic storage devices, or any other medium which can be used to carry or store program code in the form of instructions or data structures and which can be read by a general-purpose or special-purpose computer, or a general-purpose or special-purpose processor. Additionally, any connection is properly termed a computer-readable medium, and, thus, is included if the software is transmitted from a website, server, or other remote source via a coaxial cable, fiber optic cable, twisted pair, Digital Subscriber Line (DSL), or wirelessly, e.g., infrared, radio, and microwave. Such discs (disk) and disks (disc) include compact disks, laser disks, optical disks, DVDs, floppy disks and blu-ray disks where disks usually reproduce data magnetically, while disks usually reproduce data optically with lasers. Combinations of the above may also be included in the computer-readable medium.