Python generates a pair of RSA keys and saves the public and private keys as .pem files respectively. Use the public key in the generated RSA key pair to encrypt the data, and then use the private key to decrypt. Convert RSA’s public key exponent (E) and modulus (N) to .pem format

You can use the cryptography library to generate a pair of RSA keys and save the public and private keys as .pem files respectively. Here is a sample code: from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives import serialization from cryptography.hazmat.primitives.asymmetric import rsa # Generate RSA key pair private_key = rsa.generate_private_key( public_exponent=65537, key_size=2048, backend=default_backend() ) # Get […]

Pre-middle and post-order traversal (recursive and non-recursive) and level-order traversal of binary trees

Pre-middle and post-order traversal (recursive and non-recursive) and level-order traversal of binary trees Article directory Pre-middle and post-order traversal (recursive and non-recursive) and level-order traversal of binary trees Preface 1. Recursive implementation 1. Preorder traversal 2. In-order traversal 3. Post-order traversal 2. Non-recursive implementation 1. Preorder traversal 2. In-order traversal 3. Postorder traversal 3. Layer […]

4. IPSec NAT traversal

IPSec NAT traversal 1. IPSec NAT traversal 2. Processing of IPSec traversal through NAT 3. IKEv2 and NAT traversal 3.1. NAT-T capability detection 3.2. NAT gateway discovery 3.3. Enabling NAT traversal 3.4. NAT-keepalive 4. IPSec NAT traversal example (NAT devices exist between gateways) 5. IPSec NAT traversal example (the egress gateway is a NAT device, […]

Euler angles (roll angle, pitch angle, yaw angle), rotation matrix, quaternion conversion and solution to universal joint deadlock

1. Overview The description method of the pose (position and direction) of an object is generally represented by two coordinate systems. One is the world coordinate system or the ground coordinate system. Here I call it the ground coordinate system, which belongs to the reference coordinate system; the other is its own Coordinate system, it […]

STL–vector container (construction, traversal, insertion and deletion, capacity size, data access, dynamic expansion, etc.)

vector Foreword In the past few days, I have used STL a lot when writing code, and I have also felt the power of STL, so I reviewed the content of STL again, and summarized and extracted some basic things and important content. This is a vector article . C++’s STL provides us with many […]

[Unity Practical Combat] Implementing a powerful, universal and easy-to-expand dialogue system (with project source code) (supplementary update on 2023/12/26)

Article directory Let’s take a look at the final effect first Preface material initial preparation work 1. Simple drawing of terrain 2. Draw dialog box 3. Configure character animation 4. Achieve simple control of character movement Control the display and hiding of dialog boxes Define conversation content Implement simple conversation function Verbatim printing effect Quickly […]

Use of RSA encryption (front and back ends)

Public key (publicKey) encryption, private key (privateKey) decryption. Cannot be reversed, private key (privateKey) encryption, public key (publicKey) decryption. To put it bluntly, both the front and back ends need to use the public key (publicKey) for encryption and the private key (privateKey) for decryption. Introducing the front-end JS library: jsencrypt.js npm install jsencrypt Use […]