CN112637225A - Data sending method, data receiving method, client and server - Google Patents

Data sending method, data receiving method, client and server Download PDF

Info

Publication number
CN112637225A
CN112637225A CN202011575388.XA CN202011575388A CN112637225A CN 112637225 A CN112637225 A CN 112637225A CN 202011575388 A CN202011575388 A CN 202011575388A CN 112637225 A CN112637225 A CN 112637225A
Authority
CN
China
Prior art keywords
data
byte
transmitted
custom
sub
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
CN202011575388.XA
Other languages
Chinese (zh)
Other versions
CN112637225B (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.)
Xiamen Meiya Pico Information Co Ltd
Original Assignee
Xiamen Meiya Pico Information 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 Xiamen Meiya Pico Information Co Ltd filed Critical Xiamen Meiya Pico Information Co Ltd
Priority to CN202011575388.XA priority Critical patent/CN112637225B/en
Publication of CN112637225A publication Critical patent/CN112637225A/en
Application granted granted Critical
Publication of CN112637225B publication Critical patent/CN112637225B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

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
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/20Network architectures or network communication protocols for network security for managing network security; network security policies in general
    • H04L63/205Network architectures or network communication protocols for network security for managing network security; network security policies in general involving negotiation or determination of the one or more network security mechanisms to be used, e.g. by negotiation between the client and the server or between peers or by selection according to the capabilities of the entities involved
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/06Protocols specially adapted for file transfer, e.g. file transfer protocol [FTP]

Abstract

The invention discloses a data sending method, a data receiving method, a client and a server, wherein a custom byte coding rule is negotiated with the server; encrypting and packaging data to be transmitted according to the custom byte encoding rule; sending the encapsulated data to the server, and decapsulating and decrypting the encapsulated data through the server according to the custom byte encoding rule to obtain the data to be transmitted; because the coding rule is self-defined, even if the data is stolen in the transmission process, the data cannot be decoded, and the safety of the data transmission process is improved.

Description

