The invention generally relates to the technical field of information processing and, particularly, to a method and system for compressing and encrypting data.
Now, a large number of information data are transmitted at information nodes. For a virtual private network (abbreviated to VPN), when persons have access to an internal resource at their working place over the Internet from the outside, it is usually required to compress and encrypt data, such that a data flow quantity can be decreased, a network rate can be increased, and a network congestion can be reduced by means of compression, and a security can be enhanced, and a leakage of working data and personal data can be avoided by means of encryption. For another example, in a cloud storage environment, since a storage device for the cloud storage is usually used by many persons, it is necessary for the data to be encrypted. In order to reduce the data flow quantity, before the data are stored on a network storage server, a user may first compress then encrypt the data such that the security is improved while an occupied magnetic disk space is reduced. Additionally, a general network transmission with a security requirement and a certain bandwidth requirement also demands the compression and encryption. That is to say, an application scenario of data compression to reduce the data flow quantity and data encryption to ensure the privacy thereof at the same time is very wide.
Current compression and encryption algorithms have defects of a long time of compression and encryption, and a low efficiency.
Therefore, there is a need for a method and system for compressing and encrypting data with a higher efficiency.
In one aspect, the present invention provides a method for compressing and encrypting data, comprising: receiving original data; performing a first compression of said original data to obtain a first compression result; and encrypting only a literal portion in the first compression result to obtain an encrypted first compression result.
In another aspect, the present invention provides a system for compressing and encrypting data, comprising: a receiving means configured to receive original data; a first compressing means configured to perform a first compression of said original data to obtain a first compression result; and an encrypting means configured to encrypt only a literal portion in the first compression result to obtain an encrypted first compression result.
Embodiments of the present invention improve the efficiency of the process of compression + encryption to a great extent by means of encrypting only the literal portion of the compression result.
In order to explain features and advantages of the present invention in detail, we will make reference to the following drawings. If possible, the same or similar reference numbers are used in the drawings and the description to denote the same or similar parts, wherein:
Now the description will be made in detail with reference to exemplary embodiments of the present invention. Examples of said embodiments are illustrated in the appended drawings, throughout which the like reference numbers denote the like elements. It should be understood that the present invention is not limited to the disclosed exemplary embodiments. It should also be understood that not every feature of said method and device is necessary for implementing the present invention claimed by any claim. Further, in the entire disclosure, when a process or method is shown or described, steps of the method may be performed in any order or simultaneously, unless it is apparent from the context that one step depends on another step performed previously. Further, there may be a significant time interval between steps.
When studying to solve the defects of the existing compression and encryption technique, the applicant has findings as shown in
Based on the above data analysis findings, the applicant proposes a first embodiment of a method for compressing and encrypting data of the present invention, as shown in
1. The first compression stage: In this stage, original data comprising text data are received, and the original data are compressed by employing the LZ77 compression algorithm. After being subject to the LZ77 compression algorithm, the original data are formed to a first compression result as shown in
2. The encryption stage: In this stage, any existing suitable text encryption algorithm is used to encrypt only the literal portions of L1, L2, L3 . . . . Since the distance and the length in the tuple do not contain information on the original text, and restoration of the original file depends on the literal portion, encrypting only the literal portion can not lower the encryption level. After undergoing the first compression and the encryption, the original data are changed into C1, C2, (tuple1), (tuple2), C3 . . . , wherein C1, C2, C3 . . . are the compression results corresponding to the literal portions of L1, L2, L3 . . . , respectively. As only the literal portions amounting for about 30% are encrypted and the rest tuples portions amounting for nearly 70% are not encrypted at the encryption stage, the present embodiment saves about 70% of the encryption time, thus the encryption efficiency is increased to a large extent.
When a specific encryption algorithm is performed, if a flow encryption algorithm, for example the RC4, is adopted, it will be directly applied to the embodiment. If a block encryption algorithm, for example the AES/DES, or the RSA/ECC, is adopted, it is required that the original data are inputted in a block format, that is, the unit of data encryption must be a fixed length (except for a last block of the entire file to be encrypted), such as 16 bytes, 32 bytes and the like. Therefore, in the method, since the literal portion is generated discretely, with respect to the block encryption method, a source block buffer is used to buffer the literal portion in said first compression result, and a target block buffer is used to buffer the encryption result of said literal portion. When the source block buffer is full, the encryption can be performed, and the encryption result is written in the target block buffer, otherwise it is required to wait until subsequent text data arrive. Physically, the source block buffer and the target block buffer may share one buffer. With respect to the flow encryption algorithm, each byte thereof may be encrypted immediately after the literal data are generated, and outputted to the position of the literal data in the first compression result. With respect to the block encryption algorithm, the literal data are buffered in a source data buffer when being generated, and when a content of the buffer reaches a size of the block required by the encryption algorithm, for example, 32 bytes, the block is encrypted to generate new encrypted data having a size of 32 bytes, each of which is outputted to the position of the literal data in the first compression result simultaneously.
3. The second compression stage (optional): On the basis of the encrypted data obtained at the encryption stage, a second compression of at least part of the encrypted data is performed by using the Huffman coding to obtain final data for transmission, such that the quantity of the original data is further reduced. Undergoing the foresaid process of compression + encryption + at least part of compression, the original data can be used for a security transmission, and the flow quantity of data to be transmitted is decreased to a great extent.
The invention is adapted to be applied in various application scenarios necessary for the compression + encryption, such as a cloud storage, the VPN, and so forth.
As shown in
Preferably, a second compressing means 707 is further included and configured to perform a second compression of at least part of the encrypted first compression result to obtain a second compression result.
Preferably, the first compression employs a LZ77 compression algorithm.
Preferably, in the case of employing a block encryption algorithm, a source block buffer is further included and configured to buffer the literal portion in said first compression result, and a target block buffer is included and configured to buffer the encryption result of said literal portion.
Preferably, the algorithm employed by said encryption includes at least one of an RC4 flow encryption algorithm, an AES block encryption algorithm, and an RSA block encryption algorithm.
Preferably, said literal portion is at least one of text data and binary data.
Preferably, the system is applied in at least one of a cloud storage or a virtual private network.
A function of each component in
Although the computer system illustrated in
Herein, while the exemplary embodiments of the present invention are described with reference to the appended drawings, it should be understood that the present invention is not limited to these accurate embodiments, and those skilled in the art can make a variety of changes and modifications to the embodiments without departing from the scope and spirit of the present invention. All these changes and modifications are intended to be included within the scope of the present invention defined by the appended claims.
According to above description, those skilled in the art know the present invention may be embodied as an apparatus, method or computer program product. Accordingly, the present invention may be embodied in following forms, that is, may be an entire hardware, an entire software (including firmware, resident software, microcode, etc.), or a combination of a software component and a hardware component, which are generally referred to herein as “circuit”, “module” or “system”. In addition, the present invention may also take the form of a computer program product embodied in any tangible medium of expression having a computer usable program code in the medium.
Any combination of one or more computer-usable or computer-readable medium(s) can be used. The computer-usable or computer-readable medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared or semiconductor system, apparatus, device or propagation medium. More specific examples (a non-exhaustive list) of the computer-readable medium include the following: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a transmission media such as those supporting the Internet or an intranet, or a magnetic storage device. Note that the computer-usable or computer-readable medium could even be paper or another suitable medium upon which the program is printed, as the program can be electronically captured, via, for instance, electrical scanning of the paper or other medium, then compiled, interpreted, or processed in a suitable manner, and stored in a computer memory if necessary. In the context of this document, a computer-usable or computer-readable medium may be any medium that can contain, store, communicate, propagate, or transport the program for use by or in connection with the instruction execution system, apparatus, or device. The computer-usable medium may include a propagated data signal with the computer-usable program code embedded therewith, either in baseband or as part of a carrier wave. The computer-usable program code may be transmitted using any suitable medium, including, but not limited to, wireless, wireline, optical fiber cable, RF, etc.
Computer program code for carrying out operations of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C++ or the like and conventional procedural programming languages, such as the “C” programming language or similar programming languages. The program code may execute entirely on a user's computer, partly on a user's computer, as a stand-alone software package, partly on a user's computer and partly on a remote computer or entirely on a remote computer or server. In the latter scenario, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN), or a wide area network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet Service Provider).
Further, in the present invention, each block of the flowcharts and/or block diagrams and combinations of blocks in the flowcharts and/or block diagrams, can be both performed by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus, thereby producing a machine, such that the instructions, which execute by the computer or the other programmable data processing apparatus, create means for performing the functions/operations specified in the block or blocks in the flowcharts and/or block diagrams.
These computer program instructions may also be stored in a computer-readable medium that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable medium produce an article of manufacture including instruction means performing the functions/operations specified in the block or blocks in the flowcharts and/or block diagrams.
The computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operation steps to be performed on the computer or other programmable data processing apparatus to generate a computer performed process such that the instructions which execute on the computer or other programmable data processing apparatus provide processes for performing the functions/operations specified in the block or blocks in the flowcharts and/or block diagrams.
The flowcharts and block diagrams in the drawings illustrate the architecture, functionality and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowcharts or block diagrams may represent a modular, program segment, or part of code, which comprises one or more executable instructions for performing the specified logic function(s). It should also be noted that, in some alterative implementations, the functions noted in the block may also occur in an order other than that noted in the drawings. For example, two blocks consecutively shown may, in fact, be performed substantially in parallel, or sometimes they may be performed in a reverse order, depending upon the functionality involved. It will also be noted that, each block of the block diagrams and/or flowcharts and combinations of blocks in the block diagrams and/or flowcharts, can be performed by using a special purpose hardware-based system that executes the specified functions or operations, or by using a combination of a special purpose hardware and computer instructions.
Number | Date | Country | Kind |
---|---|---|---|
2011 101022963.5 | May 2011 | CN | national |
This application is a continuation of U.S. patent application Ser. No. 13/469,396, filed May 11, 2012, which claims the benefit of the priority filing date of commonly-owned, co-pending Chinese Patent Application No. CN 2011 101022963.5, filed on May 12, 2011, the entire contents and disclosure of which is incorporated by reference as if fully set forth herein.
Number | Date | Country | |
---|---|---|---|
Parent | 13469396 | May 2012 | US |
Child | 13612362 | US |