CN109617680B - Encryption method, device, equipment and medium - Google Patents
Encryption method, device, equipment and medium Download PDFInfo
- Publication number
- CN109617680B CN109617680B CN201811486139.6A CN201811486139A CN109617680B CN 109617680 B CN109617680 B CN 109617680B CN 201811486139 A CN201811486139 A CN 201811486139A CN 109617680 B CN109617680 B CN 109617680B
- Authority
- CN
- China
- Prior art keywords
- encrypted
- character
- numbers
- characters
- encryption
- 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.)
- Active
Links
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L9/00—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
- H04L9/08—Key distribution or management, e.g. generation, sharing or updating, of cryptographic keys or passwords
- H04L9/0816—Key establishment, i.e. cryptographic processes or cryptographic protocols whereby a shared secret becomes available to two or more parties, for subsequent use
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L9/00—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
- H04L9/08—Key distribution or management, e.g. generation, sharing or updating, of cryptographic keys or passwords
- H04L9/0861—Generation of secret information including derivation or calculation of cryptographic keys or passwords
- H04L9/0869—Generation of secret information including derivation or calculation of cryptographic keys or passwords involving random numbers or seeds
Abstract
The invention discloses an encryption method, an encryption device, equipment and a medium, wherein the encryption method is executed for each character in plaintext to be encrypted, and the encryption method comprises the following steps: generating an encryption key corresponding to the character to be encrypted according to the random seed value of the character to be encrypted and the initial key of the plaintext to be encrypted; generating a random array according to the random seed value and the encryption key; and replacing the characters to be encrypted with the characters in the random array according to the index numbers of the characters in the random array. According to the embodiment of the invention, the byte lengths of the ciphertext and the plaintext can be consistent, the constraint of a data format cannot be damaged, the ciphertext generated when different plaintexts are encrypted is different, and the data operation error caused by the same ciphertext is avoided, so that the data accuracy is ensured.
Description
Technical Field
The present invention relates to the field of computers, and in particular, to an encryption method, apparatus, device, and medium.
Background
With the development of mobile communication technology and the increasing coverage requirement of special scenes, more and more emergency sites are put into use, the monitoring and control messages of the emergency sites are sensitive, and the information security needs to be ensured, so that a message encryption mode needs to be designed.
At present, the encryption mode of the message to be sent corresponding to the urgent site adopts the common data encryption or the data masking encryption. In the ordinary data encryption, general symmetric encryption algorithm is adopted to encrypt XDR sensitive information such as MSISDN and the like, and meaningless ciphertext in the form of zgpzrdma/ue 87cvdF1rbHg is generated. Data Masking (Data Masking) encryption is the cloning and Masking of sensitive Data, etc. It is now common to simply hide the few characters in the middle of the message to be sent, i.e. replace the actual characters with the characters, e.g. 001101 for the message to be sent, encrypted to 00 x 01.
The encryption method in the prior art has the following disadvantages:
(1) the common data encryption causes the byte length of the generated ciphertext to be often larger than that of the original plaintext, so that the existing data system has the risk of needing to be modified, and extra cost is brought.
(2) The security of a common encryption mode is low, and once a password is leaked, encrypted information can be obtained.
(3) The information encrypted by the data hiding method still contains more real information, is easy to crack and has certain potential safety hazard. In addition, the method is easy to cause different data to generate the same ciphertext, and when the two same ciphertexts are operated, because the two same ciphertexts cannot be distinguished, operation errors are caused, and the data accuracy is influenced.
Disclosure of Invention
Embodiments of the present invention provide an encryption method, apparatus, device, and medium, which can keep byte lengths of an original plaintext and a ciphertext consistent, improve security of the ciphertext, and avoid operation errors because keys of different plaintexts are different.
In one aspect, an embodiment of the present invention provides an encryption method, where the encryption method is executed for each character in plaintext to be encrypted, where the encryption method includes:
generating an encryption key corresponding to the character to be encrypted according to the random seed value of the character to be encrypted and the initial key of the plaintext to be encrypted;
generating a random array according to the random seed value and the encryption key;
and replacing the characters to be encrypted with the characters in the random array according to the index numbers of the characters in the random array.
On the other hand, an embodiment of the present invention provides an encryption apparatus, where the apparatus encrypts each character in plaintext to be encrypted, and the encryption apparatus includes:
the key generation module is used for generating an encryption key corresponding to the character to be encrypted according to the random seed value of the character to be encrypted and the initial key of the plaintext to be encrypted;
a random array generating module, configured to generate a random array according to the random seed value and the encryption key;
and the character replacing module is used for replacing the characters to be encrypted with the characters in the random array according to the index numbers of the characters in the random array.
In another aspect, an embodiment of the present invention provides an apparatus having an encryption function, where the apparatus includes: a processor and a memory storing computer program instructions;
the processor, when executing the computer program instructions, implements an encryption method as described in any of the above.
In yet another aspect, an embodiment of the present invention provides a computer storage medium having computer program instructions stored thereon, where the computer program instructions, when executed by a processor, implement the encryption method as described in any one of the above.
According to the encryption method, the encryption device, the encryption equipment and the encryption medium, each character in the plaintext to be encrypted is replaced by other characters so as to realize plaintext encryption, so that the byte lengths of the ciphertext and the plaintext are consistent, the constraint of a data format is not damaged, and the modification cost of an operating application system is reduced. Each character in each plaintext to be encrypted has a corresponding encryption key, so that the security of encrypted data is ensured. And when different plaintexts are encrypted, the generated ciphertexts are different, so that data operation errors caused by the same ciphertexts are avoided, and the data accuracy is ensured.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required to be used in the embodiments of the present invention will be briefly described below, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a schematic flow chart illustrating an encryption method according to an embodiment of the present invention;
FIG. 2 is a schematic diagram illustrating interaction between a user terminal and a server according to an embodiment of the present invention;
FIG. 3 shows a schematic diagram of data transmission of an embodiment of the present invention;
fig. 4 is a schematic structural diagram of an encryption apparatus provided in an embodiment of the present invention;
fig. 5 is a schematic diagram illustrating a hardware structure of a device with an encryption function according to an embodiment of the present invention.
Detailed Description
Features and exemplary embodiments of various aspects of the present invention will be described in detail below, and in order to make objects, technical solutions and advantages of the present invention more apparent, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not to be construed as limiting the invention. It will be apparent to one skilled in the art that the present invention may be practiced without some of these specific details. The following description of the embodiments is merely intended to provide a better understanding of the present invention by illustrating examples of the present invention.
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 … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
In order to solve the problem of the prior art, embodiments of the present invention provide an encryption method, apparatus, device, and medium. The following first describes an encryption method provided in an embodiment of the present invention.
Fig. 1 shows a schematic flow chart of an encryption method provided by an embodiment of the present invention. The encryption method is executed for each character in plaintext to be encrypted, and as shown in fig. 1, the encryption method includes:
s101, generating an encryption key corresponding to the character to be encrypted according to the random seed value of the character to be encrypted and the initial key of the plaintext to be encrypted.
It should be noted that the plaintext to be encrypted includes the code of the message to be transmitted. For example, the message to be sent is a monitoring control message, and the user terminal collects monitoring control messages such as an access switch and a power equipment switch of an emergency site and encodes the messages according to a custom rule. The maintainer identity passes through Application (APP) authentication, and long-range APP realization on through user's mobile terminal is to emergency stop entrance guard switch, the control of website power switch, and the data that the period was sent or was received need to guarantee information safety.
The specific encoding format is shown in table 1:
TABLE 1
Message to be sent | Coding of messages to be transmitted |
Gate inhibition switch (open) | 000100 |
Gate inhibition switch (off) | 000101 |
Temperature of | 000200 |
Humidity | 000300 |
Power switch (on) | 000400 |
Power switch(guan) | 000401 |
Voltage of | 000500 |
Electric current | 000600 |
…… | …… |
In addition, the plaintext to be encrypted may include a user identification in addition to the encoding of the message to be transmitted. The method comprises the steps of encrypting codes and user identity marks of messages to be sent, namely, taking data of users as a part of keys, enabling the keys of user information to be independent, enabling other users to be guaranteed not to be directly cracked even if a single user is cracked, and enabling each piece of data not to have referential property.
S102, generating a random array according to the random seed value and the encryption key.
S103, replacing the characters to be encrypted with the characters in the random array according to the index numbers of the characters in the random array.
According to the encryption method provided by the embodiment of the invention, each character in the plaintext to be encrypted is replaced by other characters so as to realize plaintext encryption, so that the byte lengths of the ciphertext and the plaintext are consistent, the constraint of a data format is not damaged, and the modification cost of the running application system is reduced. Each character in each plaintext to be encrypted is provided with a corresponding encryption key, so that the difficulty in cracking is increased, and the safety of encrypted data is ensured. And when different plaintexts are encrypted, the generated ciphertexts are different, so that errors caused by the association operation of the data due to the same ciphertexts are avoided, and the data accuracy is ensured.
In one embodiment of the present invention, the encryption method further includes:
when the character to be encrypted is the nth character in the plaintext to be encrypted, sequentially acquiring n characters from the last bit of the plaintext to be encrypted, and taking the n characters arranged according to the acquired sequence as a random seed value, wherein n is a positive integer.
For example, the plaintext to be encrypted is subjected to reverse order, and each character and all characters before the character in the plaintext to be encrypted are selected in a circulating manner to form a character string array as a random seed value. Taking the user ID number as 56789 and the message code to be sent as 001100 as an example, the user ID + the message code to be sent is taken as a plaintext to be encrypted, that is, the plaintext to be encrypted is 56789001100. When the first character '5' in the plaintext to be encrypted is encrypted, the random seed value of the character is [0 ]; when the 2 nd character "6" in the plaintext to be encrypted is encrypted, the random seed value of the character is [0,0 ]; when the 3 rd character '7' in plaintext to be encrypted is encrypted, the random seed value of the character is [0,0,1 ]; when the last character "0" in the plaintext to be encrypted is encrypted, the random seed value for that character is [0,0,1,1,0,0,9,8,7,6,5 ].
In one embodiment of the present invention, S101 includes:
determining the index number of the character to be replaced in the initial key according to the index number of each character in the random seed value and the total number of the characters in the random seed value; and replacing the characters in the initial key with the characters in the random seed value according to the index number of the characters to be replaced, and taking the replaced initial key as the encryption key.
As an example, the index number of the character to be replaced is determined by the following formula 1:
q ═ Q (length (n) + i-1) mod16 equation 1
When replacing the characters in the initial key, the characters with the index number Q in the initial key are replaced by Ni.
Wherein, N represents the random seed value, Ni represents the character with index number i in the random seed value, length (N) represents the total number of the characters in the random seed value, and Q represents the index number of the character to be replaced. mod means modulo.
For example, the plaintext to be encrypted is 56789001100, the initial key is 9722852492105080, the character with index number 0 in the initial key is 9, the character with index number 1 in the initial key is 7, and the character with index number 2 in the initial key is 2.
When the 1 st bit character "5" in plain text is encrypted, if the random seed value N of the character is [0], i is 0, N0 is 0, length (N) is 1, (length (N) + i-1) mod16 is 0, it is determined that the character to be replaced in the initial key is a character with an index number of 0 in the initial key. The character of the initial key with index number 0 is replaced by 0 in the random seed value, i.e. the replaced initial key is 0722852492105080.
When a 2 nd bit character "6" in plain text is encrypted, the random seed value N of the character is [0, 0], and length (N) is 2. When i is 0 and N0 is 0, (length (N) + i-1) mod16 is 1, it is determined that the character to be replaced in the initial key is a character whose index number is 1 in the initial key. The character with index number 1 in the initial key is replaced by N0 in the random seed value, i.e. the replaced initial key is 9022852492105080. On the basis of the replaced key 9022852492105080, when i is 1 and N1 is 0, (length (N) + i-1) mod16 is 2, it is determined that the character to be replaced in the initial key is a character whose index number is 2 in the initial key. The character with index number 2 in the initial key is replaced by N1 in the random seed value, i.e. the replaced initial key is 9002852492105080.
In one embodiment of the present invention, S102 includes:
respectively encrypting the numbers 0-9 according to the random seed value and the encryption key to obtain ciphertexts of the numbers 0-9; and sequencing the numbers 0-9 according to the ciphertext contents of the numbers 0-9, and taking the sequenced numbers 0-9 as a random array.
As an example, when the numbers 0 to 9 are respectively encrypted, the numbers 0 to 9 are converted into hexadecimal characters, and the hexadecimal characters corresponding to the numbers 0 to 9 are respectively encrypted; and when the numbers 0-9 are sequenced, the first four digits of the ciphertext of each number in the numbers 0-9 are obtained, the first four digits of the ciphertext are converted into decimal numbers, and the numbers 0-9 are sequenced according to the decimal number size of the first four digits of the ciphertext.
For example, the numbers 0 to 9 are converted into hexadecimal numbers, and Advanced Encryption Standard (AES) Encryption is sequentially performed on the hexadecimal numbers 0 to 9 to generate a ciphertext-number correspondence list as shown in table 2. In table 2, the first four characters of the ciphertext of each digit are taken, the first four digits are converted into decimal numbers, the digits 0 to 9 are sorted in the descending order of the decimal numbers, and the sorted digits 0 to 9 are [4,3,7,9,5,1,0,6,8,2 ].
TABLE 2
Number of | Cipher text | First four bits of ciphertext | Decimal system | Descending order |
0 | 38A870A4255015A8EFA480C2F8A7F914 | 38A8 | 14504 | 7 |
1 | 3D6E666F28AAE994B8E0C96A3C10EF96 | 3D6E | 15726 | 6 |
2 | 0D399A28234DCF44A0B5CDBE893350CA | 0D39 | 3385 | 10 |
3 | 6D27E9A31BBEAD4157F77FE0CF852071 | 6D27 | 27943 | 2 |
4 | B34B8C6BB9570DC938532FDBD37298C0 | B34B | 45899 | 1 |
5 | 408142D9F6174FFD0051B93D37539BEA | 4081 | 16513 | 5 |
6 | 3675FB9A2408274833B591991D104AFF | 3675 | 13941 | 8 |
7 | 6A04F772D9C5ABF90BD2D5E2CA708AFC | 6A04 | 27140 | 3 |
8 | 172D01CC7C36F38CCCA8D314FA80562A | 172D | 5933 | 9 |
9 | 59910D117CDD18F5B5874ABAEBF98ADD | 5991 | 22929 | 4 |
In one embodiment of the invention, for a character x to be encrypted, the character x to be encrypted is replaced by a character with an index number x in a random array, wherein x is a decimal character or a hexadecimal character.
For example, the plaintext to be encrypted is 56789001100, and if the character to be encrypted is the last bit "0", and the random array is [4,3,7,9,5,1,0,6,8,2], the last bit "0" in the plaintext to be encrypted is replaced by the number (i.e., 4) with the index number "0", that is, the plaintext after replacement is 56789001104.
In one embodiment of the present invention, the encryption method further includes:
and determining an initial key according to the identification number of the cell where the user terminal is located and the time for generating the message to be sent.
It should be noted that the identification number of the Cell may be an evolved universal terrestrial radio access network Cell identity (E-UTRAN Cell Identifier, ECI).
As an example, a set of digit sequences is generated based on the time at which a message to be sent is generated; the identification number of the cell is multiplied by the number sequence and the first 16-bit character of the multiplication result is taken as the initial key. Wherein if the multiplication result is not enough 16 bits, the insufficient number of bits is filled with 0.
For example, the identification number of the cell where the user terminal is located is 54726274, the time for generating the message to be sent is 18 o 'clock 45 o' clock in 10 month 03 day in 2018, and the first 16 bits of the numbers 53716472 × 1810031845 are taken as the private key, in this example, the initial key is 9722852492105080.
It should be noted that the main execution body of the encryption method in the above is the user terminal. Fig. 2 shows a schematic diagram of interaction between a user terminal and a server according to an embodiment of the present invention. As shown in fig. 2, after the user terminal executes the encryption method in the foregoing description on each character in the plaintext to be encrypted, or replaces each character in the plaintext to be encrypted with another character, the user terminal sends a service request (Server request) to the Server, where the service request carries a ciphertext, and the ciphertext includes: a message to be sent, an Identity (ID) of a Subscriber, an International Mobile Subscriber Identity (IMSI), and an International Mobile Equipment Identity (IMEI). The user terminal sends the initial key of the encrypted ciphertext, or sends the ECI and the date, besides sending the ciphertext to the server, and the server can obtain the initial key according to the ECI and the date.
And after receiving the ciphertext, the server acquires an initial key, takes the ciphertext as a plaintext to be encrypted, encrypts the plaintext to be encrypted according to the encryption method, and decrypts the ciphertext in an encryption mode. For example, the server receives the ciphertext a, encrypts a according to the encryption method described above to obtain the ciphertext B, and decrypts B as the content of a. The server returns a response to the user terminal, and the response carries the key. The user terminal needs to take the server side key when requesting resources from the server every time, and the server returns request data to the user terminal.
Fig. 3 shows a schematic diagram of data transmission according to an embodiment of the invention. As shown in fig. 3, the processing of messages to be sent and control messages includes: the UE1 sends the ciphertext to the Internet of Things (IoT) via an uplink message; the Internet of things analyzes the protocol message to obtain an effective message; the Internet of things searches for a corresponding decoder and analyzes the decoder into server matching data; the de-coding plug-in transmits the de-coded data back to the IoT; the IoT sends an application server subscription message to the server, the application server decrypts the ciphertext and sends a control message to the IoT; the IoT issues a reverse decoding to the coding and decoding plug-in; the coding and decoding plug-in unit transmits the coding and decoding result back to the IoT; the IoT parses the protocol message, gets the valid message, and issues the valid message to the UE 2.
Fig. 4 is a schematic structural diagram of an encryption apparatus according to an embodiment of the present invention. The apparatus encrypts each character in plaintext to be encrypted, as shown in fig. 4, the encryption apparatus 200 includes:
the key generation module 201 is configured to generate an encryption key corresponding to the character to be encrypted according to the random seed value of the character to be encrypted and the initial key of the plaintext to be encrypted.
And a random array generating module 202, configured to generate a random array according to the random seed value and the encryption key.
And the character replacing module 203 is used for replacing the characters to be encrypted into the characters in the random array according to the index numbers of the characters in the random array.
In one embodiment of the present invention, the encryption apparatus 200 further comprises:
and the random seed value generating module is used for sequentially acquiring n characters from the last bit of the plaintext to be encrypted when the character to be encrypted is the nth character in the plaintext to be encrypted, and taking the n characters arranged according to the acquired sequence as the random seed value, wherein n is a positive integer.
In one embodiment of the present invention, the key generation module 201 includes:
and the index number determining module is used for determining the index number of the character to be replaced in the initial key according to the index number of each character in the random seed value and the total number of the characters in the random seed value.
And the key determining module is used for replacing the characters in the initial key with the characters in the random seed value according to the index number of the characters to be replaced, and taking the replaced initial key as the encryption key.
In one embodiment of the present invention, the index number determination module determines the index number of the character to be replaced by the following formula:
Q=(length(N)+i-1)mod16。
when replacing the characters in the initial key, the characters with the index number Q in the initial key are replaced by Ni.
Wherein, N represents the random seed value, Ni represents the character with index number i in the random seed value, length (N) represents the total number of the characters in the random seed value, and Q represents the index number of the character to be replaced.
In one embodiment of the present invention, the random array generation module 202 comprises:
and the digital encryption module is used for respectively encrypting the numbers 0-9 according to the random seed value and the encryption key to obtain ciphertexts of the numbers 0-9.
And the number sequencing module is used for sequencing the numbers 0-9 according to the ciphertext contents of the numbers 0-9, and taking the sequenced numbers 0-9 as a random array.
In an embodiment of the present invention, the digital encryption module is configured to convert the numbers 0 to 9 into hexadecimal characters, and encrypt the hexadecimal characters corresponding to the numbers 0 to 9, respectively.
And the number sequencing module is used for acquiring the front four digits of the ciphertext of each number in the numbers 0-9, converting the front four digits of the ciphertext into decimal numbers, and sequencing the numbers 0-9 according to the size of the decimal numbers of the front four digits of the ciphertext.
In one embodiment of the invention, the character replacement module 203 is configured to,
and for the character x to be encrypted, replacing the character x to be encrypted with a character with an index number x in a random array, wherein x is a decimal character or a hexadecimal character.
In one embodiment of the invention, the plaintext to be encrypted comprises: coding of a message to be sent; the encryption device 200 further includes:
and the initial key determining module is used for determining an initial key according to the identification number of the cell where the user terminal is located and the time for generating the message to be sent.
In one embodiment of the invention, the initial key determination module comprises:
and the digital sequence generating module is used for generating a group of digital sequences according to the time for generating the message to be sent.
And the initial key calculation module is used for multiplying the identification number of the cell by the digital sequence and taking the first 16-bit character of the multiplication result as the initial key.
In one embodiment of the invention, the plaintext to be encrypted further comprises a user identity.
Fig. 5 is a schematic diagram illustrating a hardware structure of a device with an encryption function according to an embodiment of the present invention.
The device with encryption functionality may comprise a processor 301 and a memory 302 in which computer program instructions are stored.
In particular, the processor 301 may include a Central Processing Unit (CPU), or an Application Specific Integrated Circuit (ASIC), or may be configured as one or more Integrated circuits implementing embodiments of the present invention.
The processor 301 implements any of the encryption methods in the above embodiments by reading and executing computer program instructions stored in the memory 302.
In one example, a device with encryption capabilities can also include a communication interface 303 and a bus 310. As shown in fig. 5, the processor 301, the memory 302, and the communication interface 303 are connected via a bus 310 to complete communication therebetween.
The communication interface 303 is mainly used for implementing communication between modules, apparatuses, units and/or devices in the embodiment of the present invention.
The device with the encryption function can execute the encryption method in the embodiment of the invention, thereby realizing the encryption method and the encryption device described in conjunction with fig. 1 and 4.
In addition, in combination with the encryption method in the above embodiments, the embodiments of the present invention may be implemented by providing a computer storage medium. The computer storage medium having computer program instructions stored thereon; the computer program instructions, when executed by a processor, implement any of the encryption methods in the above embodiments.
It is to be understood that the invention is not limited to the specific arrangements and instrumentality described above and shown in the drawings. A detailed description of known methods is omitted herein for the sake of brevity. In the above embodiments, several specific steps are described and shown as examples. However, the method processes of the present invention are not limited to the specific steps described and illustrated, and those skilled in the art can make various changes, modifications and additions or change the order between the steps after comprehending the spirit of the present invention.
The functional blocks shown in the above-described structural block diagrams may be implemented as hardware, software, firmware, or a combination thereof. When implemented in hardware, it may be, for example, an electronic circuit, an Application Specific Integrated Circuit (ASIC), suitable firmware, plug-in, function card, or the like. When implemented in software, the elements of the invention are the programs or code segments used to perform the required tasks. The program or code segments may be stored in a machine-readable medium or transmitted by a data signal carried in a carrier wave over a transmission medium or a communication link. A "machine-readable medium" may include any medium that can store or transfer information. Examples of a machine-readable medium include electronic circuits, semiconductor memory devices, ROM, flash memory, Erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks, fiber optic media, Radio Frequency (RF) links, and so forth. The code segments may be downloaded via computer networks such as the internet, intranet, etc.
It should also be noted that the exemplary embodiments mentioned in this patent describe some methods or systems based on a series of steps or devices. However, the present invention is not limited to the order of the above-described steps, that is, the steps may be performed in the order mentioned in the embodiments, may be performed in an order different from the order in the embodiments, or may be performed simultaneously.
As described above, only the specific embodiments of the present invention are provided, and it can be clearly understood by those skilled in the art that, for convenience and brevity of description, the specific working processes of the system, the module and the unit described above may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again. It should be understood that the scope of the present invention is not limited thereto, and any person skilled in the art can easily conceive various equivalent modifications or substitutions within the technical scope of the present invention, and these modifications or substitutions should be covered within the scope of the present invention.
Claims (11)
1. An encryption method, wherein the encryption method is performed for each character in plaintext to be encrypted, the encryption method comprising:
generating an encryption key corresponding to the character to be encrypted according to the random seed value of the character to be encrypted and the initial key of the plaintext to be encrypted, wherein the plaintext to be encrypted comprises a user ID and a message code to be sent;
generating a random array according to the random seed value and the encryption key;
replacing the characters to be encrypted with the characters in the random array according to the index numbers of the characters in the random array
Generating a random array according to the random seed value and the encryption key, including:
encrypting the numbers 0-9 respectively according to the random seed value and the encryption key to obtain ciphertexts of the numbers 0-9;
sequencing the numbers 0-9 according to the ciphertext contents of the numbers 0-9, and taking the sequenced numbers 0-9 as the random array;
when the numbers 0-9 are respectively encrypted, the numbers 0-9 are converted into hexadecimal characters, and the hexadecimal characters corresponding to the numbers 0-9 are respectively encrypted;
and the number of the first and second electrodes,
when the numbers 0-9 are sequenced, the first four digits of the ciphertext of each number in the numbers 0-9 are obtained, the first four digits of the ciphertext are converted into decimal numbers, and the numbers 0-9 are sequenced according to the decimal number size of the first four digits of the ciphertext.
2. The method of claim 1, further comprising:
when the character to be encrypted is the nth character in the plaintext to be encrypted, sequentially acquiring n characters from the last bit of the plaintext to be encrypted, and taking the n characters arranged according to the acquired sequence as the random seed value, wherein n is a positive integer.
3. The method according to claim 1, wherein the generating an encryption key corresponding to the character to be encrypted according to the random seed value of the character to be encrypted and the initial key of the plaintext to be encrypted comprises:
determining the index number of the character to be replaced in the initial key according to the index number of each character in the random seed value and the total number of the characters in the random seed value;
and replacing the characters in the initial key with the characters in the random seed value according to the index number of the characters to be replaced, and taking the replaced initial key as the encryption key.
4. The method of claim 3,
determining the index number of the character to be replaced by the following formula:
Q=(length(N)+i-1)mod16,
and the number of the first and second electrodes,
when replacing the characters in the initial key, replacing the characters with the index number of Q in the initial key with Ni,
wherein, N represents the random seed value, Ni represents a character with an index number i in the random seed value, length (N) represents the total number of characters in the random seed value, and Q represents the index number of the character to be replaced.
5. The method of claim 1, wherein,
and for the character x to be encrypted, replacing the character x to be encrypted with a character with an index number x in the random array, wherein x is a decimal character or a hexadecimal character.
6. The method according to claim 1, wherein the plaintext to be encrypted comprises: coding of a message to be sent; and the method further comprises:
and determining the initial key according to the identification number of the cell where the user terminal is located and the time for generating the message to be sent.
7. The method of claim 6, wherein,
generating a group of digital sequences according to the time for generating the message to be sent;
and multiplying the identification number of the cell by the number sequence, and taking the first 16-bit character of the multiplication result as the initial key.
8. The method according to claim 6, wherein the plaintext to be encrypted further comprises a user identity.
9. An encryption apparatus, wherein the apparatus encrypts each character in plaintext to be encrypted, the encryption apparatus comprising:
the key generation module is used for generating an encryption key corresponding to the character to be encrypted according to the random seed value of the character to be encrypted and the initial key of the plaintext to be encrypted, wherein the plaintext to be encrypted comprises a user ID and a message code to be sent;
a random array generating module, configured to generate a random array according to the random seed value and the encryption key;
the character replacing module is used for replacing the characters to be encrypted with the characters in the random array according to the index numbers of the characters in the random array;
the random array generating module further comprises:
the digital encryption module is used for respectively encrypting the numbers 0-9 according to the random seed value and the encryption key to obtain ciphertexts of the numbers 0-9;
the digital sequencing module is used for sequencing the numbers 0-9 according to the ciphertext contents of the numbers 0-9, and taking the sequenced numbers 0-9 as the random array; when the numbers 0-9 are respectively encrypted, the numbers 0-9 are converted into hexadecimal characters, and the hexadecimal characters corresponding to the numbers 0-9 are respectively encrypted;
and when the numbers 0-9 are sequenced, the first four digits of the ciphertext of each number in the numbers 0-9 are obtained, the first four digits of the ciphertext are converted into decimal numbers, and the numbers 0-9 are sequenced according to the decimal number of the first four digits of the ciphertext.
10. An apparatus having an encryption function, characterized in that the apparatus comprises: a processor and a memory storing computer program instructions;
the processor, when executing the computer program instructions, implements the encryption method of any one of claims 1-8.
11. A computer storage medium having computer program instructions stored thereon which, when executed by a processor, implement an encryption method according to any one of claims 1 to 8.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811486139.6A CN109617680B (en) | 2018-12-06 | 2018-12-06 | Encryption method, device, equipment and medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811486139.6A CN109617680B (en) | 2018-12-06 | 2018-12-06 | Encryption method, device, equipment and medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN109617680A CN109617680A (en) | 2019-04-12 |
CN109617680B true CN109617680B (en) | 2021-12-03 |
Family
ID=66007247
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201811486139.6A Active CN109617680B (en) | 2018-12-06 | 2018-12-06 | Encryption method, device, equipment and medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109617680B (en) |
Families Citing this family (12)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110502917A (en) * | 2019-07-08 | 2019-11-26 | 全球能源互联网研究院有限公司 | Desensitization, desensitization restoring method and the device of Electricity customers data |
CN110516462B (en) * | 2019-08-30 | 2021-12-07 | 京东数字科技控股有限公司 | Method and apparatus for encrypting data |
CN112566124A (en) * | 2019-09-25 | 2021-03-26 | 北京紫光青藤微系统有限公司 | Secret key generation and encryption and decryption method and device and SIM card chip |
CN111241575B (en) * | 2019-12-27 | 2021-07-30 | 北京深思数盾科技股份有限公司 | Test method and device for data protection equipment and storage medium |
CN113595717B (en) * | 2020-04-30 | 2023-10-17 | 比亚迪股份有限公司 | ECB mode packet encryption method and decryption method, control device and vehicle |
CN111901099A (en) * | 2020-06-16 | 2020-11-06 | 上海眼控科技股份有限公司 | Method, system and equipment for encrypting vehicle information |
CN111935158B (en) * | 2020-08-12 | 2021-02-26 | 盐城工学院 | Financial data management method of remote network consumption system |
CN112260822B (en) * | 2020-09-16 | 2024-02-27 | 杜绍森 | Structured digital watermark encryption method and device |
CN112019328B (en) * | 2020-10-31 | 2021-01-26 | 北京华云安信息技术有限公司 | Encryption method, device, equipment and storage medium of IP address |
CN114499978B (en) * | 2021-12-28 | 2023-07-21 | 安徽航天信息科技有限公司 | Encryption and decryption method, device and system based on cryptographic replacement exchange |
CN114598470B (en) * | 2022-03-17 | 2023-12-19 | 北京启明星辰信息安全技术有限公司 | Encryption method, decryption method, device, and computer-readable storage medium |
CN117240585A (en) * | 2023-10-18 | 2023-12-15 | 北京海泰方圆科技股份有限公司 | Data encryption method, device and medium |
Family Cites Families (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103427987B (en) * | 2012-05-25 | 2016-05-18 | 纬创资通股份有限公司 | Method, data verification method and the electronic installation of data encryption |
CN105450232A (en) * | 2014-08-28 | 2016-03-30 | 华为技术有限公司 | Encoding method, decoding method, encoding device and decoding device |
US9553723B2 (en) * | 2014-11-14 | 2017-01-24 | Unsene, ehf. | Multi-dimensional encryption |
CN108243001B (en) * | 2016-12-23 | 2019-04-23 | 中科星图股份有限公司 | A kind of data encryption communication means |
CN108377183B (en) * | 2017-12-20 | 2020-11-13 | 中国移动通信集团福建有限公司 | XDR data information encryption method, device, equipment and medium |
-
2018
- 2018-12-06 CN CN201811486139.6A patent/CN109617680B/en active Active
Also Published As
Publication number | Publication date |
---|---|
CN109617680A (en) | 2019-04-12 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109617680B (en) | Encryption method, device, equipment and medium | |
CN108377183B (en) | XDR data information encryption method, device, equipment and medium | |
US8275997B2 (en) | Method of encrypting and transmitting data and system for transmitting encrypted data | |
CN106688204B (en) | Method for generating encryption checksum, method for authenticating message and equipment thereof | |
JP2016513825A (en) | Safety communication method and apparatus | |
JP6453366B2 (en) | Cryptographic checksum generation | |
CN108075879B (en) | Data encryption and decryption method, device and system | |
JP4875055B2 (en) | Method and apparatus for providing a linear erasure code | |
CN103209389A (en) | Method, system and cloud server for short message pushing | |
Spandri et al. | Reed-muller identification | |
US20190349754A1 (en) | Method and device for transmitting encrypted data, method and device for extracting data | |
CN113517982A (en) | Password generation method, password execution method and terminal | |
CN113556381B (en) | Optimization method of HTTP request, terminal and storage medium | |
Gardner et al. | An efficient methodology to de-anonymize the 5G-new radio physical downlink control channel | |
CN113726512A (en) | Key generation and distribution method, key generation device, and key management system | |
CN111756540B (en) | Ciphertext transmission method, terminal, server and system | |
US7526643B2 (en) | System for transmitting encrypted data | |
KR101289810B1 (en) | Transmitter, receiver, data transmitting method, data receiving method, and data transmitting and receiving method | |
EP3654576A1 (en) | Computer-implemented method for error-correction-encoding and encrypting of a file | |
Dubrova et al. | Error-correcting message authentication for 5g | |
RU2718217C1 (en) | Method of providing transmission of encrypted data with change of encryption keys and imitation protection in digital data transmission system | |
KR101632651B1 (en) | Method, server and computer program for transmitting binary data | |
RU2686005C1 (en) | Method of providing transmission of encrypted data in a digital data transmission system (versions) | |
CN114239027A (en) | Data encryption method and apparatus, data decryption method and apparatus, electronic device, and medium | |
CN115103357A (en) | 5G communication encryption system based on FPGA |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |