CN111654466A - Data encryption method for electronic valuation balance - Google Patents

Data encryption method for electronic valuation balance Download PDF

Info

Publication number
CN111654466A
CN111654466A CN202010335911.5A CN202010335911A CN111654466A CN 111654466 A CN111654466 A CN 111654466A CN 202010335911 A CN202010335911 A CN 202010335911A CN 111654466 A CN111654466 A CN 111654466A
Authority
CN
China
Prior art keywords
byte
data
random
bit
electronic
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.)
Granted
Application number
CN202010335911.5A
Other languages
Chinese (zh)
Other versions
CN111654466B (en
Inventor
程洪雨
周霖
贺朝辉
万天培
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangdong Xiangshan Electronic Technology Co., Ltd
Zhongshan Camry Electronic Co Ltd
Original Assignee
Zhongshan Camry Electronic Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Zhongshan Camry Electronic Co Ltd filed Critical Zhongshan Camry Electronic Co Ltd
Priority to CN202010335911.5A priority Critical patent/CN111654466B/en
Publication of CN111654466A publication Critical patent/CN111654466A/en
Application granted granted Critical
Publication of CN111654466B publication Critical patent/CN111654466B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/04Network architectures or network communication protocols for network security for providing a confidential data exchange among entities communicating through data packet networks
    • H04L63/0428Network 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
    • GPHYSICS
    • G01MEASURING; TESTING
    • G01GWEIGHING
    • G01G19/00Weighing apparatus or methods adapted for special purposes not provided for in the preceding groups
    • G01G19/40Weighing apparatus or methods adapted for special purposes not provided for in the preceding groups with provisions for indicating, recording, or computing price or other quantities dependent on the weight

Abstract

The invention discloses a data encryption method for an electronic price computing scale, which is characterized in that a 32-bit random number is decomposed into four 8-bit random bytes, the random bytes are randomly inserted into original data of the electronic price computing scale to obtain primary mixed data, then the original data in the primary mixed data are respectively subjected to exclusive or random bytes according to the byte sequence, and finally the 0 th byte or hexadecimal number 0x6B, the 1 st byte high and low four bits are reversed, the 2 nd byte is reversed according to the bit, and the 3 rd byte or hexadecimal number 0x13 are obtained by analogy, so that encrypted data are obtained, the original data in the electronic scale are effectively protected, the electronic scale is not easy to crack and recognize, and further the electronic scale cannot cheat in modes such as a display board imitation; meanwhile, the encryption algorithm is simple and practical, too many CPU resources are not occupied, and the smoothness and the reliability of the system are not influenced.

Description

Data encryption method for electronic valuation balance
[ technical field ]
The invention relates to a data encryption method for an electronic valuation balance.
[ background art ]
At present, most of the communication of the internal parts of the common electronic pricing scales is carried out in an unencrypted or simple encrypted mode. And the data volume is short and easy to crack and recognize. And some lawless persons can utilize the point to modify the electronic scale. For example, the display is forged and the original display is replaced, and the data sent to the display by the electronic scale mainboard is falsified, so that the cheating purpose is achieved.
On the other hand, the existing mainstream general encryption algorithms are huge, occupy a lot of resources and are not suitable for a small CPU inside the electronic scale.
[ summary of the invention ]
The invention overcomes the defects of the technology and provides a data encryption method for the electronic valuation balance.
In order to achieve the purpose, the invention adopts the following technical scheme:
a data encryption method for an electronic pricing scale comprises the following steps:
step a, setting original data of N bytes and a 32-bit random number, decomposing the 32-bit random number into four 8-bit random bytes which are respectively a random byte R0, a random byte R1, a random byte R2 and a random byte R3, setting insertion positions in encrypted data to be P0, P1, P2 and P3 respectively, setting% to be a remainder value, right shifting >, and setting 0x03 to be a hexadecimal number;
b, inserting a random byte R0 into the head end of original data, namely P0 is 0;
step c, inserting the random byte R1 into the position P1, P1 ═ R0% (LENX-1) +1+ ((R0> >4) &0x 03);
step d, inserting the random byte R2 into the position P2, P2 ═ P1+1+ ((R0> >4) &0x 03);
step e, inserting the random byte R3 into the position P3, where P3 is P2+1+ ((R0> >4) &0x03), and obtaining a mixed data;
step f, respectively carrying out exclusive or on random bytes RX according to the byte sequence of the original data in the mixed data, wherein the random bytes RX are random bytes R0, R1, R2 or R3, and X is the original data byte serial number N, and then 1 is added to the remainder of 3 to obtain secondary mixed data;
and g, inverting the high-low four bits of the 0 th byte or the hexadecimal number 0x6B, the 1 st byte, inverting the 2 nd byte by bit, inverting the 3 rd byte or the hexadecimal number 0x13 in the secondary mixed data, and so on to obtain the encrypted data.
The data encryption method for the electronic price computing scale is characterized by comprising the following steps: the 32-bit random number is a 32-bit random number produced by a 24-bit analog-to-digital converter of a load cell in an electronic price computing scale.
The data encryption method for the electronic price computing scale is characterized by comprising the following steps: the new 32-bit random number is the old 32-bit random number x 10+ 24-bit analog-to-digital conversion value% 10.
The data encryption method for the electronic price computing scale is characterized by comprising the following steps: r0 ═ Rand32> >24) &0xFF, R1 ═ Rand32> >16) &0xFF, R2 ═ Rand32> >8) &0xFF, R3(Rand32> >0) &0 xFF.
The invention has the beneficial effects that:
the encryption method of the invention effectively protects the internal original data of the electronic scale, so that the electronic scale is not easy to be cracked and identified, and further the electronic scale cannot cheat the modes of imitating a display panel and the like; meanwhile, the encryption algorithm is simple and practical, too many CPU resources are not occupied, the system smoothness and reliability are not influenced, the data decryption difficulty is high after encryption, and the data is difficult to decompose and extract under the condition of not knowing the algorithm.
[ detailed description of the invention ]
The following is a further detailed description of embodiments of the invention:
a data encryption method for an electronic pricing scale comprises the following steps:
step a, setting original data of N bytes, setting the original data length of the pricing scale to LEN, setting the encrypted data length of the pricing scale to LENX +4, setting a 32-bit random number, and decomposing the 32-bit random number into four 8-bit random bytes, namely a random byte R0, a random byte R1, a random byte R2 and a random byte R3, and setting the insertion positions of the encrypted data to P0, P1, P2 and P3 respectively, wherein% is remainder > > is right shift, & AND, 0x03 is hexadecimal number, wherein R0 & (Rand32> >24) &0xFF, R1 & (Rand32> & 16) &0xFF, & 2 & (Rand 48 > &0xFF, & R3(Rand32> & 0) &0 & 5960 & gtFF, wherein 32 nd is 0 xnd, 32 is sextuple random number;
b, inserting a random byte R0 into the head end of original data, namely P0 is 0;
step c, inserting a random byte R1 into a position P1, wherein P1 is R0% (LENX-1) +1+ ((R0> >4) &0x03), i.e., P1 is R0 remainders LENX-1, adds 1, and adds (R0 right-shifts four bits and hexadecimal number 0x03), wherein when P1 exceeds LENX, (LENX-1) is subtracted, and when P0 coincides with the insertion position P1 moves backward by one position, and likewise cannot exceed LENX after moving;
step d, inserting the random byte R2 into the position P2, P2 ═ P1+1+ ((R0> >4) &0x03), i.e. P2 ═ P1 plus 1, plus (R0 right-shifted by four bits and hexadecimal number 0x03), wherein when P2 exceeds LENX, (LENX-1) is subtracted, and when the random byte coincides with the position of insertion P0, P1, P2 is shifted backward by one position until it does not coincide, and after shifting, LENX cannot be exceeded as well;
step e, random byte R3 inserts position P3, P3 is P2+1+ ((R0> >4) &0x03), i.e., P3 is P2 plus 1, plus (R0 is shifted right four bits and hexadecimal number 0x03), when P3 exceeds LENX, minus (LENX-1), and when it coincides with insertion positions P0, P1, P2, P3 is shifted back one position until it does not coincide, and the shift likewise cannot exceed LENX. At this time, primary mixed data is obtained, wherein the positions of R1, R2 and R3 are not fixed and the sequence is not fixed;
step f, respectively carrying out exclusive or on random bytes RX according to the byte sequence of the original data in the primary mixed data, wherein the random bytes RX are random bytes R0, R1, R2 or R3, and X is the original data serial number N, and then adding 1 to the remainder of 3; that is, the 0 th original byte xor R1, the 1 st original byte xor R2, the 2 nd original byte xor R3, the 3 rd original byte xor R0, and so on, to obtain the secondary mixed data;
and g, performing the following operations on the secondary mixed data according to the byte sequence, namely performing operations on the 0 th byte or hexadecimal number 0x6B, reversing the high and low four bits of the 1 st byte, performing bit inversion on the 2 nd byte, performing exclusive OR on the 3 rd byte or the hexadecimal number 0x13, and so on. And finally, obtaining the encrypted data, wherein the length of the encrypted data is equal to the original data length + 4.
The 32-bit random number is a 32-bit random number generated by a 24-bit analog-to-digital converter of a weighing sensor in the electronic price computing scale, and the new 32-bit random number is the old 32-bit random number multiplied by 10+ 24-bit analog-to-digital conversion value% 10, namely the old 32-bit random number is multiplied by 10, and then the remainder value of the 24-bit analog-to-digital conversion value to 10 is added.
Encryption is realized through three steps, and primary mixed data is obtained through an algorithm of inserting 4 random bytes into original data; carrying out an algorithm of sequentially carrying out XOR encryption on the original data in the primary mixed data and the random number in the primary mixed data to obtain secondary mixed data; and the algorithm is used for sequentially encrypting the secondary mixed data in a whole.
Specific examples are:
example A:
a 10 byte raw data is:
{0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09}
step a, obtaining a 32-bit random number as: 0x34B7391F, and split into four 8-bit random numbers: r0 ═ 0x34, R1 ═ 0xb7, R2 ═ 0x39, R3 ═ 0x 1F;
b-e, calculating four insertion positions in the original data as follows: p0 ═ 0, P1 ═ 4, P2 ═ 8, P3 ═ 12;
the primary mixed data obtained after inserting the random number is:
{0x34,0x00,0x01,0x02,0xB7,0x03,0x04,0x05,0x39,0x06,0x07,0x08,0x1F,0x09};
step f, carrying out exclusive OR on the original data in the primary mixed data according to the byte sequence and the random number in sequence to obtain secondary mixed data:
{0x34,0xB7,0x38,0x1D,0xB7,0xB4,0x3D,0x1A,0x39,0xB1,0x3E,0x17,0x 1F,0xBE};
step g, encrypting the secondary mixed data according to the byte sequence to obtain the encrypted data with the final length of 14 as follows:
{0x5F,0x7B,0xC7,0x0E,0xDC,0x4B,0xC2,0x09,0x52,0x1B,0xC1,0x04,0x 74,0xEB}。
example B:
a 10 byte raw data is:
{0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09};
step a, obtaining 32-bit random digits: 0x52B65A9B, split into four 8-bit random numbers: r0 ═ 0x52, R1 ═ 0xB6, R2 ═ 0x5A, R3 ═ 0x 9B;
b-e, calculating four insertion positions in the original data as follows: p0-0, P1-6, P2-8, P3-10
Inserting random numbers into the primary mixed data:
{0x52,0x00,0x01,0x02,0x03,0x04,0xB6,0x05,0x5A,0x06,0x9B,0x07,0x08,0x09};
step f, carrying out exclusive OR on the original data in the primary mixed data according to the byte sequence and the random number in sequence to obtain secondary mixed data:
{0x52,0xB6,0x5B,0x99,0xB5,0x5E,0xB6,0x9E,0x5A,0xB0,0x9B,0x5D,0x 93,0xBF};
step g, encrypting the secondary mixed data according to the byte sequence to obtain the encrypted data with the final length of 14 as follows:
{0x39,0x6B,0xA4,0x8A,0xDE,0xE5,0x49,0x8D,0x31,0x0B,0x64,0x4E,0x F8,0xFB}。
when decoding, the encrypted data is decrypted reversely according to the steps g and f, and then the four inserted random bytes R0, R1, R2 and R3 are taken out respectively according to the steps a to e.

Claims (4)

1. A data encryption method for an electronic pricing scale comprises the following steps:
step a, setting original data of N bytes and a 32-bit random number, wherein the original data length of the pricing scale is LEN, the encrypted data length of the pricing scale is LENX ═ LEN +4, and the 32-bit random number is decomposed into four 8-bit random bytes which are respectively a random byte R0, a random byte R1, a random byte R2 and a random byte R3, and meanwhile, the insertion positions in the encrypted data are respectively P0, P1, P2 and P3, and% is a remainder value, > > is a right shift, > & is an AND, and 0x03 is a hexadecimal number;
b, inserting a random byte R0 into the head end of original data, namely P0 is 0;
step c, inserting the random byte R1 into the position P1, P1 ═ R0% (LENX-1) +1+ ((R0> >4) &0x 03);
step d, inserting the random byte R2 into the position P2, P2 ═ P1+1+ ((R0> >4) &0x 03);
step e, inserting the random byte R3 into the position P3, where P3 is P2+1+ ((R0> >4) &0x03), and obtaining a mixed data;
step f, respectively carrying out exclusive or on random bytes RX according to the byte sequence of the original data in the primary mixed data, wherein the random bytes RX are random bytes R0, R1, R2 or R3, and X is the original data byte serial number N, and then adding 1 to the remainder of 3 to obtain secondary mixed data;
and g, inverting the high-low four bits of the 0 th byte or the hexadecimal number 0x6B, the 1 st byte, inverting the 2 nd byte by bit, inverting the 3 rd byte or the hexadecimal number 0x13 in the secondary mixed data, and so on to obtain the encrypted data.
2. A data encryption method for an electronic pricing scale according to claim 1, characterized by: the 32-bit random number is a 32-bit random number produced by a 24-bit analog-to-digital converter of a load cell in an electronic price computing scale.
3. A data encryption method for an electronic pricing scale according to claim 2, characterized in that: the new 32-bit random number is the old 32-bit random number x 10+ 24-bit analog-to-digital conversion value% 10.
4. A data encryption method for an electronic pricing scale according to claim 1, characterized by: r0 ═ Rand32> >24) &0xFF, R1 ═ Rand32> >16) &0xFF, R2 ═ Rand32> >8) &0xFF, R3(Rand32> >0) &0xFF, where Rand32 is a 32-bit random number and 0xFF is a hexadecimal number.
CN202010335911.5A 2020-04-25 2020-04-25 Data encryption method for electronic valuation balance Active CN111654466B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010335911.5A CN111654466B (en) 2020-04-25 2020-04-25 Data encryption method for electronic valuation balance

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010335911.5A CN111654466B (en) 2020-04-25 2020-04-25 Data encryption method for electronic valuation balance

