Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/funnygeeker/micropython-easyrsa
Simple RSA encryption implementation (with limitations) (有缺陷)简单的 RSA 加密实现
https://github.com/funnygeeker/micropython-easyrsa
esp32 esp8266 micropython rsa
Last synced: 5 days ago
JSON representation
Simple RSA encryption implementation (with limitations) (有缺陷)简单的 RSA 加密实现
- Host: GitHub
- URL: https://github.com/funnygeeker/micropython-easyrsa
- Owner: funnygeeker
- License: mit
- Created: 2023-12-01T06:27:53.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2023-12-27T15:51:02.000Z (11 months ago)
- Last Synced: 2023-12-27T16:33:53.686Z (11 months ago)
- Topics: esp32, esp8266, micropython, rsa
- Language: Python
- Homepage:
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.ZH-CN.md
- License: LICENSE
Awesome Lists containing this project
README
[English (英语)](./README.md)
### micropython-easyrsa
- (有缺陷)简单的 RSA 加密实现
- 仅用于学习用途,不适合用于生产环境
- 目前可以在 Python 上面加密和解密,或者,使用 Python 加密,在 MicroPython 上面进行解密### 示例代码
```python
from lib.easyrsa import EasyRSA
# 示例用法
rsa = EasyRSA(256)
public_key, private_key = rsa.generate_keys()# 保存公钥和私钥到文件
rsa.save_key_to_file(public_key, "public_key.txt")
rsa.save_key_to_file(private_key, "private_key.txt")# 从文件加载公钥和私钥
loaded_public_key = rsa.load_key_from_file("public_key.txt")
loaded_private_key = rsa.load_key_from_file("private_key.txt")# 加密
message = b"Hello, World!"
ciphertext = rsa.encrypt(message, loaded_public_key)
print("Message:", message)
print("Encrypt:", ciphertext)
print('Decrypt:', rsa.decrypt(ciphertext, private_key))
```