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 […]

Implementation code of AES/ECB/PKCS5Padding algorithm for secret key encryption and decryption of any length consistent with JAVA, Python and PHP

Recently, I encountered an AES encryption algorithm that needs to be implemented in Java, Python, and PHP. In fact, it is not very complicated in nature, but the parameter adjustment is quite troublesome. I found some reference materials and finally got it. The actual code is as follows: Main features The three languages of JAVA, […]

How to hide encrypted password in python?

There are various Python modules for masking user-entered passwords, one of which is the **maskpass()module. In Python, with the help of themaskpass()module and thebase64()** module, we can hide the user’s password using an asterisk (*) while typing, and then with the help of the base64() module It can be encrypted. maskpass() maskpass() is a Python […]

Django+MySQL data desensitization and encryption access

1. Overview In the Django project, desensitizing the user name and password registered by the front-end client (after encrypting it) and storing it in the target database MySQL can be achieved through the following steps: Install the necessary libraries: Make sure that password hashing libraries such as bcrypt or passlib are installed in the current […]

Spring Boot interface data encryption and decryption, so easy!

Bucai Chen Coder Technology Column 2023-11-09 09:01 Published in Zhejiang Included in the collection #Spring Boot Advanced 99 Hello everyone, I am Bucai Chen~ Today’s article talks about interface security issues, involving interface encryption and decryption. After discussing external demands with students on products and front-end, we sorted out relevant technical solutions. The main demand […]

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 […]

Springboot interface encryption example (2)

RESTUDY A wolf on the road 2023-10-20 17:55 Published in Beijing Included in the collection #Interface Encryption 2 The previous article introduced interface encryption and provided the corresponding project source code (please message me privately if necessary). It uses RSA encryption and decryption. Although it is highly secure, the encryption and decryption speed is slow. […]