RSA-based encryption transmission method, device and medium

By caching serialized RSA key pairs in Redis and using their public keys for encryption, the problem of increased computational cost of RSA encryption in communication is solved, and the encryption and decryption speed and code performance are improved.

CN117201068BActive Publication Date: 2025-09-09SHANDONG INSPUR AIGOU CLOUD CHAIN INFORMATION TECH CO LTD +3
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310934701.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-07-27
Publication Date
2025-09-09
Estimated Expiration
2043-07-27

AI Technical Summary

Technical Problem

Traditional RSA encryption suffers from poor performance and efficiency in communications due to issues with key management and increased computational costs.

Method used

Generate an RSA key pair, serialize it, cache it in Redis, encrypt it using the public key of the serialized key pair, generate ciphertext, and read and deserialize it directly from Redis for encryption and decryption when needed.

Benefits of technology

The performance and efficiency of the RSA encryption algorithm have been improved, the encryption and decryption speeds have been increased, and the code performance has been optimized.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117201068B_ABST
    Figure CN117201068B_ABST
Patent Text Reader

Abstract

The embodiment of the present application discloses a method, device and medium for RSA-based encryption transmission. It includes generating an RSA key pair, serializing the key pair, and caching the serialized key pair in a pre-set Redis; when receiving the encrypted data sent by the client, determining the public key corresponding to the serialized key in the pre-set Redis, encrypting the encrypted data with the public key corresponding to the serialized key to generate ciphertext; sending the ciphertext to the client, and decrypting the ciphertext with the private key corresponding to the client to complete the RSA encrypted transmission of the data. The above method solves the problem that the use of RSA encryption in communication easily leads to increased computing costs.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of data transmission, and in particular to a method, device and medium for RSA-based encryption transmission. Background Art

[0002] Currently, data security protection has become an important issue in network communications.

[0003] Traditional symmetric encryption algorithms have key management issues and their security depends on key confidentiality. However, RSA-based asymmetric encryption algorithms can provide a more secure data protection mechanism and support functions such as digital signatures and authentication.

[0004] However, the main performance issue with applying RSA to the gateway is that a key pair is issued when the user logs in, so each encryption and decryption requires obtaining the user's corresponding key pair before performing parameter encryption and decryption operations. As a result, the use of RSA encryption in communication easily leads to increased computing costs. Summary of the Invention

[0005] The embodiments of the present application provide a method, device, and medium for RSA-based encryption transmission, which are used to solve the following technical problem: the use of RSA encryption in communication easily leads to increased computing costs.

[0006] The embodiments of this application adopt the following technical solutions:

[0007] The present invention provides an RSA-based encryption transmission method, comprising: generating an RSA key pair, serializing the key pair, and caching the serialized key pair in a pre-set Redis; upon receiving encrypted data sent by a client, determining the public key corresponding to the serialized key in the pre-set Redis, encrypting the data to be encrypted using the public key corresponding to the serialized key to generate ciphertext; sending the ciphertext to the client, and decrypting the ciphertext using the client's corresponding private key to complete the RSA encrypted transmission of the data.

[0008] The embodiment of the present application generates an RSA key pair, serializes the key pair, and caches the serialized key pair in a preset Redis. The public key corresponding to the serialized key is determined in the preset Redis, and the encrypted data is encrypted using the public key corresponding to the serialized key to generate ciphertext. When needed, it can be directly read from the preset Redis and deserialized into a key object, thereby improving code performance. The embodiment of the present application addresses the performance and efficiency issues of the RSA encryption algorithm, adopts a high-performance encryption and decryption algorithm, and optimizes the algorithm implementation to improve the encryption and decryption speed.

[0009] In one implementation of the present application, when receiving the data to be encrypted sent by the client, the public key corresponding to the serialization key is determined in the preset Redis, specifically including: determining the user information corresponding to the data to be encrypted; based on the user information, determining the serialized reference key pair corresponding to the user information in the preset Redis; and determining the public key corresponding to the user information based on the reference key pair.

[0010] In one implementation of the present application, the key pair is serialized and the serialized key pair is cached in a preset Redis, specifically including: serializing the key pair through protostuff; and determining the user information corresponding to the key pair; mapping the user information with the serialized key pair; and caching the serialized key pair in the preset Redis based on the mapping relationship.

