CN110489978A - A kind of file encryption-decryption method - Google Patents
A kind of file encryption-decryption method Download PDFInfo
- Publication number
- CN110489978A CN110489978A CN201910615408.2A CN201910615408A CN110489978A CN 110489978 A CN110489978 A CN 110489978A CN 201910615408 A CN201910615408 A CN 201910615408A CN 110489978 A CN110489978 A CN 110489978A
- Authority
- CN
- China
- Prior art keywords
- file
- fragment
- encryption
- decryption
- current
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F21/00—Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
- G06F21/60—Protecting data
- G06F21/602—Providing cryptographic facilities or services
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Health & Medical Sciences (AREA)
- Bioethics (AREA)
- General Health & Medical Sciences (AREA)
- Computer Hardware Design (AREA)
- Computer Security & Cryptography (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Storage Device Security (AREA)
Abstract
The present invention provides a kind of file encryption-decryption method, file encrypting method includes reading file to be encrypted, and a segment file is randomly selected from sample file as current file, file to be encrypted and current file exclusive or are handled, intermediate file is obtained;The sequence of fragment in intermediate file is upset, current intermediate file is obtained;Xor operation is carried out to the fragment of current intermediate file, obtains preliminary intermediate file;Encryption file is obtained according to the interative computation of preliminary encryption file;Key file is generated, encryption key is obtained.File decryption method includes the encryption file read in key, using encryption file as current decryption file;To current decryption file decryption, clear text file is obtained;Using clear text file as current decryption file, obtain tentatively decrypting file;File will tentatively be decrypted and sample file exclusive or is handled, obtain decryption file;Encryption file is decrypted.The present invention realizes " the individual character encryption " of each file, reaches the cipher round results of " one-time pad ".
Description
Technical field
The present invention relates to data encryption technology fields, and in particular to a kind of file encryption-decryption method.
Background technique
Present information encryption technology is generally used the basic thought of " algorithm+key ".No matter symmetric encipherment algorithm or
Rivest, shamir, adelman, once algorithm is selected, the intensity of information encryption just relies primarily on the intensity of " key ".As computer is transported
The continuous promotion of speed, continuing to bring out for various new and effective decoding tools are calculated, this encryption for cracking " algorithm+key " is calculated
Method has existed possibility, steals confidential information and becomes increasingly easy, and conventional encryption algorithm is facing the threat being cracked.
Summary of the invention
For the deficiencies in the prior art, the object of the present invention is to provide a kind of file encryption-decryption methods, solve
Existing encryption and decryption document method is easy the technical issues of being cracked.
In order to solve the above-mentioned technical problem, the application, which adopts the following technical scheme that, is achieved:
A kind of file encrypting method, comprising the following steps:
Step 1, file to be encrypted is read, the file size to be encrypted is L;Length is randomly selected from sample file is
A segment file of L carries out xor operation as current file, by file to be encrypted and current file, obtains intermediate file, wherein L
More than or equal to 1, unit is byte;
Step 2, n fragment length is generated at random, and intermediate file is divided by n fragment according to fragment length;
Step 3, the sequence of n fragment in intermediate file is upset, obtains current intermediate file;
Step 4, xor operation is carried out to n fragment of current intermediate file, obtains preliminary intermediate file;
Include:
Step 41, enabling i=1, i is the encryption cycle factor;
Step 42, i-th of fragment piece in n fragment of new sequences arrangement is subjected to xor operation with i+1 fragment,
Obtain the i-th ' a fragment;
Step 43, i=i+1 repeats step 42, until i=n-1, obtains the 1st ' a fragment ..., and (n-1) ' a point
Piece;
Step 44, a fragment is randomly selected from current intermediate file as current slice, it will be in current intermediate file
N-th fragment and current slice carry out xor operation, obtain the n-th ' a fragment;
By the 1st ' a fragment ..., (n-1) ' a fragment, the n-th ' a fragment is as preliminary encryption file;
Step 5, file will be tentatively encrypted as current intermediate file, repeats step 3 to step 4p times, obtain encryption text
Part, p are the natural number greater than 1, include the n fragment arranged in sequence in the encryption file;
Step 6, according to encryption file, key file is generated, key file and sample file are subjected to xor operation, obtained
Encryption key.
The present invention also provides a kind of file decryption methods, comprising the following steps:
Step 1, the encryption file in key is read, the encryption file includes m fragment, using encryption file as current
Decrypt file;
Step 2, m fragment in current decryption file is decrypted, obtains clear text file;
Include:
Step 21, a segment file is obtained at random from sample file as current decryption fragment, it will be in current decryption file
M-th fragment and current decryption fragment carry out xor operation, obtain a fragment of m ' of clear text file;
Step 22, enabling j=m-1, j is the decryption rounds factor;
Step 23, j-th of fragment in current decryption file and (j+1) ' a fragment of clear text file are subjected to exclusive or
Operation, obtains jth ' a fragment of clear text file;
Step 24, step 23 is repeated, until j=1, obtains clear text file, the clear text file includes the 1st ' a point
Piece ..., (m-1) ' a fragment, a fragment of m ';
Step 3, it using clear text file as current decryption file, repeats step 2q times, obtains tentatively decrypting file;
Step 4, it will tentatively decrypt file and sample file carries out xor operation, and obtain decryption file;
Step 5, encryption file is decrypted using decryption file.
It further,, will encryption if the number that encryption file is decrypted in decryption file is greater than H in the step 5
File is destroyed, and H is the natural number greater than 1.
Further, the encryption file is destroyed, comprising:
Read the length of encryption file and the length of key file;
Random the first overlay file generated with encryption file equal length, it is random to generate and key file equal length
Second overlay file;
First overlay file is covered into encryption file, the second overlay file is covered into key file.
The present invention also provides a kind of file encryption-decryption methods, including file encrypting method and file decryption method.
Compared with prior art, the present invention beneficial has the technical effect that
1, present invention employs the Encryption Algorithm for being based on " rule ", change the file security mode for being completely dependent on key, real
Now " the individual character encryption " of each file, reaches the cipher round results of " one-time pad ";
2, the present invention realizes the different depth encryption of different security level file, under emergency, burst and ad hoc network environment
Secure information storage and transmission provide new technological means;
3, the present invention may be implemented to guarantee that information is not broken to the destruction of the information content and destruction after confidential information is stolen
It translates.
Detailed description of the invention
Fig. 1 is the schematic diagram that file encryption is iterated operation to fragment in the process;
Fig. 2 is the schematic diagram that file decryption is iterated operation to fragment in the process;
Fig. 3 is the flow diagram for destroying encryption file and key file;
Fig. 4 is the flow diagram of file encryption-decryption.
Explanation is further explained in detail to particular content of the invention below in conjunction with drawings and examples.
Specific embodiment
Specific embodiments of the present invention are given below, it should be noted that the invention is not limited to implement in detail below
Example, all equivalent transformations made on the basis of the technical solutions of the present application each fall within protection scope of the present invention.
Embodiment 1:
The present embodiment provides a kind of file encrypting method, comprising the following steps:
Step 1, file to be encrypted is read, the file size to be encrypted is L;Length is randomly selected from sample file is
A segment file of L carries out xor operation as current file, by file to be encrypted and current file, obtains intermediate file, wherein L
More than or equal to 1, unit is byte;
Step 2, n fragment length is generated at random, and intermediate file is divided by n fragment according to fragment length;
Step 3, the sequence of n fragment in intermediate file is upset, obtains current intermediate file;
Step 4, xor operation is carried out to n fragment of current intermediate file, obtains preliminary intermediate file;
As shown in Figure 1, comprising:
Step 41, enabling i=1, i is the encryption cycle factor;
Step 42, i-th of fragment piece in n fragment of new sequences arrangement is subjected to xor operation with i+1 fragment,
Obtain the i-th ' a fragment;
Step 43, i=i+1 repeats step 42, until i=n-1, obtains the 1st ' a fragment ..., and (n-1) ' a point
Piece;
Step 44, a fragment is randomly selected from current intermediate file as current slice, it will be in current intermediate file
N-th fragment and current slice carry out xor operation, obtain the n-th ' a fragment;
By the 1st ' a fragment ..., (n-1) ' a fragment, the n-th ' a fragment is as preliminary encryption file;
Step 5, file will be tentatively encrypted as current intermediate file, repeats step 3 to step 4p times, obtain encryption text
Part, p are the natural number greater than 1, include the n fragment arranged in sequence in the encryption file;
The present invention different secret classifications according to locating for file to be encrypted number of repetition p are arranged different numerical value, carry out
Different degrees of safeguard protection meets the needs of information privacy.
Specifically, when file to be encrypted is confidential file, number of repetition p is 3;When file to be encrypted is classified papers
When, number of repetition p is 5;When file to be encrypted is topsecret papers, number of repetition p is 7.
Step 6, according to encryption file, key file is generated, key file and sample file are subjected to xor operation, obtained
Encryption key.
Specifically, length, the fragment quantity, the sequence of fragment, the reading of sample file of each fragment in file will be encrypted
The information integration such as extension name of position, file to be encrypted, generates a key file.
The selection of sample file is random in the present embodiment, can choose video, voice, picture, file etc., selection
It is required that being that the size of sample file is significantly larger than the size (10 times of file < sample files to be encrypted) of file to be encrypted.
File to be encrypted in the present invention can be the multiple types files such as text, picture, audio, video, and can transport
For row in mainstream operation system, system can be in a variety of routine operations such as Windows 2000, Windows XP, 7 Windows
It is run in system, meets the requirement of most users in current network.
The present invention can be directed to exhaustive password cracking hand by being iterated XOR operation after the out-of-order processing to file
Section, carry out file to be encrypted cracks protection, the leakage of the information content after preventing confidential information to be stolen.
Embodiment 2:
Present embodiments provide a kind of file decryption method, comprising the following steps:
Step 1, the encryption file in key is read, the encryption file includes m fragment, using encryption file as current
Decrypt file;
Step 2, m fragment in current decryption file is decrypted, obtains clear text file;
As shown in Figure 2, comprising:
Step 21, a segment file is obtained at random from sample file as current decryption fragment, it will be in current decryption file
M-th fragment and current decryption fragment carry out xor operation, obtain a fragment of m ' of clear text file;
Step 22, enabling j=m-1, j is the decryption rounds factor;
Step 23, j-th of fragment in current decryption file and (j+1) ' a fragment of clear text file are subjected to exclusive or
Operation, obtains jth ' a fragment of clear text file;
Step 24, step 23 is repeated, until j=1, obtains clear text file, the clear text file includes the 1st ' a point
Piece ..., (m-1) ' a fragment, a fragment of m ';
Step 3, it using clear text file as current decryption file, repeats step 2q times, obtains tentatively decrypting file;
The numerical value of q is arranged according to ciphertext grade by the present invention, and ciphertext series is higher, and the numerical value of q is bigger.
Step 4, it will tentatively decrypt file and sample file carries out xor operation, and obtain decryption file;
Step 5, encryption file is decrypted using decryption file.
The sample file in sample file and embodiment 1 in the present embodiment is same sample file.
User carries out attempting to crack after illegally obtaining key file or encryption file in order to prevent, joined in the present invention
Protection is cracked to key;
If the number that encryption file is decrypted in decryption file is greater than H, encryption file is destroyed, H is greater than 1
Natural number.
The present invention is 5 times according to the maximum fault-tolerant number H of ciphertext grade setting, confidential, and confidential is 4 times, top secret 2
Secondary, when user attempts to crack, once errors number is more than to limit, program can erasable key file and encryption under silent status
File content, and forced shutdown.Specific comparison content include: whether key format meets the requirements, whether sample file consistent,
The key messages such as whether confidential is consistent, whether file fragmentation quantity is consistent.
The encryption file is destroyed, as shown in Figure 3, comprising:
Read the length of encryption file and the length of key file;
Random the first overlay file generated with encryption file equal length, it is random to generate and key file equal length
Second overlay file;
First overlay file is covered into encryption file, the second overlay file is covered into key file.
Embodiment 3:
A kind of file encryption-decryption method is present embodiments provided, as shown in figure 4, including the file encryption that embodiment 1 provides
The file decryption method that method and embodiment 2 provide.
Claims (5)
1. a kind of file encrypting method, which comprises the following steps:
Step 1, file to be encrypted is read, the file size to be encrypted is L;It is L's that length is randomly selected from sample file
One segment file carries out xor operation as current file, by file to be encrypted and current file, obtains intermediate file, wherein L is big
In being equal to 1, unit is byte;
Step 2, n fragment length is generated at random, and intermediate file is divided by n fragment according to fragment length;
Step 3, the sequence of n fragment in intermediate file is upset, obtains current intermediate file;
Step 4, xor operation is carried out to n fragment of current intermediate file, obtains preliminary intermediate file;
Include:
Step 41, enabling i=1, i is the encryption cycle factor;
Step 42, it by i-th of the fragment piece and i+1 fragment progress xor operation in n fragment of new sequences arrangement, obtains
The i-th ' a fragment;
Step 43, i=i+1 repeats step 42, until i=n-1, obtains the 1st ' a fragment ..., (n-1) ' a fragment;
Step 44, a fragment is randomly selected from current intermediate file as current slice, by n-th in current intermediate file
A fragment and current slice carry out xor operation, obtain the n-th ' a fragment;
By the 1st ' a fragment ..., (n-1) ' a fragment, the n-th ' a fragment is as preliminary encryption file;
Step 5, file will be tentatively encrypted as current intermediate file, repeats step 3 to step 4p times, obtains encryption file, and p is
Natural number greater than 1, described encrypt includes the n fragment arranged in sequence in file;
Step 6, according to encryption file, key file is generated, key file and sample file are subjected to xor operation, encrypted
Key.
2. a kind of file decryption method, which comprises the following steps:
Step 1, the encryption file in key is read, the encryption file includes m fragment, using encryption file as current decryption
File;
Step 2, m fragment in current decryption file is decrypted, obtains clear text file;
Include:
Step 21, a segment file is obtained at random from sample file as current decryption fragment, by the m in current decryption file
A fragment and current decryption fragment carry out xor operation, obtain a fragment of m ' of clear text file;
Step 22, enabling j=m-1, j is the decryption rounds factor;
Step 23, j-th of fragment in current decryption file and (j+1) ' a fragment of clear text file are subjected to xor operation,
Obtain jth ' a fragment of clear text file;
Step 24, step 23 is repeated, until j=1, obtains clear text file, the clear text file includes the 1st ' a fragment ..., the
(m-1) ' a fragment, a fragment of m ';
Step 3, it using clear text file as current decryption file, repeats step 2q times, obtains tentatively decrypting file;
Step 4, it will tentatively decrypt file and sample file carries out xor operation, and obtain decryption file;
Step 5, encryption file is decrypted using decryption file.
3. file decryption method as claimed in claim 2, which is characterized in that in the step 5, if decryption file is to encryption text
The number that part is decrypted is greater than H, then destroys encryption file, and H is the natural number greater than 1.
4. file decryption method as claimed in claim 3, which is characterized in that destroyed to the encryption file, comprising:
Read the length of encryption file and the length of key file;
Random the first overlay file generated with encryption file equal length, random second generated with key file equal length
Overlay file;
First overlay file is covered into encryption file, the second overlay file is covered into key file.
5. a kind of file encryption-decryption method, which is characterized in that including file encrypting method described in claim 1 and claim
2 to 4 described in any item file decryption methods.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910615408.2A CN110489978A (en) | 2019-07-09 | 2019-07-09 | A kind of file encryption-decryption method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910615408.2A CN110489978A (en) | 2019-07-09 | 2019-07-09 | A kind of file encryption-decryption method |
Publications (1)
Publication Number | Publication Date |
---|---|
CN110489978A true CN110489978A (en) | 2019-11-22 |
Family
ID=68546842
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910615408.2A Pending CN110489978A (en) | 2019-07-09 | 2019-07-09 | A kind of file encryption-decryption method |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110489978A (en) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111432244A (en) * | 2020-03-17 | 2020-07-17 | 中国人民解放军国防科技大学 | Lightweight image encryption and decryption method, device and system based on attributes |
CN114285562A (en) * | 2021-12-27 | 2022-04-05 | 元心信息科技集团有限公司 | Data encryption method and device |
CN114490963A (en) * | 2021-12-17 | 2022-05-13 | 中国人民解放军空军军医大学 | All-media publishing system |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102170350A (en) * | 2011-04-11 | 2011-08-31 | 桂林电子科技大学 | Multiple uncertainty encryption system with misleading function |
CN104883257A (en) * | 2014-06-12 | 2015-09-02 | 梁庆生 | Big data encryption method |
CN104967518A (en) * | 2015-07-31 | 2015-10-07 | 中国人民解放军71777部队 | Method for improving information transmission security |
-
2019
- 2019-07-09 CN CN201910615408.2A patent/CN110489978A/en active Pending
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102170350A (en) * | 2011-04-11 | 2011-08-31 | 桂林电子科技大学 | Multiple uncertainty encryption system with misleading function |
CN104883257A (en) * | 2014-06-12 | 2015-09-02 | 梁庆生 | Big data encryption method |
CN104967518A (en) * | 2015-07-31 | 2015-10-07 | 中国人民解放军71777部队 | Method for improving information transmission security |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111432244A (en) * | 2020-03-17 | 2020-07-17 | 中国人民解放军国防科技大学 | Lightweight image encryption and decryption method, device and system based on attributes |
CN114490963A (en) * | 2021-12-17 | 2022-05-13 | 中国人民解放军空军军医大学 | All-media publishing system |
CN114490963B (en) * | 2021-12-17 | 2023-11-24 | 中国人民解放军空军军医大学 | Full-media publishing system |
CN114285562A (en) * | 2021-12-27 | 2022-04-05 | 元心信息科技集团有限公司 | Data encryption method and device |
CN114285562B (en) * | 2021-12-27 | 2023-05-09 | 元心信息科技集团有限公司 | Data encryption method and device |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN107086915B (en) | Data transmission method, data sending end and data receiving end | |
CN102904712B (en) | Information ciphering method | |
US20030056118A1 (en) | Method for encryption in an un-trusted environment | |
CN104660590B (en) | A kind of file encryption secure cloud storage scheme | |
Liu et al. | Whispers on ethereum: Blockchain-based covert data embedding schemes | |
CN110489978A (en) | A kind of file encryption-decryption method | |
Devi et al. | A review on DES, AES and blowfish for image encryption & decryption | |
CN106778292B (en) | A kind of quick restoring method of Word encrypted document | |
Kumar et al. | A survey on current key issues and status in cryptography | |
CN103942500B (en) | Hash ciphertext re-encryption method based on noise and decryption method after re-encryption | |
Firdaus et al. | Monitoring system with two central facilities protocol | |
Yahaya et al. | Cryptosystem for secure data transmission using Advance Encryption Standard (AES) and Steganography | |
CN105897568A (en) | Multi-channel-based mail fragmentation transmission method | |
Mohammed et al. | Implementation of new secure encryption technique for cloud computing | |
US11468178B1 (en) | Embedded obfuscated channel cryptography | |
Aghili | Improving security using blow fish algorithm on deduplication cloud storage | |
CN108134799A (en) | Novel encipher-decipher method and its device | |
CN104463003A (en) | File encryption protecting method | |
CN102647428A (en) | Encrypting and decrypting system and method adopting trusteeship control based on communication network | |
Sharma et al. | Steganography techniques using cryptography-a review paper | |
Singh et al. | Cryptography and Steganography Techniques | |
Patel et al. | Triple security of information using steganography and cryptography | |
Bishoi et al. | An algorithm on text based security in modern cryptography | |
Sadasivam et al. | Image Steganography | |
Reddy et al. | Data Storage on Cloud using Split-Merge and Hybrid Cryptographic Techniques |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20191122 |