Skip to main content

python enables rsa encryption

Project description

面向正方教务使用的 rsa 加密方法的 Python 实现

基本使用

安装

pip install PyRsa

基本使用

使用 RsaKey 模块

由于本模块是面向正方教务的加密,因此 modulus 长度应为 172;如果单纯是加密着玩的话,那么 modulus 与 pre_psw 两个参数的长度则有所限制,大概就是

modulus = int(psw / 3) + 15 + psw

嘛,谁会这么无聊干这事儿呢

>>> from PyRsa.pyrsa import RsaKey
>>> from PyRsa.pyb64 import Base64
>>> modulus = "AJftLhHzsQPu1LwCgOR41hRKn4tbaD/ehyZKiBWDYCpaualtMyJIT0SzBl07O2NwjxI8uwr82SMvEW9iiSEoBylHOWNnEzyOYwXb29xMo+D4LTVqMX7NkAliIqH+wOSA1g0DVxmcQWCtGVI4vDUnGIN8tYPlxc9NIXN5zO0HwqKn"
>>> exponent = 'AQAB'
>>> rsakey.set_public(Base64().b64tohex(modulus), Base64().b64tohex(exponent))
>>> psw = '1234567890'
>>> en_psw = Base64().hex2b64(rsakey.encrypt(pre_psw))

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

PyRsa-1.0.3.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

PyRsa-1.0.3-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file PyRsa-1.0.3.tar.gz.

File metadata

  • Download URL: PyRsa-1.0.3.tar.gz
  • Upload date:
  • Size: 9.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for PyRsa-1.0.3.tar.gz
Algorithm Hash digest
SHA256 d00e92b62cf8b4d6c1e5147a8b477cf5c2649bb83096ce9094d109929788ac9b
MD5 1b42c4c1f74d21a3c37853e968e7edaf
BLAKE2b-256 c5c8e8bcdf5eff24344c46aff114beca582876cbb6c952337a5c2a346695e1f9

See more details on using hashes here.

File details

Details for the file PyRsa-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: PyRsa-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 11.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for PyRsa-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e986de1d012f730e0b67db43e90e2e098bb4933db26a4202100ec8f0906d3e36
MD5 0e0dee8664a34914a16df11f1094916d
BLAKE2b-256 c45488dc0c58c6951de19038e489ecd92a24cd5e007800fe7f1b8b5786d38daa

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page