[0011] In one implementation of the present application, after encrypting the data to be encrypted by the public key corresponding to the serialized key and generating the ciphertext, the method further includes: obtaining the serialized private key in the preset Redis; digitally signing the transmitted data by using the deserialized private key data to generate a signature value.

[0012] In one implementation of the present application, after digitally signing the transmission data using the deserialized private key data and generating a signature value, the method further includes: during the data transmission process, obtaining the signature value and public key corresponding to the transmission data; and determining that the transmission data verification has passed when the signature value corresponding to the transmission data matches the public key.

[0013] In one implementation of the present application, when the data to be encrypted is received from the client, the public key corresponding to the serialized key is determined in the preset Redis, specifically including: when the data to be encrypted is received from the client, the required number of keys is determined based on the amount of data to be encrypted; the number of public keys corresponding to the serialized key pair extracted from the preset Redis is compared with the required number of keys; if the comparison results are consistent, it is determined that the number of extracted public keys is correct.

[0014] In one implementation of the present application, before caching the serialized key pair in the preset Redis, the method also includes: querying in the preset Redis whether there is a target key pair corresponding to the current user information; in response to the query result being non-existent, adding the key pair corresponding to the user information to the preset Redis.

[0015] In one implementation of the present application, after querying in the preset Redis whether there is a target key pair corresponding to the current user information, the method also includes: in response to the query result being yes, comparing the target key pair in the preset Redis with the new key pair corresponding to the current user information; if the comparison results are inconsistent, replacing the target key pair with the new key pair corresponding to the user information.

[0016] An embodiment of the present application provides an RSA-based encryption transmission device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so as to enable the at least one processor to: generate an RSA key pair, serialize the key pair, and cache the serialized key pair in a preset Redis; upon receiving data to be encrypted sent by a client, determine the public key corresponding to the serialization key in the preset Redis, encrypt the data to be encrypted using the public key corresponding to the serialization key, and generate a ciphertext; send the ciphertext to the client, and decrypt the ciphertext using the private key corresponding to the client, so as to complete the RSA encryption transmission of the data.

[0017] An embodiment of the present application provides a non-volatile computer storage medium storing computer-executable instructions, wherein the computer-executable instructions are configured to: generate an RSA key pair, serialize the key pair, and cache the serialized key pair in a preset Redis; upon receiving data to be encrypted sent by a client, determine the public key corresponding to the serialization key in the preset Redis, encrypt the data to be encrypted using the public key corresponding to the serialization key, and generate ciphertext; send the ciphertext to the client, and decrypt the ciphertext using the private key corresponding to the client to complete the RSA encrypted transmission of the data.

[0018] At least one of the above technical solutions adopted in the embodiments of the present application can achieve the following beneficial effects: the embodiments of the present application generate an RSA key pair, serialize the key pair, and cache the serialized key pair in a preset Redis. And determine the public key corresponding to the serialized key in the preset Redis, and encrypt the encrypted data with the public key corresponding to the serialized key to generate a ciphertext. When needed, it can be directly read from the preset Redis and deserialized into a key object, thereby improving the code performance. In order to solve the performance and efficiency problems of the RSA encryption algorithm, the embodiments of the present application adopt high-performance encryption and decryption algorithms, optimize the algorithm implementation, and improve the encryption and decryption speed. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments described in the present application. For those skilled in the art, other drawings can be obtained based on these drawings without inventive work. In the drawings:

[0020] Figure 1 A flowchart of an RSA-based encryption transmission method provided in an embodiment of the present application;

[0021] Figure 2 A schematic diagram of an RSA-based encryption transmission method provided in an embodiment of the present application;

[0022] Figure 3 A schematic diagram of the structure of an RSA-based encryption transmission device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0023] The embodiments of the present application provide a method, device and medium for RSA-based encryption transmission.

[0024] In order to enable those skilled in the art to better understand the technical solutions in this application, the following will clearly and completely describe the technical solutions in the embodiments of this application in conjunction with the drawings in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments of this specification, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of this application.

[0025] The technical solutions proposed in the embodiments of the present application are described in detail below with reference to the accompanying drawings.

