CN106372517A - File encryption method, file decryption method, file encryption device and equipment - Google Patents

File encryption method, file decryption method, file encryption device and equipment Download PDF

Info

Publication number
CN106372517A
CN106372517A CN201610772530.7A CN201610772530A CN106372517A CN 106372517 A CN106372517 A CN 106372517A CN 201610772530 A CN201610772530 A CN 201610772530A CN 106372517 A CN106372517 A CN 106372517A
Authority
CN
China
Prior art keywords
file
encrypted
deviant
deciphering
sampling value
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
Application number
CN201610772530.7A
Other languages
Chinese (zh)
Inventor
卡涛
李明浩
曲雯雯
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Xiaomi Mobile Software Co Ltd
Original Assignee
Beijing Xiaomi Mobile Software Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Beijing Xiaomi Mobile Software Co Ltd filed Critical Beijing Xiaomi Mobile Software Co Ltd
Priority to CN201610772530.7A priority Critical patent/CN106372517A/en
Publication of CN106372517A publication Critical patent/CN106372517A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/602Providing cryptographic facilities or services
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/62Protecting access to data via a platform, e.g. using keys or access control rules
    • G06F21/6209Protecting access to data via a platform, e.g. using keys or access control rules to a single file or object, e.g. in a secure envelope, encrypted and accessed using a key, or with access control rules appended to the object itself
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/64Protecting data integrity, e.g. using checksums, certificates or signatures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2221/00Indexing scheme relating to security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F2221/21Indexing scheme relating to G06F21/00 and subgroups addressing additional information or applications relating to security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F2221/2107File encryption

Abstract

The invention discloses a file encryption method, a file decryption method, a file encryption device and equipment. The method comprises the following steps: obtaining a to-be-encrypted file; generating a secrete key, an offset value and a sampling value; determining the to-be-encrypted field in the to-be-encrypted file according to the offset value and the sampling value; and encrypting the to-be-encrypted field according to the secrete key. According to the invention, the file encryption efficiency can be improved.

Description