Publications (2)

Publication Number Publication Date
CN111654466A true CN111654466A (en) 2020-09-11
CN111654466B CN111654466B (en) 2022-03-01

Family

ID=72348504

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010335911.5A Active CN111654466B (en) 2020-04-25 2020-04-25 Data encryption method for electronic valuation balance

Country Status (1)

Country Link
CN (1) CN111654466B (en)

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP2395697A1 (en) * 2010-06-14 2011-12-14 Guiseppe Scala Method for cryptography of a binary file
CN105591737A (en) * 2016-01-27 2016-05-18 浪潮(北京)电子信息产业有限公司 Data encryption, decryption and transmission methods and systems
CN105897417A (en) * 2016-04-01 2016-08-24 广东欧珀移动通信有限公司 Encrypted data input method and encrypted data input device
WO2016206504A1 (en) * 2015-06-25 2016-12-29 中兴通讯股份有限公司 Data encryption method, decryption method and apparatus
CN107465505A (en) * 2017-08-28 2017-12-12 阿里巴巴集团控股有限公司 A kind of key data processing method, device and server
CN109104724A (en) * 2018-06-30 2018-12-28 江苏恒宝智能系统技术有限公司 A kind of data ciphering method and device for device upgrade
CN109429222A (en) * 2017-08-22 2019-03-05 马鞍山明阳通信科技有限公司 A kind of pair of Wireless Communication Equipment upgrade procedure and the method for communication data encryption

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP2395697A1 (en) * 2010-06-14 2011-12-14 Guiseppe Scala Method for cryptography of a binary file
WO2016206504A1 (en) * 2015-06-25 2016-12-29 中兴通讯股份有限公司 Data encryption method, decryption method and apparatus
CN105591737A (en) * 2016-01-27 2016-05-18 浪潮(北京)电子信息产业有限公司 Data encryption, decryption and transmission methods and systems
CN105897417A (en) * 2016-04-01 2016-08-24 广东欧珀移动通信有限公司 Encrypted data input method and encrypted data input device
CN109429222A (en) * 2017-08-22 2019-03-05 马鞍山明阳通信科技有限公司 A kind of pair of Wireless Communication Equipment upgrade procedure and the method for communication data encryption
CN107465505A (en) * 2017-08-28 2017-12-12 阿里巴巴集团控股有限公司 A kind of key data processing method, device and server
CN109104724A (en) * 2018-06-30 2018-12-28 江苏恒宝智能系统技术有限公司 A kind of data ciphering method and device for device upgrade

Also Published As

Publication number Publication date
CN111654466B (en) 2022-03-01

Similar Documents

Publication Publication Date Title
Wang et al. A new image encryption algorithm based on chaos
JP4823904B2 (en) Data encryption apparatus and data encryption method
CA2333095C (en) Improved des and other cryptographic processes with leak minimization for smartcards and other cryptosystems
US9274979B2 (en) System, method, and computer program product for optimizing data encryption and decryption by implementing asymmetric AES-CBC channels
US20130014267A1 (en) Computer protocol generation and obfuscation
US9537651B2 (en) Information processing apparatus, information processing method, and program
CN107395368A (en) Without the digital signature method in media environment and solution encapsulating method and decryption method
Alharam et al. The effects of cyber-security on healthcare industry
KR20000076501A (en) Data encryption apparatus and method
CN102983972B (en) Dynamic encryption and decryption method based on stream cipher
CN107980212A (en) The encryption method and computer-readable recording medium of anti-DPA attacks
CN102752108B (en) Magic cube encryption and decryption method
CN111654466B (en) Data encryption method for electronic valuation balance
Gui et al. Security vulnerabilities of smart meters in smart grid
CN107483182A (en) A kind of anti-power consumption attack method towards aes algorithm based on Out-of-order execution
CN107332833A (en) Method of calibration and device
CN102957534B (en) The method and system of a kind of multiple terminals unified identity authentication
CN110515591B (en) Random number generation method and device based on block chain
Wang et al. Improved lightweight encryption algorithm based on optimized S-box
CN105357206A (en) Secure video transmission method
Yasmin et al. Modified lightweight GIFT cipher for security enhancement in resource-constrained IoT devices
CN111614457A (en) P replacement improvement-based lightweight packet encryption and decryption method, device and storage medium
CN103338447B (en) A kind of self-access encryption and decryption circuit being applied to short-distance transmission
CN108052836B (en) Anti-tampering method and device for patch package and server
CN103649935A (en) Method and system for cryptographic processing core

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
TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20220322

Address after: 528400 BaiShaWan Industrial Park, east of qiwan Road, East District, Zhongshan City, Guangdong Province, adds a business site, specifically 6 floors, building 6, Fuwan Industrial Zone, East District, Zhongshan City (one photo and multiple addresses)

Patentee after: ZHONGSHAN CAMRY ELECTRONIC Co.,Ltd.

Patentee after: Guangdong Xiangshan Electronic Technology Co., Ltd

Address before: 528400 BaiShaWan Industrial Park, east of qiwan Road, East District, Zhongshan City, Guangdong Province

Patentee before: ZHONGSHAN CAMRY ELECTRONIC Co.,Ltd.