Data sending method, data receiving method, client and server
Technical Field
The present invention relates to the field of data file transmission, and in particular, to a data sending method, a data receiving method, a client, and a server.
Background
With the rapid development of information technology, the security of data information becomes more and more important. The rapid transmission and exchange of information are the requirements of the information age, data is the basis for bearing information, and the information exchange cannot be independent of the transmission of the data. However, in data transmission, data is continuously attacked in all aspects, intentionally or unintentionally, the security of data information is threatened, and besides computer virus threats, the transmission threats of various data interception, interruption, tampering, counterfeiting and the like to the data are also serious. Therefore, technologies such as identity authentication, digital signature, data encryption and the like are carried forward, and particularly, the data encryption provides a good solution for data transmission.
At present, information exchange or file transmission in many systems only adopts a weak encryption mode or a non-encryption mode; meanwhile, most File transmission is based on common protocols such as common File Transfer Protocol (FTP), security problems are easily ignored, and the transmission process is easily intercepted and forged.
Because most of the existing systems basically transmit data through FTP and the like, a plurality of default non-encryption modes are adopted, even if encryption is basically used for a database or sensitive fields, files possibly contain a large amount of contents, the use of a complex encryption algorithm can expand the packaged data, network resources are occupied in transmission, and the transmission performance is reduced. At the FTP client and the server, data are transmitted in a plaintext form by default, and anyone with control capability on the route on the communication path can acquire the data by sniffing. Although the FTP can be encapsulated by SSL (Secure Sockets Layer), the FTP transfers data through a cumbersome exchange handshake, and even if the password is protected, it is difficult to ensure the security of the data transfer.
Disclosure of Invention
The technical problem to be solved by the invention is as follows: the data sending method, the data receiving method, the client and the server are provided, and the safety in the data transmission process is improved.
In order to solve the technical problems, the invention adopts a technical scheme that:
a method for transmitting data, comprising the steps of:
negotiating a custom byte encoding rule with a server;
encrypting and packaging data to be transmitted according to the custom byte encoding rule;
and sending the encapsulated data to the server, and decapsulating and decrypting the encapsulated data through the server according to the custom byte encoding rule to obtain the data to be transmitted.
In order to solve the technical problem, the invention adopts another technical scheme as follows:
a data receiving method, comprising the steps of:
negotiating a custom byte encoding rule with a client;
receiving encapsulated data sent by a client, wherein the encapsulated data is obtained by encrypting and encapsulating data to be transmitted by the client according to the custom byte coding rule;
and decapsulating and decrypting the encapsulated data according to the custom byte encoding rule to obtain the data to be transmitted.
In order to solve the technical problem, the invention adopts another technical scheme as follows:
a client comprising a first memory, a first processor and a first computer program stored on the first memory and executable on the first processor, the first computer program, when executed by the first processor, implementing the steps of a data transmission method as described above.
In order to solve the technical problem, the invention adopts another technical scheme as follows:
a server comprising a second memory, a second processor and a second computer program stored on said second memory and executable on said second processor, said second computer program, when executed by the second processor, implementing the steps of a data receiving method as described above.
The invention has the beneficial effects that: the data to be transmitted is packaged and encrypted through the custom coding rule, the server side needs to analyze the packaged and encrypted data to be transmitted through the same custom coding rule to obtain corresponding original data, and the coding rule is self-defined by negotiation between the client side and the server side and has dynamic performance, so that the data cannot be decoded even if being stolen in the transmission process, and the safety of the data transmission process is improved.
Drawings
Fig. 1 is a flowchart illustrating steps of a data transmission method according to an embodiment of the present invention;
fig. 2 is a flowchart illustrating steps of a data receiving method according to an embodiment of the present invention;
FIG. 3 is a flow chart of data transmission according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram of a client according to an embodiment of the present invention;
fig. 5 is a schematic structural diagram of a server according to an embodiment of the present invention;
fig. 6 is a schematic view illustrating an instruction interaction flow between a client and a server according to an embodiment of the present invention.
Detailed Description
In order to explain technical contents, achieved objects, and effects of the present invention in detail, the following description is made with reference to the accompanying drawings in combination with the embodiments.
Referring to fig. 1, an embodiment of the present invention provides a method for sending data, including:
negotiating a custom byte encoding rule with a server;
encrypting and packaging data to be transmitted according to the custom byte encoding rule;
and sending the encapsulated data to the server, and decapsulating and decrypting the encapsulated data through the server according to the custom byte encoding rule to obtain the data to be transmitted.
From the above description, the beneficial effects of the present invention are: the data to be transmitted is packaged and encrypted through the custom coding rule, the server side needs to analyze the packaged and encrypted data to be transmitted through the same custom coding rule to obtain corresponding original data, and the coding rule is self-defined by negotiation between the client side and the server side and has dynamic performance, so that the data cannot be decoded even if being stolen in the transmission process, and the safety of the data transmission process is improved.
Further, the data transmission method further includes the steps of:
negotiating an instruction encoding rule with the server, wherein different instruction codes correspond to different instructions;
encrypting and packaging the data to be transmitted according to the custom byte encoding rule comprises the following steps:
attaching an instruction code corresponding to the instruction type to the data to be transmitted according to the instruction type to be transmitted and the instruction coding rule;
and encrypting and packaging the data to be transmitted attached with the instruction codes according to the custom byte encoding rule.
According to the description, the data to be transmitted is also attached with the instruction codes corresponding to the instruction types, and the server side can perform communication between the server side and the client side according to the instruction codes after receiving and decrypting the data to be transmitted sent by the client side, so that a frequent handshake protocol is avoided, and the data transmission efficiency is improved.
Further, the encrypting and packaging the data to be transmitted according to the custom byte encoding rule includes:
generating a word segment;
the byte section comprises a first byte section and a second byte section;
encrypting the data to be transmitted by adopting a TEA algorithm to obtain encrypted data to be transmitted;
writing the encrypted data to be transmitted into the first byte section;
and writing the first decrypted data corresponding to the encrypted data to be transmitted into the second byte section.
According to the above description, the data to be transmitted is encrypted through the TEA algorithm, the first decrypted data is written into the field generated by the custom coding rule, and the data to be transmitted is encrypted and encapsulated through the TEA algorithm and the custom coding rule, so that the difficulty of data decoding is improved, and the safety of data transmission is further ensured.
Further, the field also includes a third field;
the third byte section comprises two bytes, and mutually associated random numbers are written in the two bytes and form magic number constants;
the writing the first decrypted data corresponding to the encrypted data to be transmitted into the second byte section includes:
the second byte section comprises four sub-byte sections;
writing a random number in the first sub-field;
determining a number of bytes of a second sub-byte based on a size of the random number written in the first sub-byte;
randomly writing an arbitrary random number smaller than the one random number in each byte in the second sub-byte section;
XOR the random number stored in the last byte in the second sub-byte section and the encryption round number of the TEA algorithm, and writes the value obtained by XOR into a third sub-byte section;
the length of data to be transmitted is written to the fourth sub-byte segment.
As can be seen from the above description, the field segment further includes a magic number constant, and the second field segment of the field segment encapsulates the first decrypted data in a ring-and-loop manner, so that the security of the first decrypted data is ensured, even if the data is stolen by a third party in the transmission process, the third party cannot analyze the data to be transmitted, the security of output transmission is improved, and meanwhile, the magic number constant prevents the data from being tampered and misread, thereby further ensuring the security of output transmission.
Referring to fig. 2, an embodiment of the present invention provides a data receiving method, including:
negotiating a custom byte encoding rule with a client;
receiving encapsulated data sent by a client, wherein the encapsulated data is obtained by encrypting and encapsulating data to be transmitted by the client according to the custom byte coding rule;
and decapsulating and decrypting the encapsulated data according to the custom byte encoding rule to obtain the data to be transmitted.
As can be seen from the above description, the encapsulated data received according to the client transmission request can be decapsulated and decrypted only by the custom coding rule negotiated with the client, so that even if a third party steals the transmitted data, the original data cannot be obtained by parsing, thereby ensuring the security of data transmission.
Further, the data receiving method further comprises the steps of:
negotiating an instruction encoding rule with the client, wherein different instruction encodings correspond to different instructions;
the decapsulating and decrypting the encapsulated data according to the custom byte encoding rule to obtain the data to be transmitted includes:
decapsulating and decrypting the encapsulated data according to the custom byte encoding rule to obtain the data to be transmitted, wherein the data to be transmitted comprises an instruction code;
determining an instruction type corresponding to the instruction code according to the instruction coding rule;
and feeding back the received data through a response instruction matched with the instruction type.
According to the description, after the server receives and decrypts the data to be transmitted sent by the client, the server can determine the instruction type according to the instruction code in the data to be transmitted and feed back the instruction type to the client, and the client and the server communicate in an instruction mode, so that a frequent handshake protocol between the client and the server is avoided, and the efficiency of data transmission is improved.
Further, the packaged data is a word segment;
the byte section comprises a first byte section and a second byte section;
the decapsulating and decrypting the encapsulated data according to the custom byte encoding rule to obtain the data to be transmitted includes:
acquiring first decrypted data corresponding to the encrypted data to be transmitted from the second byte section according to the custom coding rule;
acquiring encrypted data to be transmitted from the first byte section according to the custom coding rule;
and decrypting the encrypted data to be transmitted according to the first decryption data to obtain the data to be transmitted.
As can be seen from the above description, the encrypted data to be transmitted and the first decrypted data need to be obtained by decrypting the first byte segment and the second byte segment according to the customized encoding rule, and the encrypted data to be transmitted can be obtained by decrypting the encrypted data to be transmitted according to the first decrypted data and the encrypted and decrypted plaintext password embedded in the program.
Further, the second byte section comprises four sub-byte sections;
the step of decrypting the second byte section according to a custom coding rule to obtain first decrypted data corresponding to the encrypted data to be transmitted comprises the following steps:
analyzing according to the self-defined coding rule to obtain a random number stored in a first sub-byte section in the second byte section, and determining the number of bytes of the second sub-byte section according to the size of the random number;
analyzing according to the custom coding rule to obtain a random number stored in the last byte in the second sub-byte in the second byte section;
analyzing and obtaining data stored in a third sub-byte in the second byte according to the custom coding rule, and obtaining an encryption round number according to the data stored in the third sub-byte and a random number stored in the last byte in the second sub-byte;
analyzing according to the custom coding rule to obtain the length of data to be transmitted in a fourth sub-field in the second field;
and decrypting the encrypted data to be transmitted according to the encryption round number, the length of the data to be transmitted and a built-in encryption and decryption plaintext password to obtain the data to be transmitted.
According to the description, the first decrypted data is analyzed layer by layer through the custom coding rule, the encryption round number and the length of the data to be transmitted can be finally obtained, the encrypted data to be transmitted can be obtained only by combining the encryption round number and the length of the data to be transmitted, the security of the first decrypted data in the transmission process is improved, and the security of the data in the transmission process is further ensured.
Referring to fig. 4, an embodiment of the present invention provides a client, including a first memory, a first processor, and a first computer program stored in the first memory and executable on the first processor, where the first computer program, when executed by the first processor, implements the steps of the data transmission method as described above.
Referring to fig. 5, an embodiment of the present invention provides a server, which includes a second memory, a second processor, and a second computer program stored in the second memory and capable of running on the second processor, where the second computer program, when executed by the second processor, implements the steps in the data receiving method described above.
The video data transmission method, the video data receiving method, the server and the client can be applied to any type of service scene needing video data transmission and reception, have universality, and are explained by a specific implementation mode as follows:
example one
In this embodiment, an interactive process of data transmission and reception between a client and a server is described, referring to fig. 1 to 3, a data transmission method includes the steps of:
s1, the client and the server negotiate a custom byte encoding rule;
s2, the client side encrypts and encapsulates the data to be transmitted according to the custom byte encoding rule, as shown in figure 1;
specifically, the client generates a byte section, wherein the byte section comprises a first byte section, a second byte section and a third byte section;
the first byte section comprises a sub-byte section used for storing encrypted data to be transmitted, the second byte section comprises five sub-byte sections used for storing parameters for decrypting the encrypted data to be transmitted, and the third byte section comprises two sub-byte sections used for storing magic number constants as section bit marks.
In this embodiment, a byte section as shown in table 1 is generated, and the byte section includes 8 segment bits:
TABLE 1
Segment position 1 2 3 4 5 6 7 8
Number of bytes 1 1 1 X 1 4 4 N
Wherein X is random length intRandom, N is byte array length encrypt tbytes. length after data to be transmitted are encrypted;
each of the eight segment bits has its own mission, and except 2 segment bits as magic constants, the other 6 segment bits are all ring-locked, so that the specific real content cannot be decoded even if the information body is intercepted, and the important role in data security transmission is played.
Specifically, the sub-fields in the first field correspond to the eighth field of bits in table 1, and the five sub-fields in the second field correspond to the third to seventh fields of bits in table 1; two sub-fields of the third field correspond to the first field and the second field of Table 1;
the third byte segment includes a first segment bit and a second segment bit, each segment bit is a byte number, and a random value is used as a fixed identifier, in this embodiment, the first segment bit is selected from 0Xdd but not limited to 0Xdd, the second segment bit is selected from 0X66 but not limited to 0X66, and random values of the first segment bit and the second segment bit are associated with each other to form a magic number constant of the characteristic value;
the second byte section comprises third to seventh section bits, the third section bit is one byte number and stores 1 to 64 random numbers intRandom, in the embodiment, the random number intRandom takes 10, and the section bit provides basic variables for the fourth section bit;
the fourth section of bits determine the byte number of the section based on the random number of the third section of bits, in this embodiment, the byte number of the fourth section of bits is 10 bits, the stored value is byte arrays randomBytes with the length equal to 10, each array stores 1-10 random numbers, and provides a basic variable for the fifth section of bits;
the fifth section of bits are one byte number, and an indirect number roundAbout is stored, and the specific algorithm of the indirect number roundAbout is as follows:
roundAbout=randomBytes[randomBytes.length-1]^roundRandom
acquiring a random number stored in the last byte of the byte array randomBytes of the fourth section bit;
randomly acquiring an encryption round number round random in a TEA algorithm, wherein the range is 33-64;
calculating the random number and the encryption round number stored in the last byte through an exclusive OR to obtain an indirect number roundBout;
the sixth segment bit includes 4 bytes, and stores the total byte length countLength of the segment bits included in the encoding rule.
The seventh section of bits stores the byte array length realLength of the data to be transmitted;
the first byte section comprises an eighth section bit, and the eighth section bit stores an encrypted byte array value encrypt of data to be transmitted, and the length of the first byte section is calculated as follows:
encryptBytes.length=countLength-intRandom-12
the eighth section of bit data is encrypted by a TEA algorithm;
after encrypting and encapsulating the data to be transmitted according to the above rules, the client sends the encapsulated data to the server;
s3, receiving the encapsulated data sent by the client, and the server decapsulating and decrypting the encapsulated data according to the custom byte encoding rule to obtain the data to be transmitted;
specifically, as shown in fig. 2, the packed data is a byte, and the byte includes a first byte, a second byte, and a third byte;
the third byte section corresponds to a first section bit and a second section bit in the table 1, each section bit is a byte number, random values are taken as fixed identifiers, and the first section bit and the second section bit form magic number constants of characteristic values;
the second byte section corresponds to third to seventh section bits in table 1, and the second byte section stores first decrypted data corresponding to the encrypted data to be transmitted;
the first byte section corresponds to an eighth section bit in the table 1, and the first byte section stores data to be transmitted encrypted by a TEA algorithm;
the S3 includes the steps of:
s301, decrypting the second byte section according to a custom coding rule to obtain first decrypted data corresponding to the encrypted data to be transmitted;
specifically, the step of receiving the encapsulated data of the data structure in table 1, and the step of decrypting the second byte segment according to a custom coding rule to obtain first decrypted data corresponding to the encrypted data to be transmitted includes:
analyzing the third segment of the data packet in the table 1 according to the self-defined coding rule to obtain a random number intRandom, and determining the number of bytes of the fourth segment of the data packet according to the random number intRandom;
analyzing an array randomBytes of a fourth section of bit of the data packet in the table 1 according to the custom coding rule to obtain a random number stored in the last byte of the array of the fourth section of bit;
analyzing and acquiring an indirect number roundAbout stored in a fifth section bit of the data packet in table 1 according to the custom coding rule, and decoding according to the indirect number roundAbout stored in the fifth section bit and a random number stored in the last byte bit of the array of the fourth section bit to acquire an encryption round number roundRandom;
the specific algorithm is as follows:
roundRandom=randomBytes[randomBytes.length-1]^roundAbout;
analyzing according to the self-defined coding rule to obtain the total length countLength of the encapsulated data bytes in the sixth section of bits;
analyzing according to the self-defined coding rule to obtain the byte length realLength of the data to be transmitted stored in the seventh section;
the encryption round number roundRandom and the byte length realLength of the data to be transmitted form first decryption data.
S402, decrypting the first byte section according to a custom coding rule to obtain an encrypted byte array value encrypt of the data to be transmitted;
specifically, the first byte section corresponds to an eighth section bit of table 1;
analyzing according to a self-defined coding rule to obtain a byte array value encryptBytes of the encrypted data to be transmitted stored in the eighth section of bits, wherein the byte data calculation length formula is as follows:
encryptBytes.length=countLength-intRandom-12;
s403, decrypting the encrypted data to be transmitted through the first decrypted data and an encryption and decryption plaintext password built in the program to obtain the data to be transmitted.
Specifically, the encryption round number roundRandom, the byte length realLength of the data to be transmitted, the encryption and decryption plaintext password built in the program, and the encrypted byte array value encryptBytes of the data to be transmitted perform TEA algorithm decryption to obtain the data to be transmitted.
Example two
Referring to fig. 6, the embodiment specifically describes how the client and the server perform information interaction through a coding instruction:
specifically, the method comprises the following steps:
the client and the server negotiate an instruction coding rule, and different instruction codes correspond to different instructions;
the client attaches an instruction code corresponding to the instruction type to the data to be transmitted according to the instruction type to be transmitted and the instruction coding rule;
the client encrypts and encapsulates the data to be transmitted with the instruction codes according to the custom byte encoding rule;
the server receives the encapsulated data, decapsulates and decrypts the encapsulated data according to the custom byte encoding rule to obtain the data to be transmitted, wherein the data to be transmitted comprises an instruction code;
determining an instruction type corresponding to the instruction code according to the instruction coding rule;
feeding back the received data through a response instruction matched with the instruction type; specifically, the client and the server negotiate an instruction coding rule to generate five instruction codes, wherein each instruction code corresponds to one instruction;
the instruction code and the instruction corresponding to the encoding instruction are shown in table 2:
TABLE 2
Figure BDA0002863569450000111
The instruction interaction between the client and the server based on the instruction encoding rule is shown in fig. 6:
s201, the client performs a login request through a monitoring port 5678 issued by the server, and attaches a command code 5000, the server verifies and returns a corresponding response code after receiving the login request, the corresponding response command code 4000, and the specific request information body format is shown in Table 3:
TABLE 3
Number of bytes 4 20 32 32
Description of the invention Command code number Client unique identifier Client user Client password
S202, the client initiates a file pre-transmission command according to an instruction code number 4000 returned by the server after the identity authentication is successful, the instruction code number 5001 is attached to the file pre-transmission command, the server verifies and returns a corresponding response code after receiving a pre-transmission request, and the corresponding response instruction code number 4001 is returned;
s203, the client sends file information according to the instruction code 4001 returned by the server and simultaneously establishes a file transmission channel and attaches an instruction code 5002, the server receives the file information and returns a corresponding response code, the corresponding response instruction code 4002 corresponds to the file information, the file information comprises a client identifier, a file name, MD5 and the like, and the specific request information body format is shown in Table 4:
TABLE 4
Number of bytes 4 20 520 8 16
Description of the invention Command code number Client unique identifier Filename File size Document MD5
S304, the client performs block transmission on the to-be-transmitted data to be encapsulated, and attaches an instruction encoding code 5003, the transmission maximally supports transmission of 32 kbytes and supports breakpoint transmission, the server receives data block information and returns a corresponding response code, the corresponding response instruction encoding code 4003, and a specific request information body format is as shown in table 5:
TABLE 5
Number of bytes 4 20 8 8 N(<=32K)
Description of the invention Command code number Client unique identifier Starting position Stop position File block byte
S305, after the file transmission of the client is finished, a file ending request is sent and an instruction coding code number 5004 is attached, the server judges the integrity of data according to the received MD5 information and returns to an instruction coding code number 4004 for ending the transmission;
the specific instruction encoding code is further divided into several cases as shown in table 6:
TABLE 6
Figure BDA0002863569450000121
Figure BDA0002863569450000131
Furthermore, the server is realized based on an open source network framework NETTY and is communicated with the client through a TCP protocol, and data is transmitted in a byte stream mode when the server is communicated with the client, so that the advantages of breakpoint transmission, integrity verification and the like are achieved.
EXAMPLE III
Referring to fig. 4, a client includes a first memory, a first processor, and a first computer program stored in the first memory and executable on the first processor, where the first computer program, when executed by the first processor, implements the steps performed by the client in the data transmission method according to the first embodiment or the second embodiment.
Example four
Referring to fig. 5, a server includes a second memory, a second processor, and a second computer program stored in the second memory and capable of running on the second processor, where the second computer program, when executed by the second processor, implements the steps performed by the server in the data transmission method according to the first embodiment or the second embodiment.
In summary, according to the sending method, the receiving method, the client and the server for data provided by the present invention, the data to be transmitted is encapsulated and encrypted according to the custom byte encoding rule negotiated by the client and the server, and the encoding instruction is stored in the data to be transmitted and transmitted between the client and the server in the form of byte stream, and the server needs to decrypt the encrypted data to be transmitted according to the custom encoding rule to obtain the data to be transmitted, thereby ensuring the security of the data in the transmission process; meanwhile, the client and the server, which store the instruction codes in the data to be transmitted, can interact through the instruction codes, so that a frequent handshaking protocol is avoided, the efficiency of data transmission is improved, and the reliability of data transmission is also ensured.
The above description is only an embodiment of the present invention, and not intended to limit the scope of the present invention, and all equivalent changes made by using the contents of the present specification and the drawings, or applied directly or indirectly to the related technical fields, are included in the scope of the present invention.