The encryption method of file, decryption method, device and equipment
Technical field
It relates to the encryption method of field of information security technology, more particularly, to file, decryption method, device and set Standby.
Background technology
Development with terminal unit and popularization, people are to the information producing on terminal unit, the such as literary composition such as picture and video The safety of part is increasingly paid attention to, thus, how effectively these files are carried out with encryption and decryption then becomes more and more important.
In correlation technique, when the files such as picture or video are encrypted, mainly pass through AES, such as data Encryption standard (data encryption standard;Referred to as: des), digest algorithm (message-digest algorithm 5;Referred to as: md5) etc. file is encrypted.When big file being encrypted using this encryption method, encryption efficiency is relatively low.
Content of the invention
For overcoming problem present in correlation technique, the disclosure provides a kind of encryption method of file, decryption method, device And equipment.
According to the embodiment of the present disclosure in a first aspect, provide a kind of encryption method of file, comprising:
Obtain file to be encrypted;
Generate key, deviant and sampling value;
According to described deviant and described sampling value, determine the field to be encrypted in described file to be encrypted;
According to described key, described field to be encrypted is encrypted.
Due to being determined after field to be encrypted according to deviant and sampling value, only treat encrypted fields and be encrypted, it is to avoid The phenomenon in correlation technique, whole file being encrypted, thus improve the efficiency of file encryption.
In conjunction with a first aspect, in the first possible implementation of first aspect, described according to described deviant and Described sampling value, determines the field to be encrypted in described file to be encrypted, comprising:
According to described deviant and sampling value, after being spaced described deviant in described file to be encrypted, by described sampling It is worth corresponding field, be defined as described field to be encrypted.
Due to field to be encrypted being determined according to deviant and sampling value so that the determination mode of field to be encrypted is simpler Single.
In conjunction with a first aspect, in the possible implementation of the second of first aspect, described generation key, deviant and After sampling value, methods described also includes:
Described key, described deviant and described sampling value are write the file header of described file to be encrypted;
Described file header is encrypted.
Due to writing key, deviant and sampling value after file header, file header is encrypted, improves the peace of file Quan Xing.
In conjunction with the possible implementation of the second of first aspect, in the third possible implementation of first aspect In, described described file header is encrypted, comprising:
Obtain and be stored in local public key corresponding with described file header;
Using described public key, described file header is encrypted.
Due to being encrypted to file header, thus improve the safety of file.
In conjunction with a first aspect, in the 4th kind of possible implementation of first aspect, described acquisition file to be encrypted it Afterwards, also include:
According to preset rules, the field of described file to be encrypted is rearranged.
The field of file to be encrypted is rearranged, the order of former file field to be encrypted can be upset so as to encryption The deciphering difficulty of file increases, and thus can improve the reliability of file encryption it is ensured that the safety of file to be encrypted.
In conjunction with the 4th kind of possible implementation of first aspect, in the 5th kind of possible implementation of first aspect In, described file to be encrypted includes the first file to be encrypted and the second file to be encrypted;
The described field by described file to be encrypted rearranges, comprising:
By mobile for the described first file to be encrypted to described second file to be encrypted;Wherein, described first is to be added Ciphertext part is front preset length field in described file to be encrypted;Described second file to be encrypted is in described file to be encrypted Field in addition to the described first file to be encrypted.
After the first file movement to be encrypted to the second file to be encrypted, as such, it is possible to upset former file to be encrypted The order of field, so that increasing to the deciphering difficulty of encryption file, thus can improve the reliability of file encryption.
In conjunction with a first aspect, in the 6th kind of possible implementation of first aspect, described acquisition file to be encrypted it Afterwards, also include:
Identify file type or the file size of described file to be encrypted;
If described file type is video file or described file size is more than predetermined threshold value, generate described key, institute State deviant and described sampling value.
Due to different cipher modes according to file type and file size, can be adopted so that cipher mode is cleverer Live.
Second in conjunction with first aspect or the third possible implementation, in the 7th kind of possible reality of first aspect In existing mode, the file header of described file to be encrypted includes thumbnail storage area.
Size due to thumbnail is byte rank, it is possible to completing entirely to encrypt so that user in 100ms rank When entering encryption application viewing thumbnail displaying, encryption is unaware to user, thus improve the experience of user.
According to the second aspect of the embodiment of the present disclosure, provide a kind of decryption method of file, comprising:
Obtain encryption file;
Obtain key, deviant and sampling value;
According to described deviant and described sampling value, determine the encrypted fields in described encryption file;
According to described key, described encrypted fields are decrypted, obtain deciphering file.
Due to first according to deviant and sampling value, determine encrypted fields, then be decrypted for encrypted fields, thus avoid The phenomenon in correlation technique, whole file being decrypted, thus improve the efficiency of file decryption.
In conjunction with second aspect, in the first possible implementation of second aspect, described according to described deviant and Described sampling value, determines the encrypted fields in described encryption file, comprising:
According to described deviant and sampling value, after being spaced described deviant in described encryption file, by described sampling value Corresponding field, is defined as described encrypted fields.
Due to according to deviant and sampling value, determining encrypted fields so that the determination mode of encrypted fields is simpler.
In conjunction with second aspect, in the third possible implementation of second aspect, described acquisition key, deviant and Sampling value, comprising:
The file header encrypting file according to private key pair is decrypted, the key in the described file header of acquisition, deviant And sampling value.
Due to being decrypted to file header, obtain key, deviant and sampling value so that key, deviant and sampling value Acquisition modes simpler.
In conjunction with second aspect, in the 4th kind of possible implementation of second aspect, if described file header includes institute State encryption file cryptographic Hash, then described according to described key, described encrypted fields are decrypted after, also include:
According to described cryptographic Hash, the described encrypted fields after deciphering are verified.
According to the integrity of the encryption file after the verification deciphering of this cryptographic Hash, thus improve the reliability of file application.
In conjunction with second aspect, in the 5th kind of possible implementation of second aspect, described according to described key to institute State encrypted fields to be decrypted, after obtaining deciphering file, also include:
According to preset rules, the field of described deciphering file is rearranged.
Due in encryption, in order to improve the reliability of file encryption, the field of file to be encrypted being adjusted, phase Answering, after encryption file is decrypted, needing to be reduced the field of deciphering file, thus improve file decryption Correctness.
In conjunction with the 5th kind of possible implementation of second aspect, in the 6th kind of possible implementation of second aspect In, described deciphering file includes the first deciphering file and the second deciphering file;
The described field by described deciphering file rearranges, comprising:
By mobile for the described first deciphering file to described second deciphering file;Wherein, described first deciphering file For rear preset length field in described deciphering file;Described second deciphering file is except described first solution in described deciphering file Field beyond ciphertext part.
Due in encryption, in order to improve the reliability of file encryption, the field of file to be encrypted being adjusted, that is, After the first file movement to be encrypted to the second file to be encrypted.Accordingly, after encryption file is decrypted, need Before the first deciphering file movement to the second deciphering file, the field of deciphering file is reduced, thus carrying The high correctness of file decryption.
In conjunction with second aspect, in the 7th kind of possible implementation of second aspect, after described acquisition encryption file, Also include:
The file type of identification described encryption file or file size;
If described file type is video file or described file size is more than predetermined threshold value, obtain key, described partially Shifting value and described sampling value.
Due to different manner of decryption according to file type and file size, can be adopted so that manner of decryption is cleverer Live.
According to the third aspect of the embodiment of the present disclosure, provide a kind of encryption device of file, comprising:
Acquisition module, is configured to obtain file to be encrypted;
First generation module, is configurable to generate key, deviant and sampling value;
Determining module, is configured to the described deviant according to described first generation module generation and described sampling value, really Field to be encrypted in fixed described file to be encrypted;
First encrypting module, is configured to according to described key, the word described to be encrypted that described determining module is determined Section is encrypted.
In conjunction with the third aspect, in the first possible implementation of the third aspect, described determining module includes:
Determination sub-module, is configured to according to described deviant and sampling value, is spaced described in described file to be encrypted After deviant, by corresponding for described sampling value field, it is defined as described field to be encrypted.
In conjunction with the third aspect, in the possible implementation of the second of the third aspect, described device also includes:
Writing module, is configured to for described key, described deviant and described sampling value to write described file to be encrypted File header;
Second encrypting module, is configured to described file header is encrypted.
In conjunction with the possible implementation of the second of the third aspect, in the third possible implementation of the third aspect In, described second encrypting module includes:
Acquisition submodule, is configured to obtain and is stored in local public key corresponding with described file header;
Encryption submodule, is configured to using described public key, described file header is encrypted.
In conjunction with the third aspect, in the 4th kind of possible implementation of the third aspect, described device also includes:
Processing module, is configured to, according to preset rules, the field of described file to be encrypted be rearranged.
In conjunction with the 4th kind of possible implementation of the third aspect, in the 5th kind of possible implementation of the third aspect In, described file to be encrypted includes the first file to be encrypted and the second file to be encrypted;Described processing module includes:
Mobile submodule, is configured to mobile for the described first file to be encrypted to described second file to be encrypted Face;Wherein, described first file to be encrypted is front preset length field in described file to be encrypted;Described second ciphertext to be added Part is the field in described file to be encrypted in addition to the described first file to be encrypted.
In conjunction with the third aspect, in the 6th kind of possible implementation of the third aspect, described device also includes:
Identification module, is configured to identify file type or the file size of described file to be encrypted;
Second generation module, is configured to identify that described file type is video file or described in described identification module When file size is more than predetermined threshold value, generate described key, described deviant and described sampling value.
Second in conjunction with the third aspect or the third possible implementation, in the 7th kind of possible reality of the third aspect In existing mode, the file header of described file to be encrypted includes thumbnail storage area.
According to the fourth aspect of the embodiment of the present disclosure, provide a kind of deciphering device of file, comprising:
First acquisition module, is configured to obtain encryption file;
Second acquisition module, is configured to obtain key, deviant and sampling value;
Determining module, is configured to the described deviant according to described second acquisition module acquisition and described sampling value, really Encrypted fields in fixed described encryption file;
First deciphering module, is configured to according to described key, the described encrypted fields that described determining module is determined be entered Row deciphering, obtains deciphering file.
In conjunction with fourth aspect, in the first possible implementation of fourth aspect, described determining module includes:
Determination sub-module, is configured to, according to described deviant and sampling value, be spaced described inclined in described encryption file After shifting value, corresponding for described sampling value field is defined as described encrypted fields.
In conjunction with fourth aspect, in the possible implementation of the second of fourth aspect, described second acquisition module includes:
Acquisition submodule, the file header being configured to encrypt file according to private key pair is decrypted, and obtains described literary composition Key in part head, deviant and sampling value.
In conjunction with fourth aspect, in the third possible implementation of fourth aspect, described device also includes:
Correction verification module, is configured to, according to cryptographic Hash, the described encrypted fields after deciphering be verified.
In conjunction with fourth aspect, in the 4th kind of possible implementation of fourth aspect, described device also includes:
Processing module, is configured to, according to preset rules, the field of described deciphering file be rearranged.
In conjunction with the 4th kind of possible implementation of fourth aspect, in the 5th kind of possible implementation of fourth aspect In, described deciphering file includes the first deciphering file and the second deciphering file;
Described processing module includes:
Mobile submodule, is configured to mobile for the described first deciphering file to described second deciphering file;Its In, described first deciphering file is rear preset length field in described deciphering file;Described second deciphering file is described solution Field in addition to the described first deciphering file in ciphertext part.
In conjunction with fourth aspect, in the 6th kind of possible implementation of fourth aspect, described device also includes:
Identification module, is configured to identify file type or the file size of described encryption file;
3rd acquisition module, is configured to identify that described file type is video file or described in described identification module When file size is more than predetermined threshold value, obtain described key, described deviant and described sampling value.
According to the 5th aspect of the embodiment of the present disclosure, provide a kind of terminal unit, comprising:
Processor;
For storing the memorizer of processor executable;
Wherein, described processor is configured to:
Obtain file to be encrypted;
Generate key, deviant and sampling value;
According to described deviant and described sampling value, determine the field to be encrypted in described file to be encrypted;
According to described key, described field to be encrypted is encrypted.
According to the 6th aspect of the embodiment of the present disclosure, provide a kind of terminal unit, comprising:
Processor;
For storing the memorizer of processor executable;
Wherein, described processor is configured to:
Obtain encryption file;
Obtain key, deviant and sampling value;
According to described deviant and described sampling value, determine the encrypted fields in described encryption file;
According to described key, described encrypted fields are decrypted.
The technical scheme that embodiment of the disclosure provides can include following beneficial effect:
By obtaining file to be encrypted, and generate key, deviant and sampling value, determined according to deviant and sampling value and treat Field to be encrypted in encryption file, according to key, treats encrypted fields and is encrypted.Due to true according to deviant and sampling value After making field to be encrypted, only treat encrypted fields and be encrypted, it is to avoid in correlation technique, whole file is encrypted Phenomenon, thus improve the efficiency of file encryption.
It should be appreciated that above general description and detailed description hereinafter are only exemplary and explanatory, not The disclosure can be limited.
Brief description
Accompanying drawing herein is merged in description and constitutes the part of this specification, shows the enforcement meeting the present invention Example, and be used for explaining the principle of the present invention together with description.
Fig. 1 is a kind of flow chart of the encryption method of file according to an exemplary embodiment;
Fig. 2 is the flow chart of the encryption method implementing a kind of file exemplifying according to another exemplary;
Fig. 3 is a kind of flow chart of the encryption method of file according to another exemplary embodiment;
Fig. 4 is a kind of flow chart of the decryption method of file according to an exemplary embodiment;
Fig. 5 is a kind of block diagram of the encryption device of file according to an exemplary embodiment;
Fig. 6 is the block diagram of the encryption device implementing a kind of file exemplifying according to another exemplary;
Fig. 7 is a kind of block diagram of the encryption device of file according to further example embodiment;
Fig. 8 is a kind of block diagram of the encryption device of file according to another exemplary embodiment;
Fig. 9 is a kind of block diagram of the encryption device of file according to another exemplary embodiment;
Figure 10 is a kind of block diagram of the encryption device of file according to another exemplary embodiment;
Figure 11 is a kind of block diagram of the encryption device of file according to another exemplary embodiment;
Figure 12 is a kind of block diagram of the deciphering device of the file according to an exemplary embodiment;
Figure 13 is a kind of block diagram of the deciphering device of the file implementing to exemplify according to another exemplary;
Figure 14 is a kind of block diagram of the deciphering device of the file according to further example embodiment;
Figure 15 is a kind of block diagram of the deciphering device of the file according to another exemplary embodiment;
Figure 16 is a kind of block diagram of the deciphering device of the file according to another exemplary embodiment;
Figure 17 is a kind of block diagram of the deciphering device of the file according to another exemplary embodiment;
Figure 18 is a kind of block diagram of the deciphering device of the file according to another exemplary embodiment;
Figure 19 is a kind of block diagram of the deciphering device of the file according to another exemplary embodiment;
Figure 20 is a kind of block diagram of the deciphering device of the file according to another exemplary embodiment;
Figure 21 is a kind of block diagram of the encryption device for file according to an exemplary embodiment.
Specific embodiment
Here will in detail exemplary embodiment be illustrated, its example is illustrated in the accompanying drawings.Explained below is related to During accompanying drawing, unless otherwise indicated, the same numbers in different accompanying drawings represent same or analogous key element.Following exemplary embodiment Described in embodiment do not represent all embodiments consistent with the present invention.On the contrary, they be only with such as appended The example of the consistent apparatus and method of some aspects being described in detail in claims, the present invention.
Fig. 1 is a kind of flow chart of the encryption method of file according to an exemplary embodiment, as shown in figure 1, this The encryption method of the file that embodiment is related to is used in terminal unit, and this terminal unit is to store the files such as picture, video Equipment, can be for example mobile phone, personal digital assistant (personal digital assistant, abbreviation pda), computer Deng.The encryption method of this document comprises the following steps.
In step s11, obtain file to be encrypted.
In step s12, generate key, deviant and sampling value.
In the related, when typically the files such as picture or video being encrypted, mainly pass through AES pair File is integrally encrypted.When file is less, when file is carried out with overall encryption, the time used is shorter, but, work as file When larger, adopt and will consume longer time in this way, thus lead to file encryption efficiency is relatively low and system takies relatively High.
For this problem, in the disclosed embodiments, terminal unit is after getting file to be encrypted, first can be with Machine generates a key, and during concrete implementation, terminal unit can be according to the production time of file to be encrypted and file Size and file format generate at random, and therefore, different files can correspond to different keys, thus can improve the reliability of encryption Property.After generating key, terminal unit also needs to generate deviant and sampling value by generating random number scheduling algorithm, with basis The key, deviant and the sampling value that generate are encrypted to file to be encrypted.Wherein, Generating Random Number for example can adopt Following implementation:
Need to illustrate, key, deviant and sampling value can also generate in other way, for example permissible Pre-set etc., for the concrete generating mode of key, deviant and sampling value, this is not restricted for the present embodiment.
In step s13, according to deviant and sampling value, determine the field to be encrypted in file to be encrypted.
In step s14, according to key, treat encrypted fields and be encrypted.
In the present embodiment, terminal unit random generate deviant and sampling value after, according to deviant and sampling value First determine field to be encrypted, further according to key, the field to be encrypted determined is encrypted.
The encryption method of the file of the present embodiment, by obtaining file to be encrypted, and generates key, deviant and sampling Value, determines field to be encrypted according to deviant and sampling value, according to key, treats encrypted fields and be encrypted.Due to according to partially After shifting value and sampling value determine field to be encrypted, only treat encrypted fields and be encrypted, it is to avoid to whole in correlation technique The phenomenon that file is encrypted, thus improve the efficiency of file encryption.
Alternatively, according to deviant and sampling value, determine the field to be encrypted in file to be encrypted, comprising: according to skew Value and sampling value, after interval deviant in file to be encrypted, corresponding for sampling value field are defined as field to be encrypted.
Specifically, in encryption, spacing bias value is specified the byte of size, encryption sampling value specifies the byte of size.Lift For example, if deviant is 1024, sampling value is 128, then terminal unit, when being encrypted to file to be encrypted, will be spaced 1024 bytes, sampling 128 bytes are encrypted.In actual applications, terminal unit first spacing bias value can specify size Byte, re-encrypts sampling value and specifies the byte of size it is also possible to be encrypted from the beginning, that is, first encryption sampling value is specified greatly Little byte, then spacing bias value specify size byte be encrypted.
Fig. 2 is the flow chart of the encryption method implementing a kind of file exemplifying according to another exemplary, and the method is used for In terminal unit, the present embodiment, on the basis of embodiment illustrated in fig. 1, after generating key, deviant and sampling value, is treated The embodiment that is encrypted of file header of encryption file, elaborates, as shown in Fig. 2 the encryption method of this document include with Lower step.
In step s21, obtain file to be encrypted.
In step s22, generate key, deviant and sampling value.
In step s23, key, deviant and sampling value are write the file header of file to be encrypted.
In step s24, file header is encrypted.
In the present embodiment, terminal unit is generating key, after deviant and sampling value, by the key generating, skew Value and sampling value write in the file header of file to be encrypted, and using terminal unit locally stored public key, this document head are carried out Encryption, wherein, when file header is encrypted, locally can be encrypted by public key using rsa algorithm.Due to be encrypted Key, deviant and the sampling value that file to be encrypted is encrypted is included in the file header of file, after encryption file header, Even if disabled user acquires file, the file header being encryption due to file header, disabled user also cannot decipher file, more no Method reads file, thus can improve the reliability of file encryption.
Significantly, since key is random generation, therefore, each file to be encrypted has its own institute right The key answered, so, even if disabled user is deciphered to wherein certain or certain several files encrypted, but right For not having decrypted file, disabled user remains and cannot read, as such, it is possible to greatly improve the safety of file Property.
In step s25, according to deviant and sampling value, determine the field to be encrypted in file to be encrypted.
In step s26, according to key, treat encrypted fields and be encrypted.
In the present embodiment, after terminal unit is encrypted to file header, need to judge whether this file to be encrypted has More data, if having, according to the key generating, deviant and sampling value to its in addition to file header in file to be encrypted It needs the field to be encrypted of encryption to be encrypted.Only treat encrypted fields due to terminal unit to be encrypted, without right Whole file is all encrypted, and thus can improve the efficiency of file encryption.
The encryption method of the file of the present embodiment, by obtaining file to be encrypted, and generates key, deviant and sampling Value, determines field to be encrypted according to deviant and sampling value, according to key, treats encrypted fields and be encrypted.Due to according to partially After shifting value and sampling value determine field to be encrypted, only treat encrypted fields and be encrypted, it is to avoid to whole in correlation technique The phenomenon that file is encrypted, thus improve the efficiency of file encryption, and, by determining to according to deviant and sampling value The field to be encrypted going out is encrypted, and increased the difficulty that cracks to file, therefore improves the safety of file.In addition, by In writing key, deviant and sampling value after file header, file header is encrypted, improves the safety of file.
Fig. 3 is a kind of flow chart of the encryption method of file according to another exemplary embodiment, and the method is used for In terminal unit, the present embodiment, on the basis of embodiment illustrated in fig. 2, to the embodiment how file header being encrypted, is made Describe in detail, as shown in figure 3, the encryption method of this document comprises the following steps.
In step s31, obtain file to be encrypted.
In step s32, generate key, deviant and sampling value.
In step s33, key, deviant and sampling value are write the file header of file to be encrypted.
In step s34, obtain and be stored in local public key corresponding with file header.
In the present embodiment, terminal unit, when being encrypted to file header, needs to rely on public and private key, wherein, public key is User certificate, and it is stored in terminal unit locally, typically there is password to be verified accordingly when first time importing public key, and use The effect duration of family certificate is described by the attribute of certificate body.
In step s35, using public key, file header is encrypted.
In the present embodiment, after terminal unit gets public key corresponding with file header, will be using this public key to file header It is encrypted.In addition, in deciphering, terminal unit need to obtain private key, and is decrypted using the private key pair file header getting, To get the key in file header, deviant and sampling value.Wherein, private key can be from server obtain or Locally stored, for the concrete acquisition modes of private key, this is not restricted for the present embodiment.
In step s36, according to deviant and sampling value, determine the field to be encrypted in file to be encrypted.
In step s37, according to key, treat encrypted fields and be encrypted.
The encryption method of the file of the present embodiment, by obtaining file to be encrypted, and generates key, deviant and sampling Value, determines field to be encrypted according to deviant and sampling value, according to key, treats encrypted fields and be encrypted.Due to according to partially After shifting value and sampling value determine field to be encrypted, only treat encrypted fields and be encrypted, it is to avoid to whole in correlation technique The phenomenon that file is encrypted, thus improve the efficiency of file encryption, and, by determining to according to deviant and sampling value The field to be encrypted going out is encrypted, and increased the difficulty that cracks to file, therefore improves the safety of file.In addition, by In writing key, deviant and sampling value after file header, file header is encrypted, improves the safety of file.
Alternatively, on the basis of any of the above-described embodiment, the file header of file to be encrypted can also comprise user List, wherein, includes the ID of the user that can open this file to be encrypted in this user list, so, in multi-user It is possible to realize sharing an encryption file among different users so that multiple user can be in non-decrypted state under mechanism After lower acquisition certificate granting, realize checking and preview to file.
Alternatively, on the basis of above-mentioned embodiment illustrated in fig. 1, after obtaining file to be encrypted, also include: identification is treated The file type of encryption file or file size, if file type is video file or file size is more than predetermined threshold value, give birth to Become key, deviant and sampling value.
Specifically, the file header in file to be encrypted includes file identification, and terminal unit can be known according to file identification Other file type and file size, if terminal unit knows that file type is video file or file size is more than predetermined threshold value When, key, deviant and sampling value will be generated, and treat encrypted fields and be encrypted.If it should be noted that terminal unit root Judge that file to be encrypted is picture file or file size is less than or equal to predetermined threshold value according to file type or file size When, deviant and sampling value can not be generated, but directly whole file is encrypted by AES, wherein, encryption Algorithm can be for example Advanced Encryption Standard (advanced encryption standard, referred to as: aes) etc..
Due to different cipher modes according to file type and file size, can be adopted so that cipher mode is cleverer Live.Further, since file size is larger more than the memory space that file or the video file of predetermined threshold value take, therefore, only right The mode that field to be encrypted is encrypted, it is to avoid in correlation technique, file is carried out with the overall mode encrypted, so not only protects Demonstrate,prove the safety of file, and make encryption efficiency higher.And file size is less than or equal to file or the figure of predetermined threshold value The memory space that piece file takies is less, therefore, it can directly whole file is encrypted, thus improve the effect of encryption Rate.Further, since different cipher modes can be selected with file size according to file type, therefore the encryption method in the disclosure It is adapted to the encryption requirements of dissimilar and different size of file.
Alternatively, the file header of file to be encrypted includes thumbnail storage area.
Specifically, the thumbnail of file to be encrypted before file to be encrypted is encrypted, can first be generated, and should Thumbnail is saved in the thumbnail storage area of file header.After preservation, by AES, file header is encrypted.Due to The size of thumbnail is byte rank, it is possible to completing entirely to encrypt in 100ms rank so that user enters encryption application When viewing thumbnail is shown, encryption is unaware to user, thus improve the experience of user.Wherein, AES is for example Can be aes AES, md5 etc., for specific AES, this is not restricted for the present embodiment.
Alternatively, on the basis of above-mentioned embodiment illustrated in fig. 1, after obtaining file to be encrypted, also include: according to pre- If regular, the field of file to be encrypted is rearranged.
Specifically, in order to ensure the safety of file, after getting file to be encrypted, can according to preset rules, The field of file to be encrypted is re-started sequence, with upset the order of field in former file to be encrypted so as to encryption file Deciphering difficulty increase.Wherein, preset rules can be the predefined field needing movement, for example: can will be to be encrypted In file, the field of front 1kb moves to the afterbody of file to be encrypted, or will start to offset from original position in file to be encrypted The field of the 5kb after 10 bytes moves to afterbody of file to be encrypted etc..
Due to according to preset rules, the field of file to be encrypted being rearranged, word in former file to be encrypted can be upset The order of section, so that increasing to the deciphering difficulty of encryption file, thus can improve the reliability of file encryption.
Alternatively, on the basis of above-described embodiment, file to be encrypted includes the first file to be encrypted and second to be encrypted File, then rearrange the field of file to be encrypted, comprising: by the first file movement to be encrypted to the second file to be encrypted Below;Wherein, the first file to be encrypted is front preset length field in file to be encrypted;Second file to be encrypted is to be encrypted Field in addition to the first file to be encrypted in file.
Specifically, for video file, include video due in the field of the front preset length of file to be encrypted The essential information of file, for example: file type, video frame number and track information etc., if this essential information is cracked, video literary composition The safety of part will be on the hazard.In actual applications, if file to be encrypted be video file, obtain file to be encrypted it Afterwards, need first to carry out pretreatment to file to be encrypted, you can with by the first ciphertext to be added of preset length front in file to be encrypted Part movement to the second file to be encrypted afterbody, as such, it is possible to upset the order of former file to be encrypted so as to encryption file Deciphering difficulty increases, and thus can improve the reliability of file encryption, and ensure that the safety of file.Wherein, preset length Degree can be chosen according to practical situation or experience, for example, can be 128 bytes etc., for the concrete value of preset length, this reality This is not restricted to apply example.If it should be noted that determining that the first file to be encrypted has needed according to deviant and sampling value Entirely encrypted, now, because all fields in the first file to be encrypted will be all encrypted, therefore, confidentiality is preferable, now, Can be without by the afterbody of the first file movement to be encrypted to the second file to be encrypted.If being determined according to deviant and sampling value First file part to be encrypted is encrypted, and now, existing in the first file to be encrypted does not have encrypted field, therefore, secrecy Property is poor, therefore needs the afterbody of the first file movement to be encrypted to the second file to be encrypted.For example, if preset length is 128, therefore, in file to be encrypted, the field of front 128 bytes is the first file to be encrypted, and remaining is the second ciphertext to be added Part, if deviant is 0, sampling value is 256, now, because the first file to be encrypted is completely encrypted, therefore there is no need first File to be encrypted moves.
Fig. 4 is a kind of flow chart of the decryption method of file according to an exemplary embodiment, as shown in figure 4, should Decryption method is used in terminal unit, and this terminal unit is the equipment that can store the files such as picture, video, for example, can be handss Machine, pda, computer etc..The decryption method of this document comprises the following steps.
In step s41, obtain encryption file.
In step s42, obtain key, deviant and sampling value.
In the present embodiment, it is necessary first to obtain the key required for deciphering, skew before being decrypted to encryption file Value and sampling value.
In step s43, according to deviant and sampling value, determine the encrypted fields in encryption file.
In step s44, it is decrypted according to key pair encryption field, obtain deciphering file.
In the disclosed embodiments, in encryption, because terminal unit is first true according to the deviant generating and sampling value Fixed field to be encrypted, is treating what encrypted fields were encrypted.Accordingly, in deciphering, terminal unit will according to deviant and Sampling value first determines the encrypted fields in encryption file, and the encrypted fields determined are decrypted.
The decryption method of the file of the present embodiment, by obtaining encryption file, and obtains key, deviant and sampling value, According to deviant and sampling value, determine encrypted fields, be decrypted further according to this key pair encryption field.Due to first according to skew Value and sampling value, determine encrypted fields, then are decrypted for encrypted fields, thus avoid in correlation technique to whole file The phenomenon being decrypted, thus improve the efficiency of file decryption.
Alternatively, on the basis of embodiment illustrated in fig. 4, according to deviant and sampling value, determine adding in encryption file Close field, comprising: according to deviant and sampling value, after interval deviant in encryption file, by corresponding for sampling value field, really It is set to encrypted fields.
Specifically, after terminal unit interval deviant in encryption file, corresponding for sampling value field is defined as encrypting Spacing bias value is specified the byte of size by field in deciphering, and deciphering sampling value specifies the byte of size.For example, If deviant is 1024, sampling value is 128, then terminal unit, when being decrypted to encryption file, will be spaced 1024 bytes, and take Sample 128 byte is decrypted.
Alternatively, on the basis of embodiment illustrated in fig. 4, key, deviant and sampling value are obtained, comprising: according to private key The file header of encryption file is decrypted, obtains key in file header, deviant and sampling value.
Specifically, terminal unit, after getting encryption file, can send request message, server root to server Send private key, the file header of the private key pair encryption file that terminal unit sends according to server according to this request message to terminal unit It is decrypted, to obtain the key in file header, deviant and sampling value.In addition, terminal unit can also get encryption After file, it is decrypted according to the file header of locally stored private key pair encryption file.For the concrete acquisition modes of private key, This is not restricted for the present embodiment.
It should be noted that in the related, it is typically necessary in the case that file is deciphered completely, ability Obtain the essential information of file, thus showing user, but user is when needing using pictorial information or video information, not Sensitive to characteristic informations such as filenames.For this problem, in the disclosure, due to including filename, files-designated in file header The base attribute information such as know, it is possible to preview file after terminal unit is only decrypted to the file header of encryption file Essential information, such that it is able to make user quickly find the picture needing to use and video file.
Alternatively, on the basis of above-described embodiment, if file header includes encrypting the cryptographic Hash of file, according to key After encrypted fields are decrypted, also include: according to cryptographic Hash, the encrypted fields after deciphering are verified.
Specifically, if also including the cryptographic Hash of encryption file in file header, after deciphering completes, will be according to this Hash The integrity of the encryption file after value verification deciphering, thus improve the reliability of file application.
Alternatively, on the basis of embodiment illustrated in fig. 4, it is decrypted according to key pair encryption field, obtain solution ciphertext After part, also include: according to preset rules, the field of deciphering file is rearranged.
Specifically, due in encryption, in order to improve the reliability of file encryption it is ensured that the safety of file, according to default Rule, the field of file to be encrypted has been re-started arrangement, for example: the field of 1kb front in file to be encrypted is moved to and treats The afterbody of encryption file, or the field starting to offset the 5kb after 10 bytes from original position in file to be encrypted is moved Afterbody to file to be encrypted etc..Accordingly, encryption file is being decrypted, after obtaining deciphering file, is needing basis Preset rules, the field of deciphering file are reduced, for example: the field of 1kb rear in deciphering file is moved to deciphering file Stem, or will deciphering file in afterbody 5kb field, move to deciphering file in start to offset 10 words from original position At position after section etc..
Due to, after obtaining deciphering file, the field of deciphering file being reduced, thus improve file decryption Correctness.
Alternatively, on the basis of above-described embodiment, deciphering file includes the first deciphering file and the second deciphering file, will Deciphering file field rearrange including: by first deciphering file movement to second deciphering file before;Wherein, the first solution Ciphertext part is rear preset length field in deciphering file;Second deciphering file be deciphering file in except first deciphering file in addition to Field.
Specifically, due in encryption, in order to improve the reliability of file encryption, the field of file to be encrypted being carried out Adjustment, will be after the first file movement to be encrypted to the second file to be encrypted.Accordingly, encryption file is being decrypted Afterwards, need before the first deciphering file movement to the second deciphering file, the field of deciphering file reduced, Thus improve the correctness of file decryption.
Alternatively, on the basis of above-mentioned embodiment illustrated in fig. 4, after obtaining encryption file, also include: identification encryption The file type of file or file size, are more than predetermined threshold value if file type is video file or file size, key, partially Shifting value and sampling value.
Specifically, the file header in encryption file includes file identification, and terminal unit can identify according to file identification File type and file size, if terminal unit knows that file type is video file or file size is more than predetermined threshold value When, by the key obtaining in file header, deviant and sampling value, and encrypted fields are decrypted.If it should be noted that eventually End equipment is judged to encrypt file for picture file or file size less than or equal to pre- according to file type or file size If during threshold value, deviant and sampling value can not be generated, but directly whole file is decrypted by decipherment algorithm, its In, decipherment algorithm can be for example aes etc..
Due to different manner of decryption according to file type and file size, can be adopted so that manner of decryption is cleverer Live.
Alternatively, on the basis of any of the above-described embodiment, in the file header of encryption file, comprise thumbnail storage area.
Due to by thumbnail storage in file header, to encryption after file be decrypted when it is only necessary to deciphering file Head, just can obtain the thumbnail of file, and therefore, in the case that whole encryption file is not deciphered completely, user is just permissible File is browsed, so that user can quickly search the file needing to use.
Fig. 5 is a kind of block diagram of the encryption device of file according to an exemplary embodiment, as shown in figure 5, this article The encryption device of part includes acquisition module 11, the first generation module 12, determining module 13 and the first encrypting module 14.
Acquisition module 11 is configured to obtain file to be encrypted;
First generation module 12 is configurable to generate key, deviant and sampling value;
Determining module 13 is configured to the described deviant generating according to described first generation module 12 and described sampling value, Determine the field to be encrypted in described file to be encrypted;
First encrypting module 14 is configured to according to described key, the word described to be encrypted that described determining module is determined Section is encrypted.
Wherein, as shown in fig. 6, Fig. 6 is the frame of the encryption device implementing a kind of file exemplifying according to another exemplary Figure, on the basis of embodiment illustrated in fig. 5, described determining module 13 also comprises determining that submodule 131;
Determination sub-module 131 is configured to according to described deviant and sampling value, is spaced institute in described file to be encrypted After stating deviant, by corresponding for described sampling value field, it is defined as described field to be encrypted.
Wherein, as shown in fig. 7, Fig. 7 is a kind of frame of the encryption device of file according to further example embodiment Figure, on the basis of embodiment illustrated in fig. 5, described device also includes: writing module 15 and the second encrypting module 16;
Writing module 15 is configured to for described key, described deviant and described sampling value to write described file to be encrypted File header;
Second encrypting module 16 is configured to described file header is encrypted.
Wherein, as shown in figure 8, Fig. 8 is a kind of frame of the encryption device of file according to another exemplary embodiment Figure, on the basis of embodiment illustrated in fig. 7, described second encrypting module 16 includes: acquisition submodule 161 and encryption submodule 162;
Acquisition submodule 161 is configured to obtain and is stored in local public key corresponding with described file header;
Encryption submodule 162 is configured to using described public key, described file header is encrypted.
Wherein, as shown in figure 9, Fig. 9 is a kind of frame of the encryption device of file according to another exemplary embodiment Figure, on the basis of embodiment illustrated in fig. 7, described device also includes: processing module 17;
Processing module 17 is configured to, according to preset rules, the field of described file to be encrypted be rearranged.
Wherein, as shown in Figure 10, Figure 10 is a kind of encryption device of the file according to another exemplary embodiment Block diagram, on the basis of embodiment illustrated in fig. 9, described file to be encrypted includes the first file to be encrypted and the second ciphertext to be added Part;Described processing module includes: mobile submodule 171;
Mobile submodule 171 is configured to mobile for the described first file to be encrypted to described second file to be encrypted Face;Wherein, described first file to be encrypted is front preset length field in described file to be encrypted;Described second ciphertext to be added Part is the field in described file to be encrypted in addition to the described first file to be encrypted.
Wherein, as shown in figure 11, Figure 11 is a kind of encryption device of the file according to another exemplary embodiment Block diagram, on the basis of embodiment illustrated in fig. 5, described device also includes: identification module 18 and the second generation module 19;
Identification module 18 is configured to identify file type or the file size of described file to be encrypted;
Second generation module 19 be configured to described identification module 18 identify described file type be video file or When described file size is more than predetermined threshold value, generate described key, described deviant and described sampling value.
Wherein, on the basis of above-described embodiment, the file header of described file to be encrypted includes thumbnail storage area.
Figure 12 is a kind of block diagram of the deciphering device of the file according to an exemplary embodiment, as shown in figure 12, should The deciphering device of file includes the first acquisition module 21, the second acquisition module 22, determining module 23 and the first deciphering module 24.
First acquisition module 21 is configured to obtain encryption file;
Second acquisition module 22 is configured to obtain the file of the described encryption file that described first acquisition module 21 obtains Key in head, deviant and sampling value;
Determining module 23 is configured to the described deviant obtaining according to described second acquisition module 22 and described sampling value, Determine the encrypted fields in described encryption file;
First deciphering module 24 is configured to the described encrypted word described determining module 23 determined according to described key Section is decrypted, and obtains deciphering file.
Wherein, as shown in figure 13, Figure 13 is a kind of deciphering device of the file implementing to exemplify according to another exemplary Block diagram, on the basis of embodiment illustrated in fig. 12, described determining module 23 also comprises determining that submodule 231;
Determination sub-module 231 is configured to according to described deviant and sampling value, and in described encryption file, interval is described After deviant, corresponding for described sampling value field is defined as described encrypted fields.
Wherein, as shown in figure 14, Figure 14 is a kind of deciphering device of the file according to further example embodiment Block diagram, on the basis of embodiment illustrated in fig. 12, described second acquisition module 22 includes acquisition submodule 221;
The file header that acquisition submodule 221 is configured to encrypt file according to private key pair is decrypted, and obtains described Key in file header, deviant and sampling value.
Wherein, as shown in figure 15, Figure 15 is a kind of deciphering device of the file according to another exemplary embodiment Block diagram, on the basis of embodiment illustrated in fig. 12, described device also includes: correction verification module 25;
Correction verification module 25 is configured to, according to cryptographic Hash, the described encrypted fields after deciphering be verified.
Wherein, as shown in figure 16, Figure 16 is a kind of deciphering device of the file according to another exemplary embodiment Block diagram, on the basis of embodiment illustrated in fig. 12, described device also includes: processing module 26;
Processing module 26 is configured to, according to preset rules, the field of described deciphering file be rearranged.
Wherein, as shown in figure 17, Figure 17 is a kind of deciphering device of the file according to another exemplary embodiment Block diagram, on the basis of embodiment illustrated in fig. 16, described deciphering file includes the first deciphering file and the second deciphering file;Described Processing module 26 includes: mobile submodule 261;
Mobile submodule 261 is configured to mobile for the described first deciphering file to described second deciphering file; Wherein, preset length field after described first deciphering file is in described deciphering file;Described second deciphering file is described Field in addition to the described first deciphering file in deciphering file.
Wherein, as shown in figure 18, Figure 18 is a kind of deciphering device of the file according to another exemplary embodiment Block diagram, on the basis of embodiment illustrated in fig. 12, described device also includes: identification module 27 and the 3rd acquisition module 28;
Identification module 27 is configured to identify file type or the file size of described encryption file;
3rd acquisition module 28 be configured to described identification module 27 identify described file type be video file or When described file size is more than predetermined threshold value, obtain described key, described deviant and described sampling value.
With regard to the device in above-described embodiment, wherein the concrete mode of modules execution operation is in relevant the method Embodiment in be described in detail, explanation will be not set forth in detail herein.
The foregoing describe built-in function and the structure of the encryption device of file, as shown in figure 19, the encryption device of this document Can achieve and be:
Obtain file to be encrypted;
Generate key, deviant and sampling value;
According to described deviant and described sampling value, determine the field to be encrypted in described file to be encrypted;
According to described key, described field to be encrypted is encrypted.
The encryption method of the file of the present embodiment, by obtaining file to be encrypted, and generates key, deviant and sampling Value, determines field to be encrypted according to deviant and sampling value, according to key, treats encrypted fields and be encrypted.Due to according to partially After shifting value and sampling value determine field to be encrypted, only treat encrypted fields and be encrypted, it is to avoid to whole in correlation technique The phenomenon that file is encrypted, thus improve the efficiency of file encryption.
The foregoing describe the built-in function of deciphering device and the structure of file, as shown in figure 20, the deciphering device of this document Can achieve and be:
Obtain encryption file;
Obtain key, deviant and sampling value;
According to described deviant and described sampling value, determine encrypted fields;
According to described key, described encrypted fields are decrypted, obtain deciphering file.
The decryption method of the file of the present embodiment, by obtaining encryption file, and obtains key, deviant and sampling value, According to deviant and sampling value, determine encrypted fields, be decrypted further according to this key pair encryption field.Due to first according to skew Value and sampling value, determine encrypted fields, then are decrypted for encrypted fields, thus avoid in correlation technique to whole file The phenomenon being decrypted, thus improve the efficiency of file decryption.
Figure 21 is a kind of block diagram of the encryption device for file according to an exemplary embodiment.For example, device 800 can be mobile phone, computer, digital broadcast terminal, messaging devices, game console, tablet device, and medical treatment sets Standby, body-building equipment, personal digital assistant etc..
With reference to Figure 21, device 800 can include following one or more assemblies: process assembly 802, memorizer 804, power supply Assembly 806, multimedia groupware 808, audio-frequency assembly 810, the interface 812 of input/output (i/o), sensor cluster 814, and Communication component 816.
The integrated operation of the usual control device 800 of process assembly 802, such as with display, call, data communication, phase Machine operation and record operate associated operation.Process assembly 802 can include one or more processors 820 and refer to execute Order, to complete all or part of step of above-mentioned method.Additionally, process assembly 802 can include one or more modules, just Interaction between process assembly 802 and other assemblies.For example, process assembly 802 can include multi-media module, many to facilitate Interaction between media component 808 and process assembly 802.
Memorizer 804 is configured to store various types of data to support the operation in equipment 800.The showing of these data Example includes the instruction for any application program of operation or method on device 800, contact data, telephone book data, disappears Breath, picture, video etc..Memorizer 804 can be by any kind of volatibility or non-volatile memory device or their group Close and realize, such as static RAM (sram), Electrically Erasable Read Only Memory (eeprom), erasable compile Journey read only memory (eprom), programmable read only memory (prom), read only memory (rom), magnetic memory, flash Device, disk or CD.
Power supply module 806 provides electric power for the various assemblies of device 800.Power supply module 806 can include power management system System, one or more power supplys, and other generate, manage and distribute, with for device 800, the assembly that electric power is associated.
Multimedia groupware 808 includes the screen of one output interface of offer between described device 800 and user.One In a little embodiments, screen can include liquid crystal display (lcd) and touch panel (tp).If screen includes touch panel, screen Curtain may be implemented as touch screen, to receive the input signal from user.Touch panel includes one or more touch sensings Device is with the gesture on sensing touch, slip and touch panel.Described touch sensor can not only sensing touch or sliding action Border, but also detection and described touch or slide related persistent period and pressure.In certain embodiments, many matchmakers Body assembly 808 includes a front-facing camera and/or post-positioned pick-up head.When equipment 800 is in operator scheme, such as screening-mode or During video mode, front-facing camera and/or post-positioned pick-up head can receive outside multi-medium data.Each front-facing camera and Post-positioned pick-up head can be the optical lens system of a fixation or have focusing and optical zoom capabilities.
Audio-frequency assembly 810 is configured to output and/or input audio signal.For example, audio-frequency assembly 810 includes a Mike Wind (mic), when device 800 is in operator scheme, during as call model, logging mode and speech recognition mode, mike is joined It is set to reception external audio signal.The audio signal being received can be further stored in memorizer 804 or via communication set Part 816 sends.In certain embodiments, audio-frequency assembly 810 also includes a speaker, for exports audio signal.
, for providing interface between process assembly 802 and peripheral interface module, above-mentioned peripheral interface module can for i/o interface 812 To be keyboard, click wheel, button etc..These buttons may include but be not limited to: home button, volume button, start button and lock Determine button.
Sensor cluster 814 includes one or more sensors, for providing the state of various aspects to comment for device 800 Estimate.For example, sensor cluster 814 can detect/the OFF state of opening of equipment 800, and the relative localization of assembly is for example described Assembly is display and the keypad of device 800, and sensor cluster 814 can be with detection means 800 or 800 1 assemblies of device Position change, user is presence or absence of with what device 800 contacted, device 800 orientation or acceleration/deceleration and device 800 Temperature change.Sensor cluster 814 can include proximity transducer, is configured to the detection when not having any physical contact The presence of object nearby.Sensor cluster 814 can also include optical sensor, such as cmos or ccd imageing sensor, for becoming Use as in application.In certain embodiments, this sensor cluster 814 can also include acceleration transducer, gyro sensors Device, Magnetic Sensor, pressure transducer or temperature sensor.
Communication component 816 is configured to facilitate the communication of wired or wireless way between device 800 and other equipment.Device 800 can access the wireless network based on communication standard, such as wifi, 2g or 3g, or combinations thereof.In an exemplary enforcement In example, communication component 816 receives broadcast singal or the broadcast related information from external broadcasting management system via broadcast channel. In one exemplary embodiment, described communication component 816 also includes near-field communication (nfc) module, to promote junction service.Example As, RF identification (rfid) technology can be based in nfc module, Infrared Data Association (irda) technology, ultra broadband (uwb) technology, Bluetooth (bt) technology and other technologies are realizing.
In the exemplary embodiment, device 800 can be by one or more application specific integrated circuits (asic), numeral letter Number processor (dsp), digital signal processing appts (dspd), PLD (pld), field programmable gate array (fpga), controller, microcontroller, microprocessor or other electronic components are realized, for executing said method.
In the exemplary embodiment, a kind of non-transitorycomputer readable storage medium including instruction, example are additionally provided As included the memorizer 804 instructing, above-mentioned instruction can be executed by the processor 820 of device 800 to complete said method.For example, Described non-transitorycomputer readable storage medium can be rom, random access memory (ram), cd-rom, tape, floppy disk With optical data storage devices etc..
A kind of non-transitorycomputer readable storage medium, when the instruction in described storage medium is by the process of mobile terminal So that mobile terminal is able to carry out a kind of encryption method of file during device execution, methods described includes:
Obtain file to be encrypted;
Generate key, deviant and sampling value;
According to described deviant and described sampling value, determine the field to be encrypted in described file to be encrypted;
According to described key, described field to be encrypted is encrypted.
Wherein, described determine the field to be encrypted in described file to be encrypted according to described deviant with described sampling value, Including:
According to described deviant and sampling value, after being spaced described deviant in described file to be encrypted, by described sampling It is worth corresponding field, be defined as described field to be encrypted.
Wherein, after described generation key, deviant and sampling value, methods described also includes:
Described key, described deviant and described sampling value are write the file header of described file to be encrypted;
Described file header is encrypted.
Wherein, described described file header is encrypted, comprising:
Obtain and be stored in local public key corresponding with described file header;
Using described public key, described file header is encrypted.
Wherein, after described acquisition file to be encrypted, also include:
According to preset rules, the field of described file to be encrypted is rearranged.
Wherein, described file to be encrypted includes the first file to be encrypted and the second file to be encrypted;
The described field by described file to be encrypted rearranges, comprising:
By mobile for the described first file to be encrypted to described second file to be encrypted;Wherein, described first is to be added Ciphertext part is front preset length field in described file to be encrypted;Described second file to be encrypted is in described file to be encrypted Field in addition to the described first file to be encrypted.
Wherein, after described acquisition file to be encrypted, also include:
Identify file type or the file size of described file to be encrypted;
If described file type is video file or described file size is more than predetermined threshold value, generate described key, institute State deviant and described sampling value.
Wherein, the file header of described file to be encrypted includes thumbnail storage area.
A kind of non-transitorycomputer readable storage medium, when the instruction in described storage medium is by the process of mobile terminal So that mobile terminal is able to carry out a kind of decryption method of file during device execution, methods described includes:
Obtain encryption file;
Obtain key, deviant and sampling value;
According to described deviant and described sampling value, determine the encrypted fields in described encryption file;
According to described key, described encrypted fields are decrypted, obtain deciphering file.
Wherein, described according to described deviant with described sampling value, determine the encrypted fields in described encryption file, bag Include:
According to described deviant and described sampling value, after being spaced described deviant in described encryption file, take described The corresponding field of sample value, is defined as described encrypted fields.
Wherein, described acquisition key, deviant and sampling value, comprising:
The file header encrypting file according to private key pair is decrypted, the key in the described file header of acquisition, deviant And sampling value.
Wherein, if described file header include described encryption file cryptographic Hash, described according to described key to described After encrypted fields are decrypted, also include:
According to described cryptographic Hash, the described encrypted fields after deciphering are verified.
Wherein, described according to described key, described encrypted fields are decrypted, obtain deciphering file after, also include:
According to preset rules, the field of described deciphering file is rearranged.
Wherein, described deciphering file includes the first deciphering file and the second deciphering file;
The described field by described deciphering file rearranges, comprising:
By mobile for the described first deciphering file to described second deciphering file;Wherein, described first deciphering file For rear preset length field in described deciphering file;Described second deciphering file is except described first solution in described deciphering file Field beyond ciphertext part.
Wherein, after described acquisition encryption file, also include:
The file type of identification described encryption file or file size;
If described file type is video file or described file size is more than predetermined threshold value, obtain described key, institute State deviant and described sampling value.
Those skilled in the art, after considering description and putting into practice invention disclosed herein, will readily occur to its of the present invention Its embodiment.The application is intended to any modification, purposes or the adaptations of the present invention, these modifications, purposes or Person's adaptations are followed the general principle of the present invention and are included the undocumented common knowledge in the art of the disclosure Or conventional techniques.Description and embodiments are considered only as exemplary, and true scope and spirit of the invention are by following Claims are pointed out.
It is described above and precision architecture illustrated in the accompanying drawings it should be appreciated that the invention is not limited in, and And various modifications and changes can carried out without departing from the scope.The scope of the present invention only to be limited by appending claims System.

