Detailed Description
The following description of the embodiments of the present invention will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are some, but not all embodiments of the invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
It should be understood that the terms "comprises" and "comprising," when used in this specification and the appended claims, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
It is also to be understood that the terminology used in the description of the invention herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. As used in this specification and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.
It should be further understood that the term "and/or" as used in the present specification and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes such combinations.
Referring to fig. 1, fig. 1 is a flow chart of an information encryption method based on pseudo random numbers according to an embodiment of the invention; the information encryption method based on the pseudo-random number is applied to a user terminal or a management server, the information encryption method based on the pseudo-random number is executed through application software installed in the user terminal or the management server, the user terminal can receive information to be encrypted input by a user and obtain encrypted data information after transposition encryption, and the user terminal can be terminal equipment such as a desktop computer, a notebook computer, a tablet computer or a mobile phone; the management server can receive the information to be encrypted from the user terminal, obtain encrypted data information after transposition encryption and feed the encrypted data information back to the server side of the user terminal, such as a server side built in an enterprise or government department. As shown in fig. 1, the method includes steps S110 to S130.
S110, if the input information to be encrypted is received, an encryption seed is randomly generated.
If the input information to be encrypted is received, randomly generating an encryption seed; the encryption seed includes a encryption base and a pseudorandom number corresponding to the encryption base. Specifically, the input information to be encrypted can be received, the information to be encrypted can be character information, the information to be encrypted can also be files such as pictures or documents, and the corresponding character information can be obtained after the files such as pictures or documents are analyzed. The management server may randomly generate an encryption seed, wherein the encryption seed includes an encryption base and a pseudorandom number corresponding to the encryption base. The encryption base can be 1bit, 2bit, 4bit, 8bit … …, etc., 1bit is a character digit, the encryption base is 4bit and corresponds to four character digits, and the numerical digits contained in the pseudo random number are equal to the digit of the encryption base. Specifically, in the process of generating the encryption seed, one of the numbers can be randomly selected as a corresponding encryption base, a pseudo-random number with corresponding numerical digits is generated according to the randomly selected encryption base, each numerical value in the pseudo-random number is randomly generated, and the numerical value of the pseudo-random number can be an integer (an integer corresponding to a decimal number) within [0,9 ]; alternatively, the value may be an integer (integer corresponding to hexadecimal number) within [0,F ].
For example, if the randomly selected encryption base is 4 bits, correspondingly generating a pseudo random number containing 4 values, and randomly generating the 4 values in the pseudo random number at the moment; if the randomly selected encryption base is 8 bits, correspondingly generating a pseudo random number containing 8 values, and randomly generating the 8 values in the pseudo random number at the moment.
And S120, sequentially reading basic data corresponding to the encryption base from the information to be encrypted, and performing transposition encryption on the basic data according to the pseudo random number to obtain corresponding ciphertext data.
And sequentially reading basic data corresponding to the encryption base from the information to be encrypted, and performing transposition encryption on the basic data according to the pseudo-random number to obtain corresponding ciphertext data. And sequentially reading basic data corresponding to the encryption base from the information to be encrypted, wherein each basic data is equal to the bit number of the encryption base, and transposition encryption is carried out on the basic data through pseudo random numbers, so that ciphertext data corresponding to each basic data is obtained. The basic data is subjected to transposition encryption through the pseudo random number, so that the complexity of encryption operation can be greatly reduced, and the time consumption of the encryption process is shortened compared with the traditional encryption method.
In a specific embodiment, as shown in fig. 2, step S120 includes substeps S121, S122, S123, and S124.
S121, judging whether the information to be encrypted contains unencrypted data.
S122, if the information to be encrypted contains unencrypted data, sequentially reading basic data corresponding to the encryption base from the information to be encrypted.
In a specific process, whether the information to be encrypted contains unencrypted data can be judged first, if the information to be encrypted contains unencrypted data, basic data corresponding to the encryption base number are sequentially read from the information to be encrypted, and the number of bits of the basic data read each time is equal to the number of bits of the encryption base number.
S123, generating a corresponding transposition number according to the pseudo random number.
And generating a corresponding bit conversion number according to the pseudo random number. In the specific application process, the pseudo random number can be directly used as a transposition number; or generating a corresponding transposition number according to the pseudo-random number and the acquired number of the encryption base, for example, multiplying each numerical value in the pseudo-random number according to the acquired number of the encryption base, and taking the last numerical value of each product as the transposition number.
For example, the third time the encryption base is obtained from the information to be encrypted, the number of obtained encryption bases is 3, the pseudo random number is 4768, the first value "4" of the pseudo random number is multiplied by "3", the product is 12, and the last value "2" of 12 is used as the first value in the bit number.
S124, performing encryption operation on the basic data and the transposition number to obtain corresponding ciphertext data.
The basic data and the transposition number can be subjected to encryption operation so as to obtain corresponding ciphertext data, each numerical value in the transposition number, namely the advancing number of the numerical value in the basic data, and each numerical value in the basic data is subjected to encryption operation through the transposition number so as to obtain ciphertext data corresponding to the basic data, wherein the numerical value in the basic data is equal to the advancing number of the numerical value in the ciphertext data. In the process of carrying out encryption operation on each bit value in the basic data, carrying out carry on the corresponding value according to the coding rule of the basic data.
For example, if the first numerical value in the basic data is "g", and the first numerical value in the bit conversion number is "2", then carrying 2 bits on "g" to obtain "i", and the ciphertext numerical value corresponding to the first numerical value in the basic data is "i"; and obtaining ciphertext values corresponding to the bit values in the basic data by the method, so as to obtain ciphertext data corresponding to the basic data.
In a specific embodiment, as shown in fig. 3, step S125 is further included after step S124.
S125, writing the acquired ciphertext data into a cache.
The obtained ciphertext data can be written into a buffer memory, the buffer memory can be a storage space special for ciphertext data storage in a storage medium (such as a memory) of the user terminal or the management server, and the buffer memory can be used for temporarily storing ciphertext data.
In a specific embodiment, as shown in fig. 4, step S121 is further followed by step S1211.
S1211, if the information to be encrypted does not contain unencrypted data, reading the ciphertext data stored in the cache and sequentially writing the ciphertext data into a data file for storage.
If the information to be encrypted does not contain unencrypted data, indicating that all data in the information to be encrypted are subjected to encryption operation; ciphertext data stored in the cache can be acquired and sequentially written into a data file for storage, and the data file can be used for carrying out persistent storage on the ciphertext data.
S130, splicing the ciphertext data of each piece of basic data to obtain encrypted data information corresponding to the information to be encrypted.
And splicing the ciphertext data of each piece of basic data to obtain encrypted data information corresponding to the information to be encrypted. Ciphertext data corresponding to the basic data can be spliced, and specifically, each ciphertext data can be spliced sequentially according to the sequence of the basic data corresponding to the ciphertext data, so that encrypted data information corresponding to the information to be encrypted is obtained.
In one embodiment, as shown in fig. 5, the step S130 includes sub-steps S131 and S132.
S131, reading the stored ciphertext data.
And S132, splicing ciphertext data of each piece of basic data according to the position of the basic data in the information to be encrypted to obtain corresponding encrypted data information.
Specifically, the ciphertext data stored in the cache or the ciphertext data stored in the data file can be read, the position of each basic data in the information to be encrypted is determined, the ciphertext data of each basic data are spliced in sequence according to the position of the basic data, so as to obtain encrypted data information, and the sequence of each ciphertext data in the encrypted data information is consistent with the position of the basic data corresponding to the ciphertext data in the information to be encrypted.
In a specific embodiment, as shown in fig. 6, step S130 is further followed by step S140.
And S140, transmitting the encrypted data information and the encrypted seed.
After the encrypted data information is obtained, the encrypted data information and the encrypted seed can be combined and then transmitted. After receiving the encrypted data information and the encrypted seed, the receiving end can decrypt and restore the encrypted data information according to the encrypted seed to obtain decryption information. The specific process of decryption and restoration is opposite to the process of encryption operation; if the decryption is correct, the obtained decryption information is the original information to be encrypted.
In the information encryption method based on pseudo random numbers provided by the embodiment of the invention, the method comprises the following steps: if the input information to be encrypted is received, randomly generating an encryption seed; the encryption seed comprises an encryption base and a pseudo random number corresponding to the encryption base; sequentially reading basic data corresponding to the encryption base from the information to be encrypted, and performing transposition encryption on the basic data according to the pseudo-random number to obtain corresponding ciphertext data; and splicing the ciphertext data of each piece of basic data to obtain encrypted data information corresponding to the information to be encrypted. By the method, encryption seeds are randomly generated, and basic data read from the information to be encrypted in sequence are subjected to transposition encryption according to the encryption seeds to obtain corresponding encrypted data information; the method has the advantages that the data to be encrypted are subjected to transposition encryption in a mode of randomly generating encryption seeds, so that the complexity of encryption operation is greatly reduced, and the time consumption of an encryption process is shortened.
The embodiment of the invention also provides a pseudo-random number-based information encryption device which is configured in the user terminal or the management server and is used for executing any embodiment of the pseudo-random number-based information encryption method. In particular, referring to fig. 7, fig. 7 is a schematic block diagram of an information encryption device based on pseudo random numbers according to an embodiment of the present invention.
As shown in fig. 7, the pseudo-random number-based information encryption apparatus 100 includes an encryption seed generation unit 110, a ciphertext data generation unit 120, and an encrypted data information acquisition unit 130.
An encryption seed generating unit 110, configured to randomly generate an encryption seed if the input information to be encrypted is received; the encryption seed includes a encryption base and a pseudorandom number corresponding to the encryption base.
And the ciphertext data generating unit 120 is configured to sequentially read basic data corresponding to the encryption base from the information to be encrypted, and perform transposition encryption on the basic data according to the pseudo random number to obtain corresponding ciphertext data.
And the encrypted data information obtaining unit 130 is configured to splice ciphertext data of each piece of the basic data to obtain encrypted data information corresponding to the information to be encrypted.
The information encryption device based on the pseudo random number provided by the embodiment of the invention applies the information encryption method based on the pseudo random number, and if the input information to be encrypted is received, encryption seeds are randomly generated; the encryption seed comprises an encryption base and a pseudo random number corresponding to the encryption base; sequentially reading basic data corresponding to the encryption base from the information to be encrypted, and performing transposition encryption on the basic data according to the pseudo-random number to obtain corresponding ciphertext data; and splicing the ciphertext data of each piece of basic data to obtain encrypted data information corresponding to the information to be encrypted. By the method, encryption seeds are randomly generated, and basic data read from the information to be encrypted in sequence are subjected to transposition encryption according to the encryption seeds to obtain corresponding encrypted data information; the method has the advantages that the data to be encrypted are subjected to transposition encryption in a mode of randomly generating encryption seeds, so that the complexity of encryption operation is greatly reduced, and the time consumption of an encryption process is shortened.
The steps performed by the above-described pseudo-random number based information encrypting means may be implemented in the form of a computer program, and the pseudo-random number based information encrypting means may be implemented in the form of a computer device, which is operable on a computer device as shown in fig. 8.
Referring to fig. 8, fig. 8 is a schematic block diagram of a computer device according to an embodiment of the present invention. The computer device may be a user terminal or a management server for performing a pseudo-random number based information encryption method to transpose and encrypt the input information to be encrypted to obtain encrypted data information.
With reference to FIG. 8, the computer device 500 includes a processor 502, a memory, and a network interface 505, connected by a system bus 501, where the memory may include a storage medium 503 and an internal memory 504.
The storage medium 503 may store an operating system 5031 and a computer program 5032. The computer program 5032, when executed, may cause the processor 502 to perform a pseudo-random number based information encryption method, wherein the storage medium 503 may be a volatile storage medium or a non-volatile storage medium.
The processor 502 is used to provide computing and control capabilities to support the operation of the overall computer device 500.
The internal memory 504 provides an environment for the execution of a computer program 5032 in the storage medium 503, which computer program 5032, when executed by the processor 502, causes the processor 502 to perform a pseudo-random number based information encryption method.
The network interface 505 is used for network communication, such as providing for transmission of data information, etc. It will be appreciated by those skilled in the art that the architecture shown in fig. 8 is merely a block diagram of some of the architecture relevant to the present inventive arrangements and is not limiting of the computer device 500 to which the present inventive arrangements may be implemented, as a particular computer device 500 may include more or fewer components than shown, or may combine some of the components, or have a different arrangement of components.
The processor 502 is configured to execute a computer program 5032 stored in a memory to implement the corresponding functions in the above-described information encryption method based on pseudo random numbers.
Those skilled in the art will appreciate that the embodiment of the computer device shown in fig. 8 is not limiting of the specific construction of the computer device, and in other embodiments, the computer device may include more or less components than those shown, or certain components may be combined, or a different arrangement of components. For example, in some embodiments, the computer device may include only a memory and a processor, and in such embodiments, the structure and function of the memory and the processor are consistent with the embodiment shown in fig. 8, and will not be described again.
It should be appreciated that in embodiments of the present invention, the Processor 502 may be a central processing unit (Central Processing Unit, CPU), the Processor 502 may also be other general purpose processors, digital signal processors (DIGITAL SIGNAL processors, DSPs), application SPECIFIC INTEGRATED Circuits (ASICs), off-the-shelf Programmable gate arrays (Field-Programmable GATE ARRAY, FPGA) or other Programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or the like. Wherein the general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
In another embodiment of the invention, a computer-readable storage medium is provided. The computer readable storage medium may be a volatile or nonvolatile computer readable storage medium. The computer readable storage medium stores a computer program which when executed by a processor implements the steps included in the pseudo-random number based information encryption method described above.
It will be clearly understood by those skilled in the art that, for convenience and brevity of description, specific working procedures of the apparatus, device and unit described above may refer to corresponding procedures in the foregoing method embodiments, which are not repeated herein. Those of ordinary skill in the art will appreciate that the elements and algorithm steps described in connection with the embodiments disclosed herein may be embodied in electronic hardware, in computer software, or in a combination of the two, and that the elements and steps of the examples have been generally described in terms of function in the foregoing description to clearly illustrate the interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
In the several embodiments provided by the present invention, it should be understood that the disclosed apparatus, device and method may be implemented in other manners. For example, the apparatus embodiments described above are merely illustrative, and for example, the division of the units is merely a logical function division, there may be another division manner in actual implementation, or units having the same function may be integrated into one unit, for example, multiple units or components may be combined or may be integrated into another system, or some features may be omitted, or not performed. In addition, the coupling or direct coupling or communication connection shown or discussed with each other may be an indirect coupling or communication connection via some interfaces, devices, or elements, or may be an electrical, mechanical, or other form of connection.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the embodiment of the present invention.
In addition, each functional unit in the embodiments of the present invention may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in software functional units.
The integrated units, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention is essentially or part of what contributes to the prior art, or all or part of the technical solution may be embodied in the form of a software product stored in a computer-readable storage medium, comprising several instructions for causing a computer device (which may be a personal computer, a server, a network device, etc.) to perform all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned computer-readable storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a magnetic disk, an optical disk, or other various media capable of storing program codes.
While the invention has been described with reference to certain preferred embodiments, it will be understood by those skilled in the art that various changes and substitutions of equivalents may be made and equivalents will be apparent to those skilled in the art without departing from the scope of the invention. Therefore, the protection scope of the invention is subject to the protection scope of the claims.