Eight-bit numeric data encryption algorithm
By employing a data encryption process involving comparison with 5 bits, left-right distribution of bit numbers, and generation of dynamic keys, the security and efficiency issues of existing encryption algorithms in 8-bit numerical classified data transmission are resolved. This achieves high-security, low-redundancy encryption and simplifies programming implementation.
Patent Information
- Application Number
- CN202511010268.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-22
- Publication Date
- 2025-11-18
AI Technical Summary
Existing encryption algorithms are easy to decipher 8-bit numerical classified data, have high data redundancy, and are complex to implement, making it difficult to meet the security and efficiency requirements of measurement and control equipment.
The data encryption process employs a 5-bit comparison process, left and right distribution by bit number, generation of dynamic keys, and combination by bit number. Data transmission is performed through XOR operation and a pre-defined frame structure.
It achieves high security and low redundancy encryption, is simple to program, and is compatible with existing measurement and control communication protocols.
Smart Images

Figure CN120979640A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application relates to an 8-bit numerical data encryption algorithm, and belongs to the technical field of software engineering, and is especially suitable for the transmission encryption of secret 8-bit numerical data such as frequency in a measurement and control device. BACKGROUND
[0002] In order to complete the measurement of the measurement and control device, a frequency source with a flexible settable frequency needs to be configured to meet the test and calibration requirements. As secret information, the frequency can be completed as 8-bit numerical data, and the transmission thereof needs to be encrypted to ensure security.
[0003] The existing conventional encryption algorithms (such as DES, RSA, SHA, AES, ECC, etc.) have the problem of easy decryption, and are difficult to meet the encryption requirements of secret data. The "coding modulation encryption method" commonly used in measurement and control communication will cause the byte number of data to be multiplied, and the programming implementation is difficult. In addition, the fixed key encryption mode has strong predictability of the key, and the decryption difficulty is extremely low. If the non-fixed key generation logic is complex, the engineering implementation cost will be increased.
[0004] Therefore, the application designs an 8-bit numerical data encryption algorithm to solve the problems of security, efficiency and implementation difficulty of the existing encryption mode in the transmission of secret 8-bit numerical data. SUMMARY
[0005] The technical problem to be solved by the application is to provide an implementation method of an 8-bit numerical data encryption algorithm to solve the problems of low decryption difficulty, large data redundancy and complex implementation of the existing encryption mode for 8-bit numerical secret data encryption, and to realize the encryption effect of "clear principle, simple structure, high security and easy programming implementation".
[0006] The technical scheme adopted by the application to solve the above problems is an 8-bit numerical data encryption algorithm, which realizes encryption through the process of "comparing with 5 -> distributing according to bit number -> generating key -> combining data according to bit number -> XORing data and key -> transmitting according to the agreed frame structure", and the specific steps are as follows: Step 1, comparing and processing the size data with 5 Each bit (unit, ten, hundred, thousand, ten thousand, hundred thousand, million, ten million) of the 8-bit data is compared with 5, and new data is generated according to the rules: If the numerical value of the bit is less than 5, the new numerical value is 5 minus the original numerical value. If the numerical value of the bit is greater than 5, the new numerical value is the original numerical value minus 5. If the numerical value of the bit is equal to 5, the new numerical value is uniformly set to 0.
[0007] Step 2, distributing according to bit number 8-bit data is distributed in the order of "units to ten million" (bit number definition: units correspond to bit number 1, tens correspond to bit number 2, hundreds correspond to bit number 3, thousands correspond to bit number 4, ten thousands correspond to bit number 5, hundred thousands correspond to bit number 6, million correspond to bit number 7, ten million correspond to bit number 8), combined with the results of comparison with 5 left and right distribution: Pre-set rule: numbers greater than 5 are distributed in the left / right 8-bit area, and numbers less than 5 are distributed in the right / left 8-bit area; Supplementary explanation: both left and right areas are 8 bits (corresponding to bit numbers 1-8), and the value = 5 bit can be placed on the left or right; When distributing, fill in the corresponding bit number position (such as the ten-bit value distributed to the left / right bit number 2 position).
[0008] Step three, key generation Generate the key based on the left and right distribution results of step 2: In the left 8-bit area, the bit number with data (i.e. the bit number filled with value in step 2) is set to 1, and the bit number without data (i.e. the bit number without value filled) is set to 0, forming an 8-bit binary number, which is used as the left key; The right 8-bit area generates an 8-bit binary number according to the same rule, which is used as the right key; Supplementary explanation: the key is in binary form and participates in subsequent operations, and can be converted to hexadecimal (such as binary 10001111 corresponding to hexadecimal 8F) when actually transmitted.
[0009] Step four, data processing by bit number According to the value distribution of the left and right areas, the bit numbers are sorted from small to large (bit number 1→bit number 8), and every two value combinations are combined into a byte (hexadecimal): If both bits have values, combine them directly (such as bit number 1 value 3, bit number 2 value 0, combined as 30); If one bit has no value (i.e. the bit is a dataless bit), replace it with the corresponding area key (such as left bit number 3 without data, filled with left key); Supplementary explanation: if two consecutive bits are dataless bits, they are still filled with keys; If all 0 data (such as 00) appears after combination, it is kept as a placeholder and marked as invalid data (eliminated in subsequent steps) during transmission.
[0010] Step five, data and key processing XOR the left and right combined data generated in step 4 with the corresponding area key respectively: Left combined data→XOR with left key; Right combination data XOR with right key; Supplementary note: XOR operation is performed at byte level (e.g. combination data 30 XOR with key 8F). Step six, agreed format frame transmission The encrypted data is encapsulated and transmitted according to the following frame structure: | Field | Length (bytes) | Description | |------------|--------------|---------------------------------------| | Frame header | 1 | Fixed value 0xAA (used to identify the start of the frame, which can be modified according to the actual scene) | | Bit number (key) | 2 | Left key (1 byte) + right key (1 byte) (stored in hexadecimal form) | | Data length | 2 | Left effective data length (1 byte) + right effective data length (1 byte) (number of data after removing all 0 placeholders) | | Data | 8 | Left XOR data (first 4 bytes) + right XOR data (last 4 bytes) (with placeholders) | | Frame trailer | 1 | Fixed value 0x55 (used to identify the end of the frame, which can be modified according to the actual scene) |.
[0011] Compared with the prior art, the present application has the following beneficial effects: 1. High security: multi-level processing of "data preprocessing → left and right distribution → dynamic key → XOR operation", the key changes with the original data (non-fixed key), greatly improving the difficulty of decryption; 2. Low data redundancy: the length of the encrypted data is fixed (1+2+2+8+1=14 bytes), without byte number multiplication problem; 3. Easy to implement: algorithm logic is based on basic numerical comparison and binary operation, with low programming difficulty, which can be quickly integrated into the communication module of the measurement and control device; 4. Strong compatibility: standardized frame structure, supporting adaptation with existing measurement and control communication protocols. BRIEF DESCRIPTION OF DRAWINGS
[0012] Figure 1: Encryption process example of the present application (taking original data 28794321 as an example, showing the complete process of "preprocessing → distribution → key generation → combination → XOR").
[0013] Figure 2: Frame structure diagram of the present application (annotating the position and length of each field). DETAILED DESCRIPTION
[0014] Reference Fig. 1-2 Take the frequency data of the monitoring equipment "2879.4321" (complete as 8-digit numeric data, ignore 28794321 after the decimal point) as an example, and explain the encryption and decryption process in detail: Encryption process Comparison with 5 Each bit of the original data (10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000) is compared with 5: 2<5→5-2=3; 8>5→8-5=3; 7>5→7-5=2; 9>5→9-5=4; 4<5→5-4=1; 3<5→5-3=2; 2<5→5-2=3; 1<5→5-1=4; Generate preprocessed data: 3 (10000000), 3 (10000000), 2 (10000000), 4 (10000000), 1 (10000000), 2 (10000000), 3 (10000000), 4 (10000000).
[0015] Bit number distribution Bit number definition: unit (bit number 1), ten (bit number 2), hundred (bit number 3), thousand (bit number 4), ten thousand (bit number 5), hundred thousand (bit number 6), million (bit number 7), ten million (bit number 8); Distribution rule: >5 numbers (including 8, 7, 9 in preprocessed data, new data on corresponding bits is 3, 2, 4) → right side; <5 numbers → left side (including 2, 4, 3, 2, 1 in preprocessed data, new data on corresponding bits is 3, 1, 2, 3, 4); Supplement: The actual distribution result is that the bit numbers 1-8 on the right side correspond to the value.324....; The bit numbers 1-8 on the left side correspond to the value 3...1234.
[0016] Key generation Left side: 3...1234→binary 10001111→hexadecimal 8F (left key); Right side:.324....→binary 01110000→hexadecimal 70 (right key).
[0017] Data bit number processing Right side bit number 1-8 sequence combination (each two bits a group): The data is processed by bit number, that is, according to the data distribution from top to bottom or from bottom to top, two by two data is formed in sequence, and all 0 data is replaced by a key. The left side data is 30 BF 12 34, and the right side data is 03 24 70 70.
[0018] Data and key processing The data and key processing is to perform XOR operation on the processed data and the key, and form new data. 30, BF, 12, 34 are XORed with 8F to become BF 00 9D BB, and 03, 24, 70, 70 are XORed with 70 to become 73 54 00 00. Here, 00 is only a placeholder.
[0019] Format frame packaging Frame header: 0xFF; Bit number (key): left key 8F + right key 70 → 8F70; Data length: left effective data 3 (remove all 0 data, corresponding data is BF 9D BB) + 02 right effective data 2 (remove all 0 data, corresponding data is 73 54) → 0302; Data: left data (fill BF 00 9D BB) + right encrypted data (fill 73 54 00 00) → BF 009D BB 73 54 00 00; Frame tail: FE; Final transmission frame: FF 8F 70 03 02 BF 00 9D BB 73 54 00 00 FE.
[0020] Decryption process Decryption is the inverse process of encryption. Taking the received frame "FF 8F 70 03 02 BF 00 9D BB 73 54 00 00 FE" as an example: Frame analysis: extract key (left 8F, right 70), effective data (left BF 00 9D BB; right 73 54 00 00); XOR inverse operation: left encrypted data XOR left key 8F → 30, 00, 12, 34; right encrypted data XOR right key 70 → 03, 24, 00, 00; Combine data split: left split 30 → bit number 1 (3), bit number 2 (0); 00 → bit number 3 (0), bit number 4 (0); 12 → bit number 5 (1), bit number 6 (2); 34 → bit number 7 (3), bit number 8 (4); Right side split 03→bit number 1(0), bit number 2(3); 24→bit number 3(2), bit number 4(4); 00→bit number 5(0), bit number 6(0); 00→bit number 7(0), bit number 8(0); Pretreatment data restoration: according to the inverse operation of "5 minus 5- original number" (original number = 5- pretreatment data), the data left of 0 is processed by 5 minus, and the right data is processed by 5 plus: Left side: bit number 1(3)→5-3=2; bit number 5(1)→5-1=4; bit number 6(2)→5-2=3; bit number 7(3)→5-3=2, bit number 8(4)→5-4=1; get 20004321 Right side: bit number 2(3)→5+3=8; bit number 3(2)→5+2=7, bit number 4(4)→5+4=9; get 08790000 Original data splicing: according to bit number 8(million bit) to bit number 1(bit) splicing→2(million bit), 8(million bit), 7(100000 bit), 9(10000 bit), 4(1000 bit), 3(100 bit), 2(10 bit), 1(bit)→28794321 (combined with original frequency format to restore 2879.4321).
[0021] In addition to the above embodiments, the present application also includes other embodiments, any technical solutions formed by using equivalent transformation or equivalent replacement shall fall within the protection scope of the claims of the present application.
Claims
1. An 8-bit numeric data encryption algorithm, characterized by, The method comprises the following steps: (1) Comparing 8-bit data with 5: each bit of the 8-bit data is compared with 5, if <5, the new value = 5 - original number, if >5, the new value = original number - 5, if =5, the new value = 0; (2) Distributing according to bit number: according to the bit sequence from "unit place to ten million place", the numbers >5 are distributed in the left / right 8-bit area, and the numbers <5 are distributed in the right / left 8-bit area; (3) Key generation: the bit numbers with data in the left and right areas are set to 1, and the bit numbers without data are set to 0, forming an 8-bit binary key: left key and right key; (4) Data processing according to bit number: according to the order from small to large, each two-bit value combination is 1 byte, and the data bit is filled with the corresponding key; (5) Data and key processing: the combined data on the left and right sides are subjected to XOR operation with the corresponding keys; (6) Transmission of agreed format frame: encapsulation and transmission according to "1-byte frame header + 2-byte key + 2-byte data length + 8-byte encrypted data + 1-byte frame tail".
2. The 8-bit numeric data encryption algorithm according to claim 1, characterized in that: In step (1), the "bit" of 8-bit data refers to unit place, ten place, hundred place, thousand place, ten thousand place, hundred thousand place, million place, and ten million place, and the data needs to be completed to 8 bits, and the high bits less than 8 bits are filled with 0.
3. The 8-bit numeric data encryption algorithm of claim 1, wherein: In step (3), the key is generated in binary form, converted to hexadecimal during transmission, and the key changes with the original data, which is not a fixed value.
4. The 8-bit numeric data encryption algorithm of claim 1, wherein: In step (6), the frame header is fixed as FF, and the frame tail is fixed as FE, which can be modified by negotiation, and the data length is the number of valid data after removing the all-0 placeholder.
5. The 8-bit numeric data encryption algorithm of claim 1, wherein: When decrypting, the inverse process of "frame analysis → XOR inverse operation → combined data splitting → preprocessed data restoration → original data splicing" is performed.