Claims (32)

1. a kind of encryption method of file is it is characterised in that include:
Obtain file to be encrypted;
Generate key, deviant and sampling value;
According to described deviant and described sampling value, determine the field to be encrypted in described file to be encrypted;
According to described key, described field to be encrypted is encrypted.
2. method according to claim 1 it is characterised in that described according to described deviant with described sampling value, determine Field to be encrypted in described file to be encrypted, comprising:
According to described deviant and sampling value, after being spaced described deviant in described file to be encrypted, by described sampling value pair The field answered, is defined as described field to be encrypted.
3. method according to claim 1 is it is characterised in that after described generation key, deviant and sampling value, described Method also includes:
Described key, described deviant and described sampling value are write the file header of described file to be encrypted;
Described file header is encrypted.
4. method according to claim 3 is it is characterised in that described be encrypted to described file header, comprising:
Obtain and be stored in local public key corresponding with described file header;
Using described public key, described file header is encrypted.
5. method according to claim 1 is it is characterised in that after described acquisition file to be encrypted, also include:
According to preset rules, the field of described file to be encrypted is rearranged.
6. method according to claim 5 is it is characterised in that described file to be encrypted includes the first file to be encrypted and Two files to be encrypted;
The described field by described file to be encrypted rearranges, comprising:
By mobile for the described first file to be encrypted to described second file to be encrypted;Wherein, described first ciphertext to be added Part is front preset length field in described file to be encrypted;Described second file to be encrypted is for removing institute in described file to be encrypted State the field beyond the first file to be encrypted.
7. method according to claim 1 is it is characterised in that after described acquisition file to be encrypted, also include:
Identify file type or the file size of described file to be encrypted;
If described file type is video file or described file size is more than predetermined threshold value, generate described key, described partially Shifting value and described sampling value.
8. the method according to claim 3 or 4 is it is characterised in that the file header of described file to be encrypted includes breviary Figure memory block.
9. a kind of decryption method of file is it is characterised in that include:
Obtain encryption file;
Obtain key, deviant and sampling value;
According to described deviant and described sampling value, determine the encrypted fields in described encryption file;
According to described key, described encrypted fields are decrypted, obtain deciphering file.
10. method according to claim 9 it is characterised in that described according to described deviant with described sampling value, determine Encrypted fields in described encryption file, comprising:
According to described deviant and described sampling value, after being spaced described deviant in described encryption file, by described sampling value Corresponding field, is defined as described encrypted fields.
11. methods according to claim 9 are it is characterised in that described acquisition key, deviant and sampling value, comprising:
The file header encrypting file according to private key pair is decrypted, and obtains the key in described file header, deviant and takes Sample value.
If 12. methods according to claim 11 are it is characterised in that described file header includes the Kazakhstan of described encryption file Uncommon value, then described according to described key, described encrypted fields are decrypted after, also include:
According to described cryptographic Hash, the described encrypted fields after deciphering are verified.
13. methods according to claim 9 are it is characterised in that described carried out to described encrypted fields according to described key Deciphering, after obtaining deciphering file, also includes:
According to preset rules, the field of described deciphering file is rearranged.
14. methods according to claim 13 are it is characterised in that described deciphering file includes the first deciphering file and second Deciphering file;
The described field by described deciphering file rearranges, comprising:
By mobile for the described first deciphering file to described second deciphering file;Wherein, described first deciphering file is institute Preset length field after stating in deciphering file;Described second deciphering file is except described first solution ciphertext in described deciphering file Field beyond part.
15. methods according to claim 9 are it is characterised in that after described acquisition encryption file, also include:
The file type of identification described encryption file or file size;
If described file type is video file or described file size is more than predetermined threshold value, obtain described key, described partially Shifting value and described sampling value.
A kind of 16. encryption devices of file are it is characterised in that include:
Acquisition module, is configured to obtain file to be encrypted;
First generation module, is configurable to generate key, deviant and sampling value;
Determining module, is configured to the described deviant according to described first generation module generation and described sampling value, determines institute State the field to be encrypted in file to be encrypted;
First encrypting module, is configured to, according to described key, the field described to be encrypted that described determining module is determined be entered Row encryption.
17. devices according to claim 16 are it is characterised in that described determining module includes:
Determination sub-module, is configured to, according to described deviant and sampling value, be spaced described skew in described file to be encrypted After value, by corresponding for described sampling value field, it is defined as described field to be encrypted.
18. devices according to claim 16 are it is characterised in that described device also includes:
Writing module, is configured to described key, described deviant and described sampling value write the literary composition of described file to be encrypted Part head;
Second encrypting module, is configured to described file header is encrypted.
19. devices according to claim 18 are it is characterised in that described second encrypting module includes:
Acquisition submodule, is configured to obtain and is stored in local public key corresponding with described file header;
Encryption submodule, is configured to using described public key, described file header is encrypted.
20. devices according to claim 16 are it is characterised in that described device also includes:
Processing module, is configured to, according to preset rules, the field of described file to be encrypted be rearranged.
21. devices according to claim 20 it is characterised in that described file to be encrypted include the first file to be encrypted and Second file to be encrypted;Described processing module includes:
Mobile submodule, is configured to mobile for the described first file to be encrypted to described second file to be encrypted;Its In, described first file to be encrypted is front preset length field in described file to be encrypted;Described second file to be encrypted is Field in addition to the described first file to be encrypted in described file to be encrypted.
22. devices according to claim 16 are it is characterised in that described device also includes:
Identification module, is configured to identify file type or the file size of described file to be encrypted;
Second generation module, is configured to identify that described file type is video file or described file in described identification module When size is more than predetermined threshold value, generate described key, described deviant and described sampling value.
23. devices according to claim 18 or 19 are it is characterised in that the file header of described file to be encrypted includes contracting Sketch map memory block.
A kind of deciphering device of 24. files is it is characterised in that include:
First acquisition module, is configured to obtain encryption file;
Second acquisition module, is configured to obtain key, deviant and sampling value;
Determining module, is configured to the described deviant according to described second acquisition module acquisition and described sampling value, determines institute State the encrypted fields in encryption file;
First deciphering module, is configured to according to described key, the described encrypted fields that described determining module is determined be solved Close, obtain deciphering file, obtain deciphering file.
25. devices according to claim 24 are it is characterised in that described determining module includes:
Determination sub-module, is configured to, according to described deviant and sampling value, be spaced described deviant in described encryption file Afterwards, by corresponding for described sampling value field, it is defined as described encrypted fields.
26. devices according to claim 24 are it is characterised in that described second acquisition module includes:
Acquisition submodule, the file header being configured to encrypt file according to private key pair is decrypted, and obtains described file header In key, deviant and sampling value.
27. devices according to claim 26 are it is characterised in that described device also includes:
Correction verification module, is configured to, according to cryptographic Hash, the described encrypted fields after deciphering be verified.
28. devices according to claim 24 are it is characterised in that described device also includes:
Processing module, is configured to, according to preset rules, the field of described deciphering file be rearranged.
29. devices according to claim 28 are it is characterised in that described deciphering file includes the first deciphering file and second Deciphering file;
Described processing module includes:
Mobile submodule, is configured to before the mobile extremely described second deciphering file of just described first deciphering file;Wherein, Described first deciphering file is rear preset length field in described deciphering file;Described second deciphering file is described solution ciphertext Field in addition to the described first deciphering file in part.
30. devices according to claim 24 are it is characterised in that described device also includes:
Identification module, is configured to identify file type or the file size of described encryption file;
3rd acquisition module, is configured to identify that described file type is video file or described file in described identification module When size is more than predetermined threshold value, obtain described key, described deviant and described sampling value.
A kind of 31. terminal units are it is characterised in that include:
Processor;
For storing the memorizer of processor executable;
Wherein, described processor is configured to:
Obtain file to be encrypted;
Generate key, deviant and sampling value;
According to described deviant and described sampling value, determine the field to be encrypted in described file to be encrypted;According to described key, Described field to be encrypted is encrypted.
A kind of 32. terminal units are it is characterised in that include:
Processor;
For storing the memorizer of processor executable;
Wherein, described processor is configured to:
Obtain encryption file;
Obtain key, deviant and sampling value;
According to described deviant and described sampling value, determine the encrypted fields in described encryption file;According to described key to institute State encrypted fields to be decrypted, obtain deciphering file.
CN201610772530.7A 2016-08-30 2016-08-30 File encryption method, file decryption method, file encryption device and equipment Pending CN106372517A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610772530.7A CN106372517A (en) 2016-08-30 2016-08-30 File encryption method, file decryption method, file encryption device and equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610772530.7A CN106372517A (en) 2016-08-30 2016-08-30 File encryption method, file decryption method, file encryption device and equipment