[0026] Figure 1 The flowchart of an RSA-based encryption transmission method provided in the embodiment of the present application is as follows. Figure 1 As shown, the RSA-based encryption transmission method includes the following steps:

[0027] S101: Generate an RSA key pair, serialize the key pair, and cache the serialized key pair in a preset Redis.

[0028] In one embodiment of the present application, a key pair is serialized using protostuff, user information corresponding to the key pair is determined, the user information is mapped to the serialized key pair, and based on the mapping relationship, the serialized key pair is cached in a pre-set Redis.

[0029] Specifically, the main performance issue with applying RSA to gateways in the prior art is that a key pair is issued when a user logs in, so each encryption and decryption operation requires obtaining the user's corresponding key pair before performing parameter encryption and decryption operations. To avoid increasing code execution time by creating a key object from a key pair string each time, the embodiment of the present application generates an RSA key pair, serializes it into a string using protostuff, and then caches it in a pre-set Redis.

[0030] Furthermore, in order to quickly determine the required RSA key pair in the preset Redis when receiving data that needs to be encrypted, the user information is mapped to the serialized key pair. That is, when receiving data that needs to be encrypted, the user information corresponding to the data that needs to be encrypted is determined, and based on the user information, the RSA key pair corresponding to the user information is determined in the preset Redis.

[0031] In one embodiment of the present application, a query is made in the pre-set Redis to determine whether a target key pair corresponding to the current user information currently exists. In response to the query result being that the target key pair does not exist, the key pair corresponding to the user information is added to the pre-set Redis.

[0032] Specifically, when caching the generated key pair in the pre-installed Redis, the user information corresponding to the newly generated key pair is first determined. Based on the user information, the pre-installed Redis is checked to see whether a target key pair corresponding to the user information exists. If the target key pair corresponding to the user information does not exist in the pre-installed Redis, the newly generated key pair is cached in the pre-installed Redis.

[0033] In one embodiment of the present application, in response to the query result being present, the target key pair pre-set in Redis is compared with the new key pair corresponding to the current user information. If the comparison results are inconsistent, the target key pair is replaced with the new key pair corresponding to the user information.

[0034] Specifically, based on the user information corresponding to the newly generated key pair, a query is made in the preset Redis to see if the target key pair for the user information already exists. If the target key pair corresponding to the user information already exists in the preset Redis, the target key pair is compared with the newly generated key pair corresponding to the current user information.

[0035] Furthermore, if the comparison results are consistent, it means that the newly generated key pair is a duplicate key pair and does not need to be cached in the preset Redis to prevent data duplication.

[0036] Furthermore, if the comparison result is inconsistent, it means that the newly generated key is the updated key pair for the user information, and the updated key pair needs to be cached in the preset Redis, and the target key pair corresponding to the user information in the preset Redis is deleted.

[0037] S102: When receiving the data to be encrypted sent by the client, determine the public key corresponding to the serialization key in the preset Redis, encrypt the data to be encrypted using the public key corresponding to the serialization key, and generate a ciphertext.

[0038] In one embodiment of the present application, user information corresponding to the data to be encrypted is determined. Based on the user information, a serialized reference key pair corresponding to the user information is determined in a pre-set Redis. A public key corresponding to the user information is determined based on the reference key pair.

[0039] Specifically, after receiving the encrypted data from the client, the system determines the user information corresponding to the encrypted data. Based on the user information, the system performs a query in a pre-set Redis database to determine a reference key pair that is mapped to the user information. Based on the reference key pair, the system determines the public key corresponding to the current user information, and uses the public key to encrypt the current encrypted data to generate ciphertext.

[0040] In one embodiment of the present application, upon receiving data to be encrypted from a client, the number of keys required is determined based on the amount of data to be encrypted. The number of public keys corresponding to the serialized key pairs extracted from a pre-set Redis server is compared with the required number of keys. If the comparison results are consistent, the number of public keys extracted is determined to be correct.

[0041] Specifically, when receiving data to be encrypted sent by the client, the number of the received data to be encrypted is first determined. In actual applications, there are cases where one or more data to be encrypted are received at the same time. If multiple data to be encrypted are received at the same time, the number of keys required is determined based on the number of multiple data to be encrypted.

