A kind of big file transmission protecting based on fragment encryption
Technical field
The present invention is on Internet data transmission protection technique field, more particularly to a kind of big text based on fragment encryption
Part transmission protecting.
Background technology
Big file transmission protection is main to include two aspects, one be transmitting procedure protection, another be exactly when
Can not normal use after being downloaded by unknown people.For this two aspects, current big file transmission protection technique mainly has
Protection based on channel, such as the transmission of https agreements and the protection based on file, it is exactly that file is carried out completely to encrypt or add
It is transmitted after shell.But all there is the defects of obvious in two kinds of technologies.
Cipher mode based on channel guard, only protecting in document transmission process to be stolen, but is transferring
Just have no idea to ensure whether this document is used by unauthorized people into rear.In addition, this kind of mode is equivalent to all
The content being transmitted by the channel is all encrypted, so file transfer speed will necessarily be influenceed.
It is that the safety that can be effectively protected file is included in and the mode based on whole file encryption shell adding is protected
After transmission neutralization is transmitted, nor need to be transmitted by encryption channel.But because present file is increasing,
Particularly some files have been likely to be breached tens GB up to a hundred, to carry out full encryption to this file.One is when encrypting
Between can be very long, another is that get will be to that can use, so for user and content after file after file decryption
Being handled for publisher can all lose time very much.
The content of the invention
It is a primary object of the present invention to overcome deficiency of the prior art, there is provided a kind of big file based on fragment encryption
Transmit protection technique.In order to solve the above technical problems, the solution of the present invention is:
A kind of big file transmission protecting based on fragment encryption is provided, specifically includes following step:
Step (1):Fragment cryptographic operation is carried out before transmission, big file is protected, specifically includes following sub-steps:
Step A:The file size of big file is obtained, using byte as statistical unit;
Step B:According to the file size got in step A, to big file with certain fractionation unit (used here as
50,000,000 bytes are as fractionation unit) split, if last a remaining fragment not enough splits the size of unit,
It is then directly independent to turn into a fragment, obtain the fragment that big file declustering forms;
Step C:According to step B split result, the calculating of crumb position and chip length is carried out to split result, i.e., from
First part of fragment starts first to obtain a crumb position (from 0 to 48, obtaining a position in 000,000 byte at random), then
A value is taken at random as chip length in the range of 1% to the 2% of fractionation unit length;Obtaining step B split results successively
In all fragments crumb position and chip length;
Step D:According to step C result of calculation, the crumb data of extraction relevant position and length from big file, and
The big corresponding position of file uses and the isometric random data of crumb data is filled;
Step E:After all crumb datas extracted in step D are stitched together, it is encrypted and (is added using DES
Close algorithm), form fragment encrypted result;
Step F:The fragment encrypted result that step E is obtained, with step D obtain filled with random data after it is big
File, merge to form final destination file;
Step G:The final destination file that transmitting step F is obtained;
Step (2):Fragment decryption oprerations are carried out after being transmitted, use is decrypted to big file, specifically included following
Sub-step:
Step H:Get the encryption file transmitted;
Step I:The encryption file that step H is got is split, obtains fragment encrypted result and by with random data
Big file after filling;
Step J:To step I obtain fragment encrypted result be decrypted, obtain all fragments position and correlation it is broken
Sheet data;
Step K:According to step J obtain crumb data and position, after being filled to what is obtained in step I by random data
Big file carry out reduction treatment, the result of reduction is required original document.
In the present invention, the method spliced in the step E to crumb data, specifically includes following step:
Step a:By all crumb positions obtained in step D and corresponding information, spliced in pairs with position and information, in
Between with "::" be separated as separator, obtain the fragment pair that crumb position combines with corresponding patch information;Each fragment pair
As " crumb position::The fragment of patch information " is to character string;
Step b:By the fragment of all splicings obtained in step a completion to splicing, and with ":::" it is used as separator
It is separated, obtains fragment and (" crumb position is ultimately formed to combining characters string::Patch information:::Crumb position::Fragment
Information:::Crumb position::The result of patch information ", only schematically illustrate three fragments here to splicing, legitimate reading with it is specific
Fragment is relevant to quantity);
Step c:The step b fragments obtained are encrypted to combining characters string and (use des encryption algorithm), are formed
Fragment encrypted result.
In the present invention, in the step F, fragment encrypted result and the big file after being filled with random data are entered
The method that row merges, specifically includes following step:
Step d:The length of the fragment encrypted result formed in calculation procedure E;
Step e:The fragment encrypted result length obtained in step d is preserved with 64 bytes;
Step f:By the fragment encrypted result length information of step e 64 bytes generated, fragment encrypted result tail is spliced to
Portion forms fragment encrypted result complete information block;
Step g:The fragment encrypted result complete information block that step f is generated, is spliced to after being filled with random data
Big file afterbody, form final destination file.
In the present invention, in the step I, the method split to encryption file is specially:Interception encryption file is most
64 bytes afterwards, obtain the length of fragment encrypted result;The encryption file of last 64 bytes has been intercepted from step h
Afterbody intercepts fragment encrypted result, and it is after being filled with random data to have intercepted the remaining file after fragment encrypted result
Big file.
In the present invention, the step J realizes especially by following step:
Step h:Using with identical key is encrypted in step c, fragment encrypted result is decrypted, obtained
Decrypted result;
Step i:By decrypted result with it is therein ":::" be separated, obtain " crumb position::Patch information " structure
Fragment pair;
Step j:All fragments pair that step i is obtained, with it is therein "::" be separated, split out crumb position and broken
Piece information.
In the present invention, the step K realizes especially by following step:
Step k:According to the crumb position got in step J, looked in the big file after being filled with random data
To corresponding crumb position;
Step l:The crumb position found in step k, the corresponding patch information of the crumb position is filled into the position;
Step m:Repeat step k and step l, all crumb positions and patch information got in step J enter
The processing of row identical;
Step n:After completing step m, that is, original big file is restored.
Compared with prior art, the beneficial effects of the invention are as follows:
1st, the present invention has not only carried out encipherment protection compared with the guard method based on channel in transmitting procedure, and
And similarly have protecting effect after receiving file, just can normally it be used after only normal decryption;Simultaneously in transmitting procedure
In no longer need to encrypt, also significantly improve transmission performance.
2nd, the present invention with whole file encryption shell adding method compared with, the present invention before transmission encryption and, receive file
There is obvious reduction on the time in decryption processing afterwards, so can more efficiently be used, reduce the two mistakes
Time in journey wastes.
Brief description of the drawings
Fig. 1 is the preceding flow chart that fragment encryption is carried out to big file of transmission.
Fig. 2 is to receive the flow chart for carrying out fragment decryption after file to file.
Embodiment
Firstly the need of explanation, the present invention relates to big file to transmit protection technique, is computer technology in internet skill
A kind of application in art field.In the implementation process of the present invention, the application of multiple software function modules can be related to.Applicant recognizes
For such as after application documents, accurate understanding realization principle and goal of the invention of the invention is read over, with reference to existing known
In the case of technology, those skilled in the art can use the software programming technical ability of its grasp to realize the present invention, Fan Benfa completely
Category this category that bright application documents refer to, applicant will not enumerate.
The present invention is described in further detail with embodiment below in conjunction with the accompanying drawings:
A kind of big file transmission protecting based on fragment encryption, carry out fragment cryptographic operation before transmitting and big file is entered
Row protection, fragment decryption oprerations are carried out after being transmitted use is decrypted to big file.
It is specific as follows first as shown in figure 1, carrying out fragment encryption to file before transmission:
Step A:The file size of big file is obtained, using byte as statistical unit.
Step B:According to the file size got in step A, we are entered with 50,000,000 bytes as unit is split
Row length decile, if last a inadequate decile, directly independent to turn into portion.
Step C:According to step B split results, the calculating of crumb position and chip length is carried out to every a split result.
Crumb position is first obtained since first part, from 0 to 48, a position is obtained in 000,000 byte at random, is grown further according to unit
A random chip length in the range of 1% to the 2% of degree.Successively obtaining step B it is all split per a result all carry out with
On calculating obtain corresponding crumb position and chip length.
Step D:The crumb data of relevant position and length is extracted from big file according to C result of calculation, and in big text
The corresponding position of part is used and the isometric random data of crumb data is filled.
Step E:Result after the splicing together of all fragments obtained in step D is subjected to des encryption processing, formed broken
Piece encrypted result.
Wherein, patch information and the joining method of position, specifically include following step:
Step a:By all crumb positions obtained in step D and corresponding information, spliced in pairs with position and information, in
Between with "::" be separated as separator.Final each fragment is to forming " crumb position::The fragment of patch information " is to character
String.The fragment is to for crumb position combines with corresponding patch information.
Step b:By the fragment of all splicings obtained in step a completion to splicing, and with ":::" it is used as separator
It is separated.Ultimately form " crumb position::Patch information:::Crumb position::Patch information:::Crumb position::Fragment is believed
The result of breath ", only lists three, legitimate reading is relevant to quantity with specific fragment here.
Step c:Des encryption is carried out to combining characters string to the fragment in step b, forms fragment encrypted result.
Step F:The fragment encrypted result that step D processing obtains and the big file after being filled with random data are carried out
Merging forms final destination file.It is described filled with random data after big file be will be corresponding broken by step D
The patch information of piece position replaced by random data after big file.
Wherein, fragment encrypted result and the big file after being filled with random data are merged, specifically included down
State step:
Step d:Calculate the length by the step E fragment encrypted results formed.
Step e:The fragment encrypted result length obtained in step d is preserved with 64 bytes.
Step f:The fragment encrypted result length information of step e 64 bytes generated is spliced to fragment encrypted result afterbody
Form fragment encrypted result complete information block.
Step g:The fragment encrypted result complete information block that step f is generated is spliced to after being filled with random data
The afterbody of big file, forms final destination file.
Step G:It is transmitted using the step F files treated.
Then it is specific as follows as shown in Fig. 2 carrying out fragment decryption after file is received:
Step H:Get the encryption file transmitted.
Step I:The encryption file that step H is got is split, fragment encrypted result is obtained and is filled out by random data
Big file after filling.It is implemented as follows:
Step h:The file got from step H intercepts 64 last bytes.
Step i:64 bytes got according to step h, obtain fragment encrypted result length.
Step j:According to the fragment encrypted result length obtained in step i, last 64 has been intercepted from step h
The afterbody interception fragment encrypted result of the file of byte.
Step k:It is the big text after being filled by random data that the file after fragment encrypted result has been intercepted by step j
Part.
Step J:The fragment encrypted result obtained in step I is decrypted, obtain all fragments position and correlation
Crumb data.It is implemented as follows:
Step l:The use of fragment encrypted result is decrypted with carrying out des encryption identical key in step c.
Step m:By step l decrypted result with ":::" be separated, form " crumb position::Patch information " structure
Fragment pair.
Step n:By step m all fragments pair, then with "::" be separated and split out crumb position and patch information.
Step K:According to step J obtain crumb data and position, after being filled to what is obtained in step I by random data
Big file carry out reduction treatment.It is implemented as follows:
Step o:According to the crumb position got in step J, the big file after being filled by random data finds phase
The crumb position answered.
Step p:Corresponding patch information is filled into the position by the crumb position found in step o.
Step q:Repeat step o and step p carries out identical to all crumb positions and patch information that are got in step J
Processing.
Step r:Original big file will be restored after completing step q.
Step L:The result of step K reduction is just final original document.
Finally it should be noted that listed above is only specific embodiment of the invention.It is clear that the invention is not restricted to
Above example, there can also be many variations.One of ordinary skill in the art can directly lead from present disclosure
All deformations for going out or associating, are considered as protection scope of the present invention.