Publications (1)

Publication Number Publication Date
CN106372517A true CN106372517A (en) 2017-02-01

Family

ID=57902076

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610772530.7A Pending CN106372517A (en) 2016-08-30 2016-08-30 File encryption method, file decryption method, file encryption device and equipment

Country Status (1)

Country Link
CN (1) CN106372517A (en)

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107147616A (en) * 2017-03-31 2017-09-08 武汉斗鱼网络科技有限公司 Data ciphering method and device
CN110022558A (en) * 2019-04-03 2019-07-16 Oppo广东移动通信有限公司 The encryption and decryption method and electronic device and storage medium of a kind of upgrade package
CN110650119A (en) * 2019-08-20 2020-01-03 阿里巴巴集团控股有限公司 Data transmission method and device and electronic equipment
CN111767529A (en) * 2020-05-18 2020-10-13 广州视源电子科技股份有限公司 File encryption method, file decryption method, storage medium and electronic device
WO2021031828A1 (en) * 2019-08-20 2021-02-25 创新先进技术有限公司 Data transmission method, device and electronic apparatus
CN115438358A (en) * 2022-09-05 2022-12-06 长江量子(武汉)科技有限公司 Controlled file encryption method and electronic equipment
CN115580474A (en) * 2022-10-17 2023-01-06 南京网藤科技有限公司 File encryption method and device followed by secret key
CN116150786A (en) * 2023-01-10 2023-05-23 深圳技术大学 USB flash disk file encryption system based on instruction key self-setting

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101141814A (en) * 2007-10-11 2008-03-12 中兴通讯股份有限公司 System and method for mobile terminal to download DRM file to movable storage medium
CN101350047A (en) * 2008-08-12 2009-01-21 无敌科技(西安)有限公司 Method for ciphering and deciphering embedded type multimedia file
CN101800811A (en) * 2010-02-02 2010-08-11 中国软件与技术服务股份有限公司 Mobile phone data security protection method
CN102254127A (en) * 2011-08-11 2011-11-23 华为技术有限公司 Method, device and system for encrypting and decrypting files
CN102456116A (en) * 2010-10-28 2012-05-16 无锡江南计算技术研究所 File encryption method, file decryption method and devices
CN103294961A (en) * 2013-06-07 2013-09-11 北京奇虎科技有限公司 Method and device for file encrypting/decrypting
US20140105390A1 (en) * 2012-08-30 2014-04-17 Tencent Technology (Shenzhen), Co., Ltd. Video file encryption and decryption method, device, and mobile terminal

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101141814A (en) * 2007-10-11 2008-03-12 中兴通讯股份有限公司 System and method for mobile terminal to download DRM file to movable storage medium
CN101350047A (en) * 2008-08-12 2009-01-21 无敌科技(西安)有限公司 Method for ciphering and deciphering embedded type multimedia file
CN101800811A (en) * 2010-02-02 2010-08-11 中国软件与技术服务股份有限公司 Mobile phone data security protection method
CN102456116A (en) * 2010-10-28 2012-05-16 无锡江南计算技术研究所 File encryption method, file decryption method and devices
CN102254127A (en) * 2011-08-11 2011-11-23 华为技术有限公司 Method, device and system for encrypting and decrypting files
US20140105390A1 (en) * 2012-08-30 2014-04-17 Tencent Technology (Shenzhen), Co., Ltd. Video file encryption and decryption method, device, and mobile terminal
CN103294961A (en) * 2013-06-07 2013-09-11 北京奇虎科技有限公司 Method and device for file encrypting/decrypting