[0042] Furthermore, the corresponding serialized key pair is determined in the preset Redis through the user information corresponding to the data to be encrypted, and the corresponding public key is determined through the serialized key pair. The number of determined public keys is compared with the number of required keys. When the comparison results are consistent, it is determined that the number of public keys currently extracted in the preset Redis is correct, and the multiple data to be encrypted currently received are encrypted respectively through the extracted public keys.

[0043] In one embodiment of the present application, a serialized private key is obtained from a pre-installed Redis, and the transmitted data is digitally signed using the deserialized private key data to generate a signature value.

[0044] Specifically, after receiving the data to be encrypted, based on the user information corresponding to the data to be encrypted, the gateway also obtains the user's serialized private key from the preset Redis, uses the deserialized private key data for digital signing, and generates a signature value.

[0045] In one embodiment of the present application, during the data transmission process, a signature value and a public key corresponding to the transmitted data are obtained. If the signature value corresponding to the transmitted data matches the public key, it is determined that the transmitted data has passed verification.

[0046] Specifically, during data transmission, the gateway can use the signature value and public key to verify the integrity and authenticity of the data.

[0047] S103: Send the ciphertext to the client, and decrypt the ciphertext using the private key corresponding to the client to complete the RSA encrypted transmission of the data.

[0048] Specifically, the gateway transmits the encrypted ciphertext to the target recipient, who decrypts the ciphertext using the private key to restore the original data, thus completing the RSA encrypted transmission of the data.

[0049] Figure 2 A schematic diagram of an RSA-based encryption transmission method provided in an embodiment of the present application. Figure 2 As shown, sender A stores the public key of receiver B. The sender encrypts the data to be encrypted using the key and sends the encrypted data to receiver B. After receiving the encrypted data, receiver B decrypts the ciphertext based on the stored private key to obtain the original data, thus completing the encrypted data transmission.

[0050] In this embodiment, the RSA encryption transmission method is used to encrypt data at the gateway, thereby solving the performance and efficiency issues of traditional RSA encryption in communication. The gateway includes the following components and functions:

[0051] Key Management Module: Used to generate and manage RSA key pairs, including public and private keys. The Key Management Module is responsible for key generation, storage, updating, and protection.

[0052] Encryption and decryption modules: used to encrypt and decrypt data. The encryption module uses the public key to encrypt data, and the decryption module uses the private key to decrypt the ciphertext.

[0053] Digital Signature and Authentication Module: This module is used to generate and verify digital signatures. The digital signature module uses a private key to sign data, and the authentication module uses a public key to verify the signature.

[0054] Secure Communication Module: Responsible for secure data transmission and identity authentication. This module uses the RSA encryption algorithm to encrypt data and ensures data integrity and authenticity through digital signatures and identity authentication mechanisms.

[0055] Performance optimization module: To address the performance and efficiency issues of the RSA encryption algorithm, we adopt high-performance encryption and decryption algorithms and optimize the algorithm implementation to improve the encryption and decryption speed.

[0056] Figure 3 This is a schematic diagram of a structure of an RSA-based encryption transmission device provided in an embodiment of the present application. Figure 3 As shown, an RSA-based encryption transmission device includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to: generate an RSA key pair, serialize the key pair, and cache the serialized key pair in a preset Redis; when receiving data to be encrypted sent by a client, determine the public key corresponding to the serialization key in the preset Redis, and encrypt the data to be encrypted by the public key corresponding to the serialization key to generate a ciphertext; send the ciphertext to the client, and decrypt the ciphertext by the private key corresponding to the client to complete the RSA encryption transmission of the data.

[0057] An embodiment of the present application also provides a non-volatile computer storage medium storing computer-executable instructions, wherein the computer-executable instructions are configured to: generate an RSA key pair, serialize the key pair, and cache the serialized key pair in a preset Redis; upon receiving data to be encrypted sent by a client, determine the public key corresponding to the serialization key in the preset Redis, encrypt the data to be encrypted using the public key corresponding to the serialization key, and generate a ciphertext; send the ciphertext to the client, and decrypt the ciphertext using the private key corresponding to the client to complete the RSA encrypted transmission of the data.

