CN112637225B - 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
CN112637225B
CN112637225B CN202011575388.XA CN202011575388A CN112637225B CN 112637225 B CN112637225 B CN 112637225B CN 202011575388 A CN202011575388 A CN 202011575388A CN 112637225 B CN112637225 B CN 112637225B
Authority
CN
China
Prior art keywords
byte
data
transmitted
custom
section
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202011575388.XA
Other languages
Chinese (zh)
Other versions
CN112637225A (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]

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Hardware Design (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)
  • Storage Device Security (AREA)

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 systems transmit data basically through FTP and the like, a plurality of default non-encryption modes are adopted, the encryption is basically only used for a database or sensitive fields, and 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 the 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 problem, 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 in the second memory and executable on the second processor, wherein the second computer program, when executed by the second processor, implements 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 the technical contents, the objects and the 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 the 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 coding 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 sections also include a third section;
the third byte segment 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 the data to be transmitted is written to the fourth sub-byte segment.
It can be known from the above description that the byte section further includes the magic number constant, and the second byte section of the byte section encapsulates the first decrypted data in a ring-and-ring buckling manner, so that the security of the first decrypted data is ensured, and even if the data is stolen by a third party in the transmission process, the third party cannot analyze the data to be transmitted, so that the security of output transmission is improved, and meanwhile, the magic number constant prevents the data from being tampered and misread, so that the security of output transmission is further ensured.
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.
According to the description, the encrypted data to be transmitted and the first decrypted data are obtained by decrypting the first byte segment and the second byte segment according to the custom coding rule, and then the encrypted data to be transmitted is decrypted according to the first decrypted data and the encryption and decryption plaintext password built in the program, so that the data to be transmitted can be obtained.
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 self-defined 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 number of the encryption rounds, 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 obtained finally, 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 side and the client side can be applied to any type of service scene needing video data transmission and reception, have universality, and are explained through specific implementation modes 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, a client and a server negotiate a custom byte coding rule;
s2, the client 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
Byte number 1 1 1 X 1 4 4 N
Wherein X is random length intRandom, N is byte array length encrypt tbytes.
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 and second fields 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 taken as a fixed identifier, in this embodiment, the first segment bit selects 0Xdd but not limited to 0Xdd, the second segment bit selects 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 includes third to seventh sections, the third section is a byte number, stores 1 to 64 random numbers intRandom, in this embodiment, the random number intRandom takes 10, and the section provides basic variables for the fourth section;
the fourth segment of bits determines the byte number of the segment based on the random number of the third segment of bits, in this embodiment, the byte number of the fourth segment 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 segment 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 roundRandom in the 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, the encrypted byte array value encrypt of the data to be transmitted is stored, and the section length 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 decapsulating and decrypting the encapsulated data according to the custom byte encoding rule by the server to obtain the data to be transmitted;
specifically, as shown in fig. 2, the encapsulated 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 of bits in the table 1, and the first byte section stores data to be transmitted encrypted by a TEA algorithm;
the S3 comprises the following steps:
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 custom coding rule to obtain the total length countLength of the encapsulated data bytes in the sixth segment 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;
and 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 segment corresponds to an eighth segment 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 preferred embodiment Command code number Client unique identifier Client user Client password
S202, the client initiates a file pre-transmission command according to an instruction encoding code 4000 returned by the server after the identity authentication is successful, the instruction encoding code 5001 is attached to the file pre-transmission command, the server verifies the file pre-transmission command after receiving the pre-transmission request and returns a corresponding response code, and the corresponding response instruction encoding code 4001 is returned;
s203, the client sends file information according to the instruction coding code 4001 returned by the server, meanwhile, a file transmission channel is established, the instruction coding code 5002 is attached, the server receives the file information and returns a corresponding response code, the corresponding response instruction coding code 4002 corresponds to the file information, the file information comprises a client identifier, a file name, an MD5 and the like, and the format of a specific request information body is shown in a table 4:
TABLE 4
Byte number 4 20 520 8 16
Description of the invention Command code number Client unique identifier Filename of file File size File MD5
S304, the client performs block transmission on the to-be-transmitted data to be encapsulated, and attaches a command encoding code 5003, where the transmission maximally supports transmission of 32 kbytes and supports breakpoint transmission, the server receives data block information and returns a corresponding response code, and the corresponding response command encoding code 4003 indicates that the 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 Byte of file block
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 numbers are 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 between 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 (7)

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;
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;
the encrypting and packaging 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;
writing first decrypted data corresponding to the encrypted data to be transmitted into the second byte section;
the lettering further comprises a third lettering; 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 five 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;
writing the length of the data to be transmitted into the fourth sub-byte segment;
the fifth sub-byte segment bit stores the total byte length of the segment bits that the custom byte-encoding rule includes.
2. A 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. 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;
decapsulating and decrypting the encapsulated data according to the custom byte encoding rule to obtain the data to be transmitted;
the packaged data is obtained by encrypting and packaging the data to be transmitted according to the custom byte encoding rule, and comprises the following steps:
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;
writing first decrypted data corresponding to the encrypted data to be transmitted into the second byte section;
the field further comprises 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 second byte section comprises five sub-byte sections;
the step of decrypting the second byte section according to a custom byte encoding rule to obtain first decrypted data corresponding to the encrypted data to be transmitted comprises the following steps:
analyzing according to the custom byte coding rule to obtain a random number stored in a first sub-byte section in the second byte section, and determining the byte number of the second sub-byte section according to the size of the random number;
analyzing according to the custom byte encoding 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 custom byte 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 byte coding rule to obtain the length of data to be transmitted in a fourth sub-byte section in the second byte section;
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;
and analyzing according to the custom byte coding rule to obtain the total length of the encapsulated data bytes in a fifth sub-field of the second sub-field.
4. A data receiving method according to claim 3, 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.
5. A method as claimed in claim 4, 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 byte encoding rule;
acquiring encrypted data to be transmitted from the first byte section according to the custom byte encoding rule;
and decrypting the encrypted data to be transmitted according to the first decrypted data to obtain the data to be transmitted.
6. A client comprising a first memory, a first processor and a first computer program stored on said first memory and executable on said first processor, characterized in that said first computer program realizes the steps of a method for transmitting data as claimed in any one of claims 1 to 2 when executed by the first processor.
7. 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 3 to 5.
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 CN112637225A (en) 2021-04-09
CN112637225B true 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)