Claims (10)

1. A data transmission method, comprising the steps of:
negotiating a custom byte encoding rule with a server;
encrypting and packaging data to be transmitted according to the custom byte encoding rule;
and sending the encapsulated data to the server, and decapsulating and decrypting the encapsulated data through the server according to the custom byte encoding rule to obtain the data to be transmitted.
2. The method for transmitting data according to claim 1, further comprising the steps of:
negotiating an instruction encoding rule with the server, wherein different instruction codes correspond to different instructions;
encrypting and packaging the data to be transmitted according to the custom byte encoding rule comprises the following steps:
attaching an instruction code corresponding to the instruction type to the data to be transmitted according to the instruction type to be transmitted and the instruction coding rule;
and encrypting and packaging the data to be transmitted attached with the instruction codes according to the custom byte encoding rule.
3. The method according to claim 1, wherein the encrypting and encapsulating the data to be transmitted according to the custom byte encoding rule comprises:
generating a word segment;
the byte section comprises a first byte section and a second byte section;
encrypting the data to be transmitted by adopting a TEA algorithm to obtain encrypted data to be transmitted;
writing the encrypted data to be transmitted into the first byte section;
and writing the first decrypted data corresponding to the encrypted data to be transmitted into the second byte section.
4. The method according to claim 3, wherein said fields further comprise a third field;
the third byte section comprises two bytes, and mutually associated random numbers are written in the two bytes and form magic number constants;
the writing the first decrypted data corresponding to the encrypted data to be transmitted into the second byte section includes:
the second byte section comprises four sub-byte sections;
writing a random number in the first sub-field;
determining a number of bytes of a second sub-byte based on a size of the random number written in the first sub-byte;
randomly writing an arbitrary random number smaller than the one random number in each byte in the second sub-byte section;
XOR the random number stored in the last byte in the second sub-byte section and the encryption round number of the TEA algorithm, and writes the value obtained by XOR into a third sub-byte field;
the length of data to be transmitted is written to the fourth sub-byte segment.
5. A data receiving method, characterized by comprising the steps of:
negotiating a custom byte encoding rule with a client;
receiving encapsulated data sent by a client, wherein the encapsulated data is obtained by encrypting and encapsulating data to be transmitted by the client according to the custom byte coding rule;
and decapsulating and decrypting the encapsulated data according to the custom byte encoding rule to obtain the data to be transmitted.
6. A data receiving method according to claim 5, further comprising the steps of:
negotiating an instruction encoding rule with the client, wherein different instruction encodings correspond to different instructions;
the decapsulating and decrypting the encapsulated data according to the custom byte encoding rule to obtain the data to be transmitted includes:
decapsulating and decrypting the encapsulated data according to the custom byte encoding rule to obtain the data to be transmitted, wherein the data to be transmitted comprises an instruction code;
determining an instruction type corresponding to the instruction code according to the instruction coding rule;
and feeding back the received data through a response instruction matched with the instruction type.
7. A method as claimed in claim 6, wherein the encapsulated data is a byte;
the byte section comprises a first byte section and a second byte section;
the decapsulating and decrypting the encapsulated data according to the custom byte encoding rule to obtain the data to be transmitted includes:
acquiring first decrypted data corresponding to the encrypted data to be transmitted from the second byte section according to the custom coding rule;
acquiring encrypted data to be transmitted from the first byte section according to the custom coding rule;
and decrypting the encrypted data to be transmitted according to the first decryption data to obtain the data to be transmitted.
8. A method of receiving data according to claim 7 wherein said second byte section comprises four sub-byte sections;
the step of decrypting the second byte section according to a custom coding rule to obtain first decrypted data corresponding to the encrypted data to be transmitted comprises the following steps:
analyzing according to the self-defined coding rule to obtain a random number stored in a first sub-byte section in the second byte section, and determining the number of bytes of the second sub-byte section according to the size of the random number;
analyzing according to the custom coding rule to obtain a random number stored in the last byte in the second sub-byte in the second byte section;
analyzing according to the self-defined coding rule to obtain data stored in a third sub-byte in the second byte, and obtaining an encryption round number according to the data stored in the third sub-byte and a random number stored in the last byte in the second sub-byte;
analyzing according to the custom coding rule to obtain the length of data to be transmitted in a fourth sub-field in the second field;
and decrypting the encrypted data to be transmitted according to the encryption round number, the length of the data to be transmitted and a built-in encryption and decryption plaintext password to obtain the data to be transmitted.
9. A client comprising a first memory, a first processor and a first computer program stored on the first memory and executable on the first processor, wherein the first computer program, when executed by the first processor, implements the steps of a method of transmitting data as claimed in any one of claims 1 to 4.
10. A server comprising a second memory, a second processor and a second computer program stored on said second memory and executable on said second processor, characterized in that said second computer program, when executed by the second processor, implements the steps of a data receiving method as claimed in any one of claims 5 to 8.
CN202011575388.XA 2020-12-28 2020-12-28 Data sending method, data receiving method, client and server Active CN112637225B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011575388.XA CN112637225B (en) 2020-12-28 2020-12-28 Data sending method, data receiving method, client and server

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011575388.XA CN112637225B (en) 2020-12-28 2020-12-28 Data sending method, data receiving method, client and server