[0058] The embodiment of the present application provides an RSA-based encryption transmission method for solving the performance and efficiency problems of traditional RSA encryption in communication. The main performance problem of applying RSA to the gateway is that a key pair is issued when the user logs in, so each encryption and decryption requires obtaining the user's corresponding key pair before performing parameter encryption and decryption operations. In order to avoid increasing the code execution time by creating a key object through a key pair string each time, the user key pair is serialized into a string using protostuff and cached in Redis. When needed, it can be directly read from Redis and deserialized into a key object. This step can improve code performance.

[0059] Those skilled in the art will appreciate that the embodiments of this specification may be provided as methods, systems, or computer program products. Therefore, the embodiments of this specification may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Furthermore, the embodiments of this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0060] This specification is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of this specification. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0061] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.

[0062] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0063] In a typical configuration, a computing device includes one or more processors (CPUs), input / output interfaces, network interfaces, and memory.

[0064] Memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.

[0065] Computer-readable media includes permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. The information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include transitory computer-readable media (transitory media), such as modulated data signals and carrier waves.

[0066] It should also be noted that the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, commodity, or apparatus that includes a series of elements includes not only those elements but also other elements not explicitly listed, or includes elements inherent to such process, method, commodity, or apparatus. In the absence of further limitations, an element defined by the phrase "comprises a ..." does not exclude the presence of other identical elements in the process, method, commodity, or apparatus that includes the element.

[0067] This specification may be described in the general context of computer-executable instructions, such as program modules, executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, and the like that perform specific tasks or implement specific abstract data types. This specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media, including storage devices.

[0068] The various embodiments in this application are described in a progressive manner. Similar portions between the various embodiments can be referenced to each other, and each embodiment focuses on the differences from the other embodiments. In particular, the device, apparatus, and non-volatile computer storage medium embodiments are generally similar to the method embodiments, so their descriptions are relatively simple. For relevant portions, refer to the descriptions of the method embodiments.

[0069] The foregoing is merely an embodiment of the present application and is not intended to limit the present application. It will be apparent to those skilled in the art that various modifications and variations may be made to the embodiments of the present application. However, such modifications or substitutions do not deviate from the spirit and scope of the technical solutions of the various embodiments of the present application.

Claims

1. A RSA-based encryption transmission method, characterized in that: The method comprises: Generate an RSA key pair, serialize the key pair, and cache the serialized key pair in a preset Redis; Upon receiving the data to be encrypted sent by the client, determining the public key corresponding to the serialization key in the preset Redis, encrypting the data to be encrypted using the public key corresponding to the serialization key to generate a ciphertext; The ciphertext is sent to the target recipient, and the ciphertext is decrypted using the private key corresponding to the target recipient to complete the RSA encrypted transmission of the data; When receiving the encrypted data sent by the client, determining the public key corresponding to the serialization key in the preset Redis specifically includes: Determining user information corresponding to the data to be encrypted; Based on the user information, determining a serialized reference key pair corresponding to the user information in the preset Redis; Determining a public key corresponding to the user information based on the reference key pair; The serializing the key pair and caching the serialized key pair in a preset Redis specifically includes: Serializing the key pair via protostuff; and Determining user information corresponding to the key pair; Mapping the user information to the serialized key pair; Based on the mapping relationship, the serialized key pair is cached in a preset Redis; After encrypting the data to be encrypted using the public key corresponding to the serialization key to generate ciphertext, the method further includes: Obtain the serialized private key in the preset Redis; Digitally sign the transmitted data using the deserialized private key data to generate a signature value; After the transmission data is digitally signed using the deserialized private key data to generate a signature value, the method further includes: During the data transmission process, obtaining the signature value and public key corresponding to the transmitted data; In a case where the signature value corresponding to the transmission data matches the public key, it is determined that the transmission data has passed verification.

2. The RSA-based encryption transmission method according to claim 1, characterized in that: When receiving the encrypted data sent by the client, determining the public key corresponding to the serialization key in the preset Redis specifically includes: Upon receiving the data to be encrypted sent by the client, determining the number of keys required based on the amount of the data to be encrypted; Compare the number of public keys corresponding to the serialized key pair extracted from the preset Redis with the required number of keys; If the comparison results are consistent, it is determined that the number of extracted public keys is correct.