Cited By (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107147616B (en) * 2017-03-31 2019-09-10 武汉斗鱼网络科技有限公司 Data ciphering method and device
CN107147616A (en) * 2017-03-31 2017-09-08 武汉斗鱼网络科技有限公司 Data ciphering method and device
CN110022558B (en) * 2019-04-03 2023-01-31 Oppo广东移动通信有限公司 Method for encrypting and decrypting upgrade package, electronic device and storage medium
CN110022558A (en) * 2019-04-03 2019-07-16 Oppo广东移动通信有限公司 The encryption and decryption method and electronic device and storage medium of a kind of upgrade package
CN110650119A (en) * 2019-08-20 2020-01-03 阿里巴巴集团控股有限公司 Data transmission method and device and electronic equipment
WO2021031828A1 (en) * 2019-08-20 2021-02-25 创新先进技术有限公司 Data transmission method, device and electronic apparatus
CN110650119B (en) * 2019-08-20 2022-01-21 创新先进技术有限公司 Data transmission method and device and electronic equipment
CN111767529A (en) * 2020-05-18 2020-10-13 广州视源电子科技股份有限公司 File encryption method, file decryption method, storage medium and electronic device
CN115438358A (en) * 2022-09-05 2022-12-06 长江量子(武汉)科技有限公司 Controlled file encryption method and electronic equipment
CN115438358B (en) * 2022-09-05 2023-07-14 长江量子(武汉)科技有限公司 Controlled file encryption method and electronic equipment
CN115580474A (en) * 2022-10-17 2023-01-06 南京网藤科技有限公司 File encryption method and device followed by secret key
CN115580474B (en) * 2022-10-17 2023-10-31 南京网藤科技有限公司 Method and device for encrypting file with key following function
CN116150786A (en) * 2023-01-10 2023-05-23 深圳技术大学 USB flash disk file encryption system based on instruction key self-setting
CN116150786B (en) * 2023-01-10 2023-11-28 深圳技术大学 USB flash disk file encryption system based on instruction key self-setting

Similar Documents

Publication Publication Date Title
CN106372517A (en) File encryption method, file decryption method, file encryption device and equipment
CN104125055B (en) Encryption and decryption method and electronic equipment
CN103916233B (en) A kind of information ciphering method and device
CN104168277A (en) File security maintaining method and device
CN103914634A (en) Image encryption method, image encryption device and electronic device
CN103914541B (en) The method and device of information search
CN104318177A (en) Protection method and protection device for data of terminal equipment
CN104573550A (en) Method and device for protecting data
JP6101863B2 (en) Information transmission method, apparatus, program, and recording medium for voice service
CN106453052A (en) Message interaction method and apparatus thereof
WO2020259026A1 (en) Access control method and apparatus, and electronic device and storage medium
CN106534876A (en) Target user determining method and target user determining device
CN105306716A (en) Data processing method, device and system
CN105893854B (en) Encryption and decryption method and device
CN106127062A (en) unlocking method and device
CN107682538A (en) The display methods and device of application interface
CN105450662A (en) Encryption method and device
CN106778225A (en) The method and apparatus for processing password
CN104182697B (en) File encrypting method and device
CN106126986A (en) Lock unlocking processing method and the device of data partition
CN105681365B (en) Method and apparatus for file transmission
CN106789070A (en) The decryption method of data, device and terminal
CN106611112A (en) Application program safe processing method, device and equipment
CN105046127A (en) Encryption and decryption method and apparatus
CN105120452A (en) Information transmission method, device and system

Legal Events

Date Code Title Description
C06 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

Application publication date: 20170201

RJ01 Rejection of invention patent application after publication