Families Citing this family (2)

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

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
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

Family Cites Families (11)

* 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
CN106850191B (en) * 2017-02-19 2020-03-10 郑州云海信息技术有限公司 Encryption and decryption method and device for communication protocol of distributed storage system
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
CN111159658B (en) * 2019-12-16 2022-04-01 广州三七互娱科技有限公司 Byte code processing method, system, device, computer equipment and storage medium
CN111683069B (en) * 2020-05-28 2022-11-01 杭州隐捷适生物科技有限公司 Customized communication protocol and service method based on netty framework

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
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

Also Published As

Publication number Publication date
CN112637225A (en) 2021-04-09

Similar Documents

Publication Publication Date Title
US7120249B2 (en) Methods and systems for generating encryption keys using random bit generators
CN1224212C (en) Data securing communication apparatus and method
US11615411B2 (en) POS system with white box encryption key sharing
CN112311865B (en) File encryption transmission method and device
US20030084292A1 (en) Using atomic messaging to increase the security of transferring data across a network
US20080044012A1 (en) Reducing Security Protocol Overhead In Low Data Rate Applications Over A Wireless Link
CN112637225B (en) Data sending method, data receiving method, client and server
CN108566368B (en) Data processing method, server and diagnosis connector
US20220353056A1 (en) Communication method and apparatus
CN112738051A (en) Data information encryption method, system and computer readable storage medium
CN110620762A (en) RDMA (remote direct memory Access) -based data transmission method, network card, server and medium
US10419212B2 (en) Methods, systems, apparatuses, and devices for securing network communications using multiple security protocols
KR101424972B1 (en) Method for using contents with a mobile card, host device, and mobile card
CN112400294A (en) Secure communications from within a non-volatile memory device
CN115174261A (en) Mixed encryption and decryption system and method based on hierarchical layer and secret-medium secret distribution
CN114978769A (en) Unidirectional lead-in device, method, medium, and apparatus
US20050108528A1 (en) Computer network and method for transmitting and authenticating data in the computer network
US6801625B1 (en) Apparatus and method for stripping parity bits from an input stream
CN116781421B (en) Network authentication method based on DTLS
CN111431846A (en) Data transmission method, device and system
CN114553498B (en) Line protection method and system suitable for chip
CN115460020B (en) Data sharing method, device, equipment and storage medium
CN112333204B (en) 5G network transmission security device based on TCP IP protocol disorder feature code
CN116600287A (en) Network data transmission encryption and decryption method
JP2003281476A (en) Communication system of ic card with cpu, ic card with cpu, management center and reading apparatus

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