Publications (2)

Publication Number Publication Date
CN112637225A true CN112637225A (en) 2021-04-09
CN112637225B CN112637225B (en) 2023-04-14

Family

ID=75325799

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011575388.XA Active CN112637225B (en) 2020-12-28 2020-12-28 Data sending method, data receiving method, client and server

Country Status (1)

Country Link
CN (1) CN112637225B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114301737A (en) * 2021-12-29 2022-04-08 迈普通信技术股份有限公司 Network configuration method and device, network equipment and computer readable storage medium
CN114745078A (en) * 2022-04-25 2022-07-12 北京兴竹同智信息技术股份有限公司 Edge identification system, method, equipment and storage medium

Citations (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20020164020A1 (en) * 2001-05-04 2002-11-07 Shakeel Mustafa System and method for encrypting and decrypting information through the use of random numbers
WO2009150042A1 (en) * 2008-06-10 2009-12-17 Telefonaktiebolaget L M Ericsson (Publ) Policy control with predefined rules
US20110041179A1 (en) * 2009-08-11 2011-02-17 F-Secure Oyj Malware detection
CN104683825A (en) * 2015-02-12 2015-06-03 央广视讯传媒股份有限公司 Encrypted transport and decoding processing method of TS (transport stream)
CN106411907A (en) * 2016-10-13 2017-02-15 广西咪付网络技术有限公司 Data transmission method and system
CN106850191A (en) * 2017-02-19 2017-06-13 郑州云海信息技术有限公司 The encryption and decryption method and device of distributed memory system communication protocol
CN108111546A (en) * 2018-03-02 2018-06-01 瓦戈科技(上海)有限公司 A kind of document transmission method and system
CN108156120A (en) * 2016-12-06 2018-06-12 阿里巴巴集团控股有限公司 Encrypted transmission data, cryptographic protocol control and detected method, apparatus and system
CN109428899A (en) * 2017-08-21 2019-03-05 中国石油化工股份有限公司 File security transfer management method and system
CN111159658A (en) * 2019-12-16 2020-05-15 广州三七互娱科技有限公司 Byte code processing method, system, device, computer equipment and storage medium
CN111683069A (en) * 2020-05-28 2020-09-18 杭州绿度信息技术有限公司 Customized communication protocol and service method based on netty framework
WO2020233033A1 (en) * 2019-05-20 2020-11-26 深圳壹账通智能科技有限公司 Information interaction method, device and storage medium
WO2020237868A1 (en) * 2019-05-24 2020-12-03 平安科技(深圳)有限公司 Data transmission method, electronic device, server and storage medium

Patent Citations (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20020164020A1 (en) * 2001-05-04 2002-11-07 Shakeel Mustafa System and method for encrypting and decrypting information through the use of random numbers
WO2009150042A1 (en) * 2008-06-10 2009-12-17 Telefonaktiebolaget L M Ericsson (Publ) Policy control with predefined rules
US20110041179A1 (en) * 2009-08-11 2011-02-17 F-Secure Oyj Malware detection
CN104683825A (en) * 2015-02-12 2015-06-03 央广视讯传媒股份有限公司 Encrypted transport and decoding processing method of TS (transport stream)
CN106411907A (en) * 2016-10-13 2017-02-15 广西咪付网络技术有限公司 Data transmission method and system
CN108156120A (en) * 2016-12-06 2018-06-12 阿里巴巴集团控股有限公司 Encrypted transmission data, cryptographic protocol control and detected method, apparatus and system
CN106850191A (en) * 2017-02-19 2017-06-13 郑州云海信息技术有限公司 The encryption and decryption method and device of distributed memory system communication protocol
CN109428899A (en) * 2017-08-21 2019-03-05 中国石油化工股份有限公司 File security transfer management method and system
CN108111546A (en) * 2018-03-02 2018-06-01 瓦戈科技(上海)有限公司 A kind of document transmission method and system
WO2020233033A1 (en) * 2019-05-20 2020-11-26 深圳壹账通智能科技有限公司 Information interaction method, device and storage medium
WO2020237868A1 (en) * 2019-05-24 2020-12-03 平安科技(深圳)有限公司 Data transmission method, electronic device, server and storage medium
CN111159658A (en) * 2019-12-16 2020-05-15 广州三七互娱科技有限公司 Byte code processing method, system, device, computer equipment and storage medium
CN111683069A (en) * 2020-05-28 2020-09-18 杭州绿度信息技术有限公司 Customized communication protocol and service method based on netty framework

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114301737A (en) * 2021-12-29 2022-04-08 迈普通信技术股份有限公司 Network configuration method and device, network equipment and computer readable storage medium
CN114301737B (en) * 2021-12-29 2023-10-24 迈普通信技术股份有限公司 Network configuration method, device, network equipment and computer readable storage medium
CN114745078A (en) * 2022-04-25 2022-07-12 北京兴竹同智信息技术股份有限公司 Edge identification system, method, equipment and storage medium
CN114745078B (en) * 2022-04-25 2023-07-14 北京兴竹同智信息技术股份有限公司 Edge recognition system, method, equipment and storage medium

Also Published As

Publication number Publication date
CN112637225B (en) 2023-04-14

Similar Documents

Publication Publication Date Title
KR100480225B1 (en) Data-securing communication apparatus and method therefor
US7120249B2 (en) Methods and systems for generating encryption keys using random bit generators
KR101684076B1 (en) A secure Data Communication system between IoT smart devices and a Network gateway under Internet of Thing environment
US11870761B1 (en) Hardware security accelerator
JP4366037B2 (en) System and method for controlling and exercising access rights to encrypted media
CN112311865B (en) File encryption transmission method and device
CN112637225B (en) Data sending method, data receiving method, client and server
US20220353056A1 (en) Communication method and apparatus
CN110620762A (en) RDMA (remote direct memory Access) -based data transmission method, network card, server and medium
CN108566368B (en) Data processing method, server and diagnosis connector
US20050172119A1 (en) Hardware/software partitioning for encrypted WLAN communications
CN112738051A (en) Data information encryption method, system and computer readable storage medium
KR101424972B1 (en) Method for using contents with a mobile card, host device, and mobile card
US20180145829A1 (en) Data management method
CN112400294A (en) Secure communications from within a non-volatile memory device
Kummert The PPP Triple-DES Encryption Protocol (3DESE)
CN114679299B (en) Communication protocol encryption method, device, computer equipment and storage medium
CN114978769A (en) Unidirectional lead-in device, method, medium, and apparatus
CN116781421B (en) Network authentication method based on DTLS
CN115189969B (en) Network encryption communication method, device, medium and equipment
CN114553498B (en) Line protection method and system suitable for chip
JP7397403B2 (en) Electronic information storage medium, authentication code generation method, authentication code verification method, and program
CN112333204B (en) 5G network transmission security device based on TCP IP protocol disorder feature code
JP2003281476A (en) Communication system of ic card with cpu, ic card with cpu, management center and reading apparatus
CN116915391A (en) Method for exchanging cryptographic keys between communication subscribers

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