Electronic information transmission method and electronic equipment
By using hash function and asymmetric encryption algorithm for dual encryption during data transmission, the problem of insufficient security of data transmission in the prior art is solved, and efficient data integrity and authentication are achieved.
Patent Information
- Application Number
- CN202510209190.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-25
- Publication Date
- 2025-06-20
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In the prior art, only symmetric encryption or asymmetric encryption processing cannot effectively ensure the security of data during data transmission, which can easily lead to illegal crawling or malicious tampering.
The hash function is used to calculate the hash value for the data, and the data is encrypted into ciphertext using an asymmetric encryption algorithm. At the same time, the hash value is digitally signed using a private key to ensure the integrity and authentication of the data.
Through dual encryption and hash encryption, the security of data transmission is significantly improved, preventing data tampering and identity impersonation, and ensuring the integrity of the data during transmission and the authenticity of its source.
Smart Images

Figure CN120185818A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of secure transmission of electronic information, and particularly to an electronic information transmission method and an electronic device. Background Art
[0002] Information transmission is to transmit command or status information from one end to the other end via a channel and be received by the other party, including transmission and reception. The transmission media are divided into wired and wireless. Wired media are telephone lines or dedicated cables; wireless media utilize radio stations, microwave, and satellite technologies, etc. During the information transmission process, the information cannot be changed, and the information itself cannot be transmitted or received either. There must be a carrier, such as data, language, signal, etc., and there must be a common interpretation of the carrier between the transmission side and the reception side.
[0003] Computer security refers to the technical and management security protection for data processing systems, protecting computer hardware, software, and data from being damaged, altered, or disclosed due to accidental or malicious reasons. The definition of computer system security by the International Organization for Standardization is: establishing and adopting technical and management security protection for data processing systems to protect computer hardware, software, and data from being damaged, altered, and disclosed due to accidental and malicious reasons. Therefore, the security of a computer network can be understood as: by adopting various technical and management measures, enabling the normal operation of the network system, thereby ensuring the availability, integrity, and confidentiality of network data. So, the purpose of establishing network security protection measures is to ensure that the data transmitted and exchanged through the network will not have phenomena such as increase, modification, loss, and disclosure.
[0004] Currently, data is not processed securely during transmission or is only processed through symmetric encryption or asymmetric encryption. During the data transmission process, the security of the data cannot be guaranteed, and it is easy for unauthorized personnel to crawl the transmitted data or maliciously tamper with the data, resulting in data loss problems. Summary of the Invention
[0005] (1) Technical Problems to be Solved
[0006] In view of the deficiencies of the prior art, the present invention provides an electronic information transmission method and an electronic device, which solve the problems in the prior art that only symmetric encryption or asymmetric encryption is used for processing, and the security of data cannot be guaranteed during the data transmission process, and it is easy for unauthorized personnel to crawl the transmitted data or maliciously tamper with the data.
[0007] (2) Technical Solutions
[0008] To achieve the above objectives, the present invention is realized through the following technical solutions: An electronic information transmission method includes the following steps:
[0009] S1. The electronic device calculates the hash value of the data to be sent using a hash function: Import the data into the hashlib library and convert it into a byte string because hash functions usually operate at the byte level, i.e., data_bytes = data.encode('utf-8'). Then create a SHA-256 hash object hash_object = hashlib.sha256(data_bytes). Finally, call the hexdigest method of hash_object to obtain the hexadecimal representation of the hash value;
[0010] S2. The sender encrypts the hash value using the private key: The sender obtains the public key of the receiver and uses an asymmetric encryption algorithm to encrypt the original data into ciphertext. Then, the sender uses the private key to encrypt the hash value, which can be a digital signature. This step ensures that the source of the hash value is the sender and that it has not been tampered with during transmission;
[0011] S3. Send the encrypted ciphertext and the signed hash value together: The ciphertext and the hash value can be transmitted over the network and will pass through network devices such as routers and switches during transmission;
[0012] S4. The receiving end initially decrypts the ciphertext using the public key to restore the original data: Use JAVA for decryption operations;
[0013] S5. The receiving end decrypts the hash value using the public key to obtain the original hash value: Use JAVA for decryption operations;
[0014] S6. The receiving end performs a second hash calculation on the original function using the same hash function: The receiver uses the same hash function to perform a hash calculation on the decrypted original data again to obtain a new hash value. If this hash value is the same as the hash value in S5, it proves that the data has not been tampered with during transmission and that the data was indeed sent by the sender. If the two hash values are different, it indicates that there may be a problem with the data;
[0015] S7. Risk reminder: In transmissions based on network protocols, after the receiving end discovers that the data has been tampered with, it sends a TCP packet containing the message "Data tampering error" to the sender. The sender can listen for these returned messages or error codes and take corresponding measures after receiving the data tampering reminder.
[0016] Preferably: In S2, the asymmetric encryption algorithm is used to convert the original data into a seemingly random sequence of numbers that can only be decrypted using the private key of the receiver.
[0017] Preferably: in S4 and S5, first load the public key from the byte array through X509EncodedKeySpec, then use an instance of Signature to initialize the verification through initVerify, and then use the verify method for decryption and verification operations. If verify returns true, the decryption is successful.
[0018] An electronic device, comprising: a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein the processor executes the program to implement an electronic information transmission method according to any one of claims 1-3.
[0019] (III) Beneficial effects
[0020] The present invention provides an electronic information transmission method and an electronic device, having the following beneficial effects:
[0021] 1. In the information transmission process of the electronic device, the present invention uses an asymmetric encryption algorithm and a hash function to double-encrypt the data. The data integrity verification provided by the hash encryption assists the asymmetric encryption to better complete the identity verification. If the data is tampered with, the hash value will change, resulting in the failure of the digital signature verification, thereby preventing the identity from being misused and greatly improving the information transmission security of the entire electronic device. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Figure 1 is the overall flowchart of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0023] The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.
[0024] Embodiment:
[0025] As Figure 1 shown, the embodiment of the present invention provides an electronic information transmission method, including the following steps:
[0026] S1. The electronic device calculates the hash value of the data to be sent using a hash function: Import the data into the hashlib library and convert it into a byte string because hash functions usually operate at the byte level, i.e., data_bytes = data.encode('utf-8'). Then create a SHA-256 hash object hash_object = hashlib.sha256(data_bytes). Finally, call the hexdigest method of hash_object to obtain the hexadecimal representation of the hash value;
[0027] S2. The sender encrypts the hash value using the private key: The sender obtains the public key of the receiver and uses an asymmetric encryption algorithm to encrypt the original data into ciphertext. Then, the private key is used to encrypt the hash value, and digital signature can be adopted. This step ensures that the source of the hash value is the sender and it has not been tampered with during the transmission;
[0028] S3. Send the encrypted ciphertext and the signed hash value together: The ciphertext and the hash value can be transmitted through the network and will pass through network devices such as routers and switches during the transmission;
[0029] S4. The receiving end decrypts the ciphertext for the first time using the public key to restore the original data: Decryption operations are carried out using JAVA;
[0030] S5. The receiving end decrypts the hash value using the public key to obtain the original hash value: Decryption operations are carried out using JAVA;
[0031] Assume that there is already the encrypted hash value (represented in the form of a byte array, such as encryptedHashValue) and the public key (an object of the PublicKey type):
[0032]
[0033]
[0034] S6. The receiving end performs a second hash calculation on the original function using the same hash function: The receiver uses the same hash function to perform another hash calculation on the decrypted original data to obtain a new hash value. If this hash value is the same as the hash value in S5, it proves that the data has not been tampered with during the transmission and the data is indeed sent by the sender. If the two hash values are different, it indicates that there may be a problem with the data;
[0035] S7. Risk reminder: In the transmission based on network protocols, after the receiving end detects that the data has been tampered with, it sends a TCP data packet containing the information of "data tampering error" to the sending end. The sending end can listen to these returned messages or error codes and take corresponding measures after receiving the data tampering reminder. The data is double encrypted using an asymmetric encryption algorithm and a hash function. The hash encryption provides data integrity verification to assist the asymmetric encryption in better completing identity verification. If the data is tampered with, the hash value will change, resulting in the failure of digital signature verification, thus preventing the identity from being misused and greatly improving the information transmission security of the entire electronic device.
[0036] In S2, the original data is converted into a seemingly random sequence of numbers using an asymmetric encryption algorithm, and it can only be decrypted with the private key of the receiving party.
[0037] In S4 and S5, first, the public key is loaded from the byte array through X509EncodedKeySpec, then an instance of Signature is used to initialize the verification through initVerify, and then the verify method is used for decryption and verification operations. If verify returns true, the decryption is successful.
[0038] An electronic device includes: a memory, a processor, and a computer program stored on the memory and executable on the processor. The processor executes the program to implement an electronic information transmission method according to any one of claims 1 - 3.
[0039] Although the embodiments of the present invention have been shown and described, for those of ordinary skill in the art, it can be understood that various changes, modifications, substitutions, and variations can be made to these embodiments without departing from the principles and spirit of the present invention. The scope of the present invention is defined by the appended claims and their equivalents.
Claims
1. A method for transmitting electronic information, characterized in that: The following steps are involved: S1. The electronic device uses a hash function to calculate a hash value for the sent data: import the data into the hashlib library and convert it into a byte string, because hash functions usually operate at the byte level, i.e., data_bytes = data.encode('utf-8'), then create a SHA-256 hash object hash_object = hashlib.sha256(data_bytes), and finally call the hexdigest method of hash_object to obtain the hexadecimal representation of the hash value; S2. The sender uses the private key to encrypt the hash value: The sender obtains the public key of the receiver and uses an asymmetric encryption algorithm to encrypt the original data into ciphertext. Then, the sender uses the private key to encrypt the hash value. A digital signature can be used. This step ensures that the source of the hash value is the sender and has not been tampered with during transmission. S3, sending the encrypted ciphertext and the signed hash value together: the ciphertext and the hash value can be transmitted over the network, and during the transmission process they will pass through network devices, such as routers and switches; S4. The receiving end uses the public key to perform the initial decryption on the ciphertext and restore the initial data: JAVA is used for the decryption operation; S5. The receiving end uses the public key to decrypt the hash value to obtain the original hash value: JAVA is used for decryption operation; S6. The receiving end uses the same hash function to perform a second hash calculation on the original function: The receiving end uses the same hash function to perform a hash calculation on the decrypted original data again to obtain a new hash value. If the hash value is the same as the hash value in S5, it proves that the data has not been tampered with during transmission and that the data is indeed sent by the sender. If the two hash values are different, it indicates that there may be a problem with the data. S7. Risk reminder: In the transmission based on the network protocol, after the receiving end finds that the data has been tampered with, it sends a TCP data packet containing "data tampering error" information to the sending end. The sending end can monitor these returned messages or error codes and take corresponding measures after receiving the data tampering reminder.
2. The electronic information transmission method and electronic device according to claim 1, characterized in that: In the S2, an asymmetric encryption algorithm is used to convert the original data into a seemingly chaotic digital sequence, which can only be decrypted with the recipient's private key.
3. The electronic information transmission method and electronic device according to claim 2, characterized in that: In S4 and S5, the public key is first loaded from the byte array through X509EncodedKeySpec, and then the instance of Signature is used to initialize the verification through initVerify, and then the verify method is used to perform decryption and verification operations. If verify returns true, the decryption is successful.
4. An electronic device, characterized in that: include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement an electronic information transmission method as described in any one of claims 1 to 3.
Citation Information
Cited By
Privacy protection system based on multimedia short message
CN121037836A