CN111131158A - Single byte symmetric encryption and decryption method, device and readable medium - Google Patents
Single byte symmetric encryption and decryption method, device and readable medium Download PDFInfo
- Publication number
- CN111131158A CN111131158A CN201911149662.4A CN201911149662A CN111131158A CN 111131158 A CN111131158 A CN 111131158A CN 201911149662 A CN201911149662 A CN 201911149662A CN 111131158 A CN111131158 A CN 111131158A
- Authority
- CN
- China
- Prior art keywords
- byte
- decryption
- encryption
- file
- plaintext
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L63/00—Network architectures or network communication protocols for network security
- H04L63/04—Network architectures or network communication protocols for network security for providing a confidential data exchange among entities communicating through data packet networks
- H04L63/0428—Network architectures or network communication protocols for network security for providing a confidential data exchange among entities communicating through data packet networks wherein the data content is protected, e.g. by encrypting or encapsulating the payload
- H04L63/0435—Network architectures or network communication protocols for network security for providing a confidential data exchange among entities communicating through data packet networks wherein the data content is protected, e.g. by encrypting or encapsulating the payload wherein the sending and receiving network entities apply symmetric encryption, i.e. same key used for encryption and decryption
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F21/00—Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
- G06F21/60—Protecting data
- G06F21/602—Providing cryptographic facilities or services
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F21/00—Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
- G06F21/60—Protecting data
- G06F21/62—Protecting access to data via a platform, e.g. using keys or access control rules
- G06F21/6209—Protecting access to data via a platform, e.g. using keys or access control rules to a single file or object, e.g. in a secure envelope, encrypted and accessed using a key, or with access control rules appended to the object itself
Landscapes
- Engineering & Computer Science (AREA)
- Computer Security & Cryptography (AREA)
- Theoretical Computer Science (AREA)
- Computer Hardware Design (AREA)
- General Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Health & Medical Sciences (AREA)
- Bioethics (AREA)
- General Health & Medical Sciences (AREA)
- Software Systems (AREA)
- Computing Systems (AREA)
- Signal Processing (AREA)
- Computer Networks & Wireless Communication (AREA)
- Storage Device Security (AREA)
Abstract
The invention relates to a single byte symmetric encryption and decryption method, a device and a readable medium, comprising the following steps: a single byte symmetric encryption and decryption method comprises an encryption step and a decryption step, and is characterized in that the encryption step comprises the following steps: loading plaintext file data, randomly generating a key to encrypt each byte of data of the plaintext, and outputting the encrypted file data to a ciphertext file to obtain the ciphertext file; the decrypting step includes: and calling the corresponding key which is randomly generated in the memory space to decrypt the ciphertext file, and converting the obtained plaintext data in the memory space into a plaintext file. The invention has the beneficial effects that: the file data is encrypted and decrypted efficiently, and the confidentiality of the file is protected effectively.
Description
Technical Field
The invention belongs to the field of computer data encryption and decryption, and particularly relates to a single-byte symmetric encryption and decryption method, a single-byte symmetric encryption and decryption device and a readable medium.
Background
Symmetric encryption algorithms are well-established techniques that apply older encryption algorithms. In the symmetric encryption algorithm, a data sender processes a plaintext and an encryption key together through a special encryption algorithm, and then the plaintext and the encryption key are changed into a complex encryption ciphertext to be sent out. After the receiver receives the ciphertext, if the receiver wants to decode the original text, the receiver needs to decrypt the ciphertext by using the key used for encryption and the inverse algorithm of the same algorithm so as to recover the ciphertext into readable plaintext.
The two parties of the transaction of the existing symmetric encryption and decryption method use the same key, so that the security cannot be ensured; each time each pair of users uses the symmetric encryption algorithm, a unique key which is unknown to others needs to be used, so that the number of keys owned by both the sender and the receiver increases in a geometric progression, and key management becomes a burden for the users. The symmetric encryption algorithm is difficult to use in a distributed network system, mainly because of difficult key management and high use cost, and the encryption and decryption of the file has poor security effect and low file loading and reading efficiency.
Devices on the handset and low end are greatly affected by the ability to load files, which can cause the pictures of the game to be jammed and thus reduce the user experience. The data of the loaded file cannot influence the running performance and needs to be effectively protected.
Disclosure of Invention
The present invention is directed to solve at least one of the technical problems in the prior art, and provides a method, an apparatus and a readable medium for symmetric encryption and decryption of a single byte, which can effectively encrypt and decrypt file data and effectively protect the confidentiality of the file.
The technical scheme of the invention comprises a single byte symmetric encryption and decryption method, which comprises an encryption step and a decryption step, and is characterized in that the encryption step comprises the following steps: loading plaintext file data, randomly generating a key to encrypt each byte of data of the plaintext, and outputting the encrypted file data to a ciphertext file to obtain the ciphertext file; the decrypting step includes: and calling the corresponding key which is randomly generated in the memory space to decrypt the ciphertext file, and converting the obtained plaintext data in the memory space into a plaintext file.
According to the single-byte symmetric encryption and decryption method, the number of the keys is 2.
According to the one-byte symmetric encryption and decryption method, the key size is 4 bytes.
According to the single-byte symmetric encryption and decryption method, the encryption mode of encrypting each byte data of the plaintext in the encryption step comprises exclusive OR, remainder and bit operation.
According to the single-byte symmetric encryption and decryption method, the method specifically comprises the following steps: a first encryption step of determining the number of single-byte encryption bits, and processing using cT [ ((K1^ K2)% 5) +2, where cT denotes a single-byte start encryption position, K1 and K2 are keys, ^ is an XOR operation, and ^ is a division operation; a second encryption step of encrypting the single byte according to the single byte start encryption position, and performing shift encryption using cV ═ (((cV > > (8-cT)) + (cV < < cT)) > nK2), where > > and < < are shift operations.
According to the single-byte symmetric encryption and decryption method, the decryption mode of the ciphertext in the encryption step comprises exclusive or, remainder and bit operation.
According to the single-byte symmetric encryption and decryption method, the decryption step specifically comprises the following steps: a first decryption step of determining the number of single-byte decryption bits, and processing the single-byte decryption bits using cT ((K1^ K2)% 5) +2, where cT denotes the single-byte initial decryption position, K1 and K2 are keys, and ^ is an XOR operation,% is a division operation; a second decryption step of decrypting the single byte according to the single byte start decryption position, and performing shift decryption using cV ═ cV ^ nK2 and cV ═ (((cV > > (8-cT)) + (cV < < cT)) > xnk 2), where > > and < < are shift operations.
The technical scheme of the invention also comprises a single-byte symmetric encryption and decryption device, which comprises a memory, a processor and a computer program which is stored in the memory and can run on the processor, and is characterized in that any one of the method steps is realized when the processor executes the computer program.
The technical solution of the present invention also includes a computer-readable storage medium, in which a computer program is stored, where the computer program is characterized in that when being executed by a processor, the computer program implements any of the method steps as described above.
The invention has the beneficial effects that: the file data is encrypted and decrypted efficiently, and the confidentiality of the file is protected effectively.
Drawings
The invention is further described below with reference to the accompanying drawings and examples;
FIG. 1 is a general schematic diagram according to an embodiment of the invention;
FIG. 2 is a flow diagram illustrating encryption according to an embodiment of the present invention;
fig. 3 is a flowchart illustrating decryption according to an embodiment of the present invention.
Detailed Description
Reference will now be made in detail to the present preferred embodiments of the present invention, examples of which are illustrated in the accompanying drawings, wherein like reference numerals refer to like elements throughout.
In the description of the present invention, the meaning of a plurality of means is one or more, the meaning of a plurality of means is two or more, and larger, smaller, larger, etc. are understood as excluding the number, and larger, smaller, inner, etc. are understood as including the number. If the first and second are described for the purpose of distinguishing technical features, they are not to be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated or implicitly indicating the precedence of the technical features indicated.
In the description of the present invention, unless otherwise explicitly defined, terms such as set, etc. should be broadly construed, and those skilled in the art can reasonably determine the specific meanings of the above terms in the present invention in combination with the detailed contents of the technical solutions.
FIG. 1 is a general schematic diagram illustrating an embodiment of the present invention. The encrypting step includes: loading plaintext file data, randomly generating a key to encrypt each byte of data of the plaintext, and outputting the encrypted file data to a ciphertext file to obtain the ciphertext file; the decrypting step includes: and calling the corresponding key which is randomly generated in the memory space to decrypt the ciphertext file, and converting the obtained plaintext data in the memory space into a plaintext file.
Fig. 2 shows an encryption flow chart according to an embodiment of the present invention, wherein 2 random 4-byte keys K1 and K2 are used to process encryption, and each byte encryption process is performed by reading file plaintext data, and the algorithm formula 1 is that step 1 is signed charcT ((K1^ K2)% 5) +2, and step 2 is cV ═(((cV > > (8-cT)) + (cV < < cT)) > nK2), and mainly uses an exclusive-or remainder, and the first and last bits of a single byte are exchanged. And then all data are encrypted and output to a file.
FIG. 3 is a flowchart of decryption process according to an embodiment of the present invention, wherein 2 random 4-byte keys K1 and K2 are used to process decryption, the decryption process is performed by reading the encrypted data of the file for each byte, and step 1 of algorithm formula assigns charcT ((K1^ K2)% 5) + 2; step 2, cV ═ cV ^ nK 2; cv ═ ((Cv < (8-cT)) + (Cv > > cT)); the principle of exchanging the first and the last bits of a single byte mainly adopts the principle of XOR, remainder and the exchange of the first and the last bits of a single byte. And then all the data after decryption is output to the memory.
The embodiments of the present invention have been described in detail with reference to the accompanying drawings, but the present invention is not limited to the above embodiments, and various changes can be made within the knowledge of those skilled in the art without departing from the gist of the present invention.
Claims (9)
1. A single byte symmetric encryption and decryption method comprises an encryption step and a decryption step,
the encrypting step includes:
loading plaintext file data, randomly generating a key to encrypt each byte of data of the plaintext, and outputting the encrypted file data to a ciphertext file to obtain the ciphertext file;
the decrypting step includes:
and calling the corresponding key which is randomly generated in the memory space to decrypt the ciphertext file, and converting the obtained plaintext data in the memory space into a plaintext file.
2. The method for single-byte symmetric encryption and decryption of claim 1, wherein the number of keys is 2.
3. The method of claim 1, wherein the key size is 4 bytes.
4. The method for encrypting and decrypting single-byte symmetry according to claim 1, wherein the encryption step encrypts each byte of data in the plaintext by means of exclusive or, remainder and bit operations.
5. The method for symmetric encryption and decryption of one byte according to claim 4, wherein the steps specifically include:
a first encryption step of determining the number of single-byte encryption bits, and processing using cT [ ((K1^ K2)% 5) +2, where cT denotes a single-byte start encryption position, K1 and K2 are keys, ^ is an XOR operation, and ^ is a division operation;
a second encryption step of encrypting the single byte according to the single byte start encryption position, and performing shift encryption using cV ═ (((cV > > (8-cT)) + (cV < < cT)) > nK2), where > > and < < are shift operations.
6. The method for symmetric encryption and decryption of one byte according to claim 1, wherein the decryption of the ciphertext in the encrypting step comprises an exclusive or, a remainder and a bit operation.
7. The method for symmetric encryption and decryption of one byte according to claim 6, wherein the steps specifically include:
a first decryption step of determining the number of single-byte decryption bits, and processing the single-byte decryption bits using cT ((K1^ K2)% 5) +2, where cT denotes the single-byte initial decryption position, K1 and K2 are keys, and ^ is an XOR operation,% is a division operation;
a second decryption step of decrypting the single byte according to the single byte start decryption position, and performing shift decryption using cV ═ cV ^ nK2 and cV ═ (((cV > > (8-cT)) + (cV < < cT)) > xnk 2), where > > and < < are shift operations.
8. A single-byte symmetric encryption/decryption apparatus comprising a memory, a processor and a computer program stored in said memory and executable on said processor, wherein said processor implements the method steps of any of claims 1-7 when executing said computer program.
9. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the method steps of any one of claims 1 to 8.
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201911149662.4A CN111131158A (en) | 2019-11-21 | 2019-11-21 | Single byte symmetric encryption and decryption method, device and readable medium |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201911149662.4A CN111131158A (en) | 2019-11-21 | 2019-11-21 | Single byte symmetric encryption and decryption method, device and readable medium |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| CN111131158A true CN111131158A (en) | 2020-05-08 |
Family
ID=70496194
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN201911149662.4A Pending CN111131158A (en) | 2019-11-21 | 2019-11-21 | Single byte symmetric encryption and decryption method, device and readable medium |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN111131158A (en) |
Cited By (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN114154175A (en) * | 2021-10-25 | 2022-03-08 | 河北汉光重工有限责任公司 | File encryption method and software based on Windows system |
| CN115913548A (en) * | 2022-12-15 | 2023-04-04 | 河北素数信息安全有限公司 | A symmetric key distribution method and device |
| CN116132020A (en) * | 2023-03-29 | 2023-05-16 | 芯安微众(上海)微电子技术有限公司 | Single byte data encryption and decryption algorithm |
| CN117459327A (en) * | 2023-12-22 | 2024-01-26 | 杭州海康威视数字技术股份有限公司 | A cloud data transparent encryption protection method, system and device |
Citations (7)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20090106552A1 (en) * | 2007-10-20 | 2009-04-23 | Blackout, Inc. | Rights management services-based file encryption system and method |
| CN104966525A (en) * | 2015-01-14 | 2015-10-07 | 腾讯科技(深圳)有限公司 | File encryption method and apparatus, and file decryption method and apparatus |
| CN106878013A (en) * | 2017-03-20 | 2017-06-20 | 网宿科技股份有限公司 | Method and device for encrypting and decrypting files |
| WO2018100246A1 (en) * | 2016-11-30 | 2018-06-07 | Widlund Sam | Method and arrangement for encrypting data |
| CN108334754A (en) * | 2018-01-31 | 2018-07-27 | 山东奥太电气有限公司 | The encrypting and decrypting method and system of embedded system program |
| CN108390759A (en) * | 2018-03-21 | 2018-08-10 | 平安普惠企业管理有限公司 | Code encryption, decryption method, device, computer equipment and storage medium |
| CN109299614A (en) * | 2018-10-30 | 2019-02-01 | 天津津航计算技术研究所 | A kind of system and method for realizing SM4 cryptographic algorithm using pipeline system |
-
2019
- 2019-11-21 CN CN201911149662.4A patent/CN111131158A/en active Pending
Patent Citations (7)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20090106552A1 (en) * | 2007-10-20 | 2009-04-23 | Blackout, Inc. | Rights management services-based file encryption system and method |
| CN104966525A (en) * | 2015-01-14 | 2015-10-07 | 腾讯科技(深圳)有限公司 | File encryption method and apparatus, and file decryption method and apparatus |
| WO2018100246A1 (en) * | 2016-11-30 | 2018-06-07 | Widlund Sam | Method and arrangement for encrypting data |
| CN106878013A (en) * | 2017-03-20 | 2017-06-20 | 网宿科技股份有限公司 | Method and device for encrypting and decrypting files |
| CN108334754A (en) * | 2018-01-31 | 2018-07-27 | 山东奥太电气有限公司 | The encrypting and decrypting method and system of embedded system program |
| CN108390759A (en) * | 2018-03-21 | 2018-08-10 | 平安普惠企业管理有限公司 | Code encryption, decryption method, device, computer equipment and storage medium |
| CN109299614A (en) * | 2018-10-30 | 2019-02-01 | 天津津航计算技术研究所 | A kind of system and method for realizing SM4 cryptographic algorithm using pipeline system |
Cited By (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN114154175A (en) * | 2021-10-25 | 2022-03-08 | 河北汉光重工有限责任公司 | File encryption method and software based on Windows system |
| CN115913548A (en) * | 2022-12-15 | 2023-04-04 | 河北素数信息安全有限公司 | A symmetric key distribution method and device |
| CN116132020A (en) * | 2023-03-29 | 2023-05-16 | 芯安微众(上海)微电子技术有限公司 | Single byte data encryption and decryption algorithm |
| CN117459327A (en) * | 2023-12-22 | 2024-01-26 | 杭州海康威视数字技术股份有限公司 | A cloud data transparent encryption protection method, system and device |
| CN117459327B (en) * | 2023-12-22 | 2024-03-26 | 杭州海康威视数字技术股份有限公司 | Cloud data transparent encryption protection method, system and device |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US10187361B2 (en) | Method for secure communication using asymmetric and symmetric encryption over insecure communications | |
| US10785019B2 (en) | Data transmission method and apparatus | |
| US6125185A (en) | System and method for encryption key generation | |
| CN107086915B (en) | Data transmission method, data sending end and data receiving end | |
| US20150074393A1 (en) | Method, Apparatus, and System for Implementing Media Data Processing | |
| US11128452B2 (en) | Encrypted data sharing with a hierarchical key structure | |
| CN111555880B (en) | Data collision method, device, storage medium and electronic equipment | |
| CN112165443A (en) | Multi-key information encryption and decryption method and device and storage medium | |
| CN111131158A (en) | Single byte symmetric encryption and decryption method, device and readable medium | |
| Gupta et al. | A new way to design and implementation of hybrid crypto system for security of the information in public network | |
| US6996233B2 (en) | System and method for encrypting and verifying messages using three-phase encryption | |
| CA2639649A1 (en) | Cryptography method and system | |
| Koko et al. | Comparison of Various Encryption Algorithms and Techniques for improving secured data Communication | |
| JP6319866B2 (en) | Cryptosystem | |
| US11909893B2 (en) | Composite encryption across cryptographic algorithms | |
| EP3977320A1 (en) | Methods and devices for optimal information-theoretically secure encryption key management | |
| CN111404952A (en) | Substation data encryption transmission method, device, computer equipment and storage medium | |
| CN114499857A (en) | Method for realizing data correctness and consistency in big data quantum encryption and decryption | |
| CN113347144A (en) | Method, system, equipment and storage medium for reciprocal data encryption | |
| WO2018016330A1 (en) | Communication terminal, server device, and program | |
| CN110519226B (en) | Quantum communication server secret communication method and system based on asymmetric key pool and implicit certificate | |
| CN107425959A (en) | A kind of method for realizing encryption, system, client and service end | |
| CN107645488A (en) | Web data storage and data transmission method based on U-shield | |
| CN118282637A (en) | Data transmission method and device and related products | |
| CN113645235A (en) | Distributed data encryption and decryption system and encryption and decryption method |
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 | ||
| RJ01 | Rejection of invention patent application after publication |
Application publication date: 20200508 |
|
| RJ01 | Rejection of invention patent application after publication |