Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. The components of embodiments of the present invention generally described and illustrated in the figures herein may be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the present invention, presented in the figures, is not intended to limit the scope of the invention, as claimed, but is merely representative of selected embodiments of the invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments of the present invention without making any creative effort, shall fall within the protection scope of the present invention.
It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures. Meanwhile, in the description of the present invention, the terms "first", "second", and the like are used only for distinguishing the description, and are not to be construed as indicating or implying relative importance.
Referring to fig. 1, fig. 1 is a block diagram illustrating anelectronic device 100 applicable to an embodiment of the present application. Theelectronic device 100 may include a data encryption device or a data decryption device, a memory 101, a memory controller 102, aprocessor 103, aperipheral interface 104, an input-output unit 105, anaudio unit 106, and adisplay unit 107.
The memory 101, the memory controller 102, theprocessor 103, theperipheral interface 104, the input/output unit 105, theaudio unit 106, and thedisplay unit 107 are electrically connected to each other directly or indirectly to realize data transmission or interaction. For example, the components may be electrically connected to each other via one or more communication buses or signal lines. The data encryption device or the data decryption device includes at least one software function module that may be stored in the memory 101 in the form of software or firmware (firmware) or solidified in an Operating System (OS) of the data encryption device or the data decryption device. Theprocessor 103 is configured to execute an executable module stored in the memory 101, such as a software functional module or a computer program included in the data encryption apparatus or the data decryption apparatus.
The Memory 101 may be, but is not limited to, a Random Access Memory (RAM), a Read Only Memory (ROM), a Programmable Read-Only Memory (PROM), an Erasable Read-Only Memory (EPROM), an electrically Erasable Read-Only Memory (EEPROM), and the like. The memory 101 is configured to store a program, and theprocessor 103 executes the program after receiving an execution instruction, and the method executed by the server defined by the flow process disclosed in any of the foregoing embodiments of the present invention may be applied to theprocessor 103, or implemented by theprocessor 103.
Theprocessor 103 may be an integrated circuit chip having signal processing capabilities. TheProcessor 103 may be a general-purpose Processor, and includes a Central Processing Unit (CPU), a Network Processor (NP), and the like; but may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic, discrete hardware components. The various methods, steps and logic blocks disclosed in the embodiments of the present invention may be implemented or performed. A general purpose processor may be a microprocessor or theprocessor 103 may be any conventional processor or the like.
Theperipheral interface 104 couples various input/output devices to theprocessor 103 as well as to the memory 101. In some embodiments, theperipheral interface 104, theprocessor 103, and the memory controller 102 may be implemented in a single chip. In other examples, they may be implemented separately from the individual chips.
The input and output unit 105 is used for providing input data for a user to realize the interaction of the user and the server (or the local terminal). The input/output unit 105 may be, but is not limited to, a mouse, a keyboard, and the like.
Audio unit 106 provides an audio interface to a user, which may include one or more microphones, one or more speakers, and audio circuitry.
Thedisplay unit 107 provides an interactive interface (e.g., a user interface) between theelectronic device 100 and a user or for displaying image data to a user reference. In this embodiment, thedisplay unit 107 may be a liquid crystal display or a touch display. In the case of a touch display, the display can be a capacitive touch screen or a resistive touch screen, which supports single-point and multi-point touch operations. Supporting single-point and multi-point touch operations means that the touch display can sense touch operations simultaneously generated from one or more positions on the touch display, and the sensed touch operations are sent to theprocessor 103 for calculation and processing.
Theperipheral interface 104 couples various input/output devices to theprocessor 103 as well as to the memory 101. In some embodiments, theperipheral interface 104, theprocessor 103, and the memory controller 102 may be implemented in a single chip. In other examples, they may be implemented separately from the individual chips.
The input and output unit 105 is used for providing input data for a user to realize the interaction of the user and the processing terminal. The input/output unit 105 may be, but is not limited to, a mouse, a keyboard, and the like.
Referring to fig. 2, fig. 2 is a flowchart of a data encryption method according to an embodiment of the present invention, where the method specifically includes the following steps:
step S110: an iris image of the user is acquired.
As an implementation mode, the iris camera can be used for acquiring the iris image of the user, and the iris camera adopts an optical anti-shaking iris camera which can accurately acquire the iris image of the user in both eyes or one eye. In addition, a CCD camera or other image acquisition devices can be adopted to acquire the iris image of the user.
Step S120: and generating an iris characteristic sequence according to the iris image.
Because the original iris image generally acquired by a camera or an image acquisition device usually does not only include the iris, and often includes other parts of the eye, such as eyelids, eyelashes, white eyes, etc., before generating the iris feature sequence, after the positions of the irises in the image are determined and the size normalization is performed, the normalization aims to adjust the acquired original iris image to the same size and corresponding position, so as to eliminate the influence of translation, scaling and rotation on iris recognition, perform iris recognition on the obtained normalized iris image, that is, perform iris image preprocessing, to obtain a processed pure iris image, and generate the iris feature sequence from the processed iris image.
As an embodiment, the method for generating an iris feature sequence may detect an iris boundary in a processed iris image, map pixels representing the iris in the iris image to a rectangular image according to the iris boundary, filter the pixels in the rectangular image to generate a filtered output, where the filtering may be performed by using a sum and difference filter, and then binarize the filtered output to generate a feature vector representing the iris image, that is, obtain the iris feature sequence.
In addition, the method for generating the iris feature sequence can also adopt a fuzzy algorithm or a fuzzy extractor for generation, and can also adopt a Haar wavelet three-layer decomposition method, a random extractor extraction method and other methods for generation, and the specific algorithm process is not described herein again.
Alternatively, the iris feature sequence may be generated in other ways, such as multi-channel filtering, two-dimensional wavelet transform, etc.
Step S130: and acquiring a file to be encrypted.
Acquiring file data needing to be encrypted, namely a file to be encrypted.
Step S140: and generating a file characteristic sequence according to the file to be encrypted.
After the file to be encrypted is obtained, the file to be encrypted needs to be generated into a file feature sequence, as an implementation manner, the generation method may be a hash algorithm, and the algorithm process is not described in detail herein. The generated file feature sequence uniquely corresponds to a file to be encrypted, so that keys generated correspondingly to different files are different, the key cannot be stolen easily, the security of the key is improved, and the security of data is ensured.
In addition, as an embodiment, in order to achieve the rapidity and efficiency of generating the file feature sequence, partial data may be acquired from the file to be encrypted to be used as feature sequence generation data, and then the file feature sequence corresponding to the file to be encrypted is generated based on the feature sequence generation data, and the file feature sequence may uniquely identify the file to be encrypted.
Step S150: and generating a secret key according to the file characteristic sequence and the iris characteristic sequence.
Through the acquired file feature sequence and the iris feature sequence, a key can be generated, and the method for generating the key here can also be generated by using a fuzzy algorithm or a fuzzy extractor in step S110.
Step S160: and encrypting the file to be encrypted based on the key.
After the key is generated, the file to be encrypted needs to be encrypted by using the key, and the encryption method can adopt a cryptographic algorithm (SM1, SM2, SM3, SM4, SM7) and the like.
After step S160, in order to perform file feature sequence extraction in the decryption process, the data encryption method may further include:
step S170: and generating an encrypted data packet according to the file characteristic sequence and the encrypted file to be encrypted.
In order to extract the file feature sequence in the decryption process, the file feature sequence and the encrypted file to be encrypted may be generated into an encrypted data packet. In addition, since only the file feature sequence needs to be extracted in advance in the decryption process, only the file feature sequence may be generated into the encrypted data packet, or the file feature sequence may be encrypted to generate the encrypted data packet.
After an iris image of a user is obtained, an iris feature sequence is generated according to the iris image, a file to be encrypted is obtained, a file feature sequence is generated according to the file to be encrypted, a secret key is generated according to the file feature sequence and the iris feature sequence, the file to be encrypted is encrypted based on the secret key, the file to be encrypted is encrypted, and then an encrypted data packet can be generated from the file feature sequence or the encrypted file to be encrypted in order to facilitate extraction of the file feature sequence in a decryption process.
Referring to fig. 3, fig. 3 is a flowchart of a data decryption method according to an embodiment of the present invention, where the method specifically includes the following steps:
step S210: an iris image of the user is acquired.
The method includes the steps of obtaining a file to be decrypted after an original file is encrypted, obtaining an iris image of a user first if the file to be decrypted is to be decrypted, obtaining the iris image in the step can also be obtained through an iris camera, and referring to step S110 for the specific implementation method, so that redundant description is omitted for simplicity of description.
Step S220: and generating an iris characteristic sequence according to the iris image.
The method for generating the iris feature sequence from the iris image in this step is the same as the method for generating the iris feature sequence in step S120, i.e., the iris feature sequence can be generated by a fuzzy algorithm or a fuzzy extractor, or can be generated by a Haar wavelet three-layer decomposition method, a random extractor extraction method and other methods, and please refer to step S120 for a specific implementation method.
Step S230: the method comprises the steps of obtaining an encrypted data packet corresponding to a file to be decrypted, wherein the encrypted data packet is generated in the process of encrypting an original file to obtain the file to be decrypted, and the encrypted data comprises a file feature sequence of the original file.
The encrypted data packet is actually the encrypted data packet generated in step S170, that is, the encrypted data packet is generated for the file feature sequence of the original file, or the encrypted data packet is generated for the encrypted original file, that is, the file to be decrypted and the file feature sequence.
Step S240: and acquiring the file characteristic sequence from the encrypted data packet.
After the encrypted data packet is obtained, the file feature sequence of the original file can be extracted from the encrypted data packet, and if the file feature sequence is the encrypted file feature sequence, the file feature sequence of the original file can be obtained only after the encrypted file feature sequence is decrypted.
Step S250: and generating a secret key according to the file characteristic sequence and the iris characteristic sequence.
And generating a key through the acquired file feature sequence and the iris feature sequence, wherein the key generation method can also adopt a fuzzy algorithm or a fuzzy extractor for generation.
Step S260: and decrypting the file to be decrypted according to the key.
And after the key is obtained, decrypting the file to be decrypted according to the key, wherein if the key generated in the step S250 is not consistent with the key generated in the encryption process, the file to be decrypted cannot be decrypted, and if the key generated in the step S250 is consistent with the key generated in the encryption process, the file to be decrypted can be decrypted into an original file. The decryption algorithm here may employ cryptographic algorithms (SM1, SM2, SM3, SM4, SM7) and the like.
After an iris image of a user is obtained, an iris characteristic sequence is generated according to the iris image, an encrypted data packet corresponding to a file to be decrypted is obtained, the encrypted data packet is generated in the process of encrypting an original file to obtain the file to be decrypted, the encrypted data comprises a file characteristic sequence of the original file, the file characteristic sequence is obtained from the encrypted data packet, a secret key is generated according to the file characteristic sequence and the iris characteristic sequence, the file to be decrypted is decrypted according to the secret key, the data decryption method is that the file characteristic sequence generated by the original file is obtained, the secret key is generated according to the file characteristic sequence and the iris characteristic sequence of the user, whether the secret key is consistent with the secret key generated in the data encryption method is compared, if so, the file to be decrypted can be decrypted, if the two are not consistent, decryption cannot be performed, and therefore key security and data security are improved.
Referring to fig. 4, fig. 4 is a block diagram of a data encryption apparatus 200 according to an embodiment of the present invention, the apparatus is configured to perform the data encryption method, and the apparatus includes:
animage obtaining module 210, configured to obtain an iris image of the user.
Afirst generating module 220, configured to generate an iris feature sequence according to the iris image.
Thefile obtaining module 230 is configured to obtain a file to be encrypted.
And asecond generating module 240, configured to generate a file feature sequence according to the file to be encrypted.
And akey generating module 250, configured to generate a key according to the file feature sequence and the iris feature sequence.
And theencryption module 260 is configured to encrypt the file to be encrypted based on the key.
Wherein thesecond generating module 240 comprises:
and the partial data acquisition submodule is used for acquiring partial data from the file to be encrypted as the characteristic sequence generation data.
And the sequence generation submodule is used for generating a file characteristic sequence based on the characteristic sequence generation data.
As an embodiment, the apparatus may further include:
and the third generation module is used for generating an encrypted data packet according to the file characteristic sequence and the encrypted file to be encrypted.
Alternatively, the apparatus may further include:
and the sequence encryption module is used for encrypting the file characteristic sequence.
And the data packet generating module is used for generating an encrypted data packet according to the encrypted file characteristic sequence and the encrypted file to be encrypted.
Referring to fig. 5, fig. 5 is a block diagram of adata decryption apparatus 300 according to an embodiment of the present invention, the apparatus is configured to execute the data decryption method described above, and the apparatus specifically includes:
the first obtainingmodule 310 is configured to obtain an iris image of a user.
A featuresequence generating module 320, configured to generate an iris feature sequence according to the iris image.
The second obtainingmodule 330 is configured to obtain an encrypted data packet corresponding to a file to be decrypted, where the encrypted data packet is generated in a process of encrypting an original file to obtain the file to be decrypted, and the encrypted data includes a file feature sequence of the original file.
A third obtainingmodule 340, configured to obtain the file feature sequence from the encrypted data packet.
Agenerating module 350, configured to generate a key according to the file feature sequence and the iris feature sequence.
And thedecryption module 360 is configured to decrypt the file to be decrypted according to the key.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working process of the apparatus described above may refer to the corresponding process in the foregoing method, and will not be described in too much detail herein.
In summary, embodiments of the present invention provide a method and an apparatus for encrypting and decrypting data, where an iris image of a user is first obtained, an iris feature sequence is generated according to the iris image, a file to be encrypted is then obtained, a file feature sequence is generated according to the file to be encrypted, a key is then generated according to the file feature sequence and the iris feature sequence, the file to be encrypted is encrypted based on the key, and different keys are generated for different files to be encrypted according to the file feature sequence and the iris feature sequence by using the file feature sequence and the iris feature sequence generated by the file to be encrypted, so that key security and data security are improved.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method can be implemented in other ways. The apparatus embodiments described above are merely illustrative, and for example, the flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
In addition, the functional modules in the embodiments of the present invention may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
The functions, if implemented in the form of software functional modules and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes. It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention. It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures.
The above description is only for the specific embodiments of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present invention, and all the changes or substitutions should be covered within the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.