3. The RSA-based encryption transmission method according to claim 1, characterized in that: Before caching the serialized key pair in the preset Redis, the method further includes: In the preset Redis, query whether there is a target key pair corresponding to the current user information; In response to the query result being non-existent, the key pair corresponding to the user information is added to the preset Redis.

4. The RSA-based encryption transmission method according to claim 3, characterized in that: After querying whether a target key pair corresponding to the current user information currently exists in the preset Redis, the method further includes: In response to the query result being yes, comparing the target key pair in the preset Redis with the new key pair corresponding to the current user information; If the comparison results are inconsistent, the target key pair is replaced with a new key pair corresponding to the user information.

5. An RSA-based encryption transmission device comprising: at least one processor; as well as, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to: Generate an RSA key pair, serialize the key pair, and cache the serialized key pair in a preset Redis; Upon receiving the data to be encrypted sent by the client, determining the public key corresponding to the serialization key in the preset Redis, encrypting the data to be encrypted using the public key corresponding to the serialization key to generate a ciphertext; The ciphertext is sent to the target recipient, and the ciphertext is decrypted using the private key corresponding to the target recipient to complete the RSA encrypted transmission of the data; When receiving the encrypted data sent by the client, determining the public key corresponding to the serialization key in the preset Redis specifically includes: Determining user information corresponding to the data to be encrypted; Based on the user information, determining a serialized reference key pair corresponding to the user information in the preset Redis; Determining a public key corresponding to the user information based on the reference key pair; The serializing the key pair and caching the serialized key pair in a preset Redis specifically includes: Serializing the key pair via protostuff; and Determining user information corresponding to the key pair; Mapping the user information to the serialized key pair; Based on the mapping relationship, the serialized key pair is cached in a preset Redis; After encrypting the data to be encrypted using the public key corresponding to the serialization key to generate a ciphertext, the method further includes: Obtain the serialized private key in the preset Redis; Digitally sign the transmitted data using the deserialized private key data to generate a signature value; After the transmission data is digitally signed by the deserialized private key data and the signature value is generated, the following steps are further included: During the data transmission process, obtaining the signature value and public key corresponding to the transmitted data; In a case where the signature value corresponding to the transmission data matches the public key, it is determined that the transmission data has passed verification.

6. A non-volatile computer storage medium storing computer-executable instructions, wherein the computer-executable instructions are configured to: Generate an RSA key pair, serialize the key pair, and cache the serialized key pair in a preset Redis; Upon receiving the data to be encrypted sent by the client, determining the public key corresponding to the serialization key in the preset Redis, encrypting the data to be encrypted using the public key corresponding to the serialization key to generate a ciphertext; The ciphertext is sent to the target recipient, and the ciphertext is decrypted using the private key corresponding to the target recipient to complete the RSA encrypted transmission of the data; When receiving the encrypted data sent by the client, determining the public key corresponding to the serialization key in the preset Redis specifically includes: Determining user information corresponding to the data to be encrypted; Based on the user information, determining a serialized reference key pair corresponding to the user information in the preset Redis; Determining a public key corresponding to the user information based on the reference key pair; The serializing the key pair and caching the serialized key pair in a preset Redis specifically includes: Serializing the key pair via protostuff; and Determining user information corresponding to the key pair; Mapping the user information to the serialized key pair; Based on the mapping relationship, the serialized key pair is cached in a preset Redis; After encrypting the data to be encrypted using the public key corresponding to the serialization key to generate a ciphertext, the method further includes: Obtain the serialized private key in the preset Redis; Digitally sign the transmitted data using the deserialized private key data to generate a signature value; After the transmission data is digitally signed by the deserialized private key data and the signature value is generated, the following steps are further included: During the data transmission process, obtaining the signature value and public key corresponding to the transmitted data; In a case where the signature value corresponding to the transmission data matches the public key, it is determined that the transmission data has passed verification.

Citation Information

Patent Citations

  • Authorization control method and device, authorization method and device and computing equipment

    CN113326482A

  • Encryption and decryption method and device, equipment and medium

    CN114900338A