1. Python-RSA使用手册

英文文档见Python-RSA使用手册,主要介绍了Python-RSA的消息的加密解密、文件的加密解密以及签名的方法。

Installation

使用pip install rsa安装Python-RSA模块

Generating keys

>>> import rsa
>>> (pubkey, privkey) = rsa.newkeys(512)

Encryption and decryption

To encrypt or decrypt a message, use rsa.encrypt() resp. rsa.decrypt(). Let’s say that Alice wants to send a message that only Bob can read.

  1. Bob generates a keypair, and gives the public key to Alice. This is done such that Alice knows for sure that the key is really Bob’s (for example by handing over a USB stick that contains the key).

    >>> import rsa
    >>> (bob_pub, bob_priv) = rsa.newkeys(512)
  2. Alice writes a message, and encodes it in UTF-8. The RSA module only operates on bytes, and not on strings, so this step is necessary.

    >>> message = 'hello Bob!'.encode('utf8')
  3. Alice encrypts the message using Bob’s public key, and sends the encrypted message.

    >>> import rsa
    >>> crypto = rsa.encrypt(message, bob_pub)
  4. Bob receives the message, and decrypts it with his private key.

    >>> message = rsa.decrypt(crypto, bob_priv)
    >>> print(message.decode('utf8'))
    hello Bob!

Python 常用库(随时补充)的更多相关文章

  1. python 常用库, 随时添加中

    python只有你想不到的库,只要你能想到,肯定有对应的库 前面*的为标准库,**的是pip里面的,***则是要手动安装的1)python运行时服务* copy: copy模块提供了对复合(compo ...

  2. python 常用库整理

    python 常用库整理 GUI 图形界面 Tkinter: Tkinter wxPython:wxPython pyGTK:PyGTK pyQt:pyQt WEB框架 django:django w ...

  3. python常用库安装网址

    python常用库安装网址如下: http://pypi.python.org/pypi

  4. windows下python常用库的安装

    windows下python常用库的安装,前提安装了annaconda 的python开发环境.只要已经安装了anaconda,要安装别的库就很简单了.只要使用pip即可,正常安装好python,都会 ...

  5. Python常用库整理

    Python常用库整理 Python中到底有哪些库会让程序员爱不释手?以至于一次上瘾,造成永久性伤害(这句话好像在哪里见过),今天我们就来整理一番这样的库,欢迎各位在评论区或者私信我添加或者修改相关库 ...

  6. python常用库

    本文由 伯乐在线 - 艾凌风 翻译,Namco 校稿.未经许可,禁止转载!英文出处:vinta.欢迎加入翻译组. Awesome Python ,这又是一个 Awesome XXX 系列的资源整理,由 ...

  7. Python常用库大全

    环境管理 管理 Python 版本和环境的工具 p – 非常简单的交互式 python 版本管理工具. pyenv – 简单的 Python 版本管理工具. Vex – 可以在虚拟环境中执行命令. v ...

  8. python常用库 - NumPy 和 sklearn入门

    Numpy 和 scikit-learn 都是python常用的第三方库.numpy库可以用来存储和处理大型矩阵,并且在一定程度上弥补了python在运算效率上的不足,正是因为numpy的存在使得py ...

  9. Python常用库大全,看看有没有你需要的

    作者:史豹链接:https://www.zhihu.com/question/20501628/answer/223340838来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明 ...

  10. python常用库(转)

    转自http://www.west999.com/info/html/wangluobiancheng/qita/20180729/4410114.html Python常用的库简单介绍一下 fuzz ...

随机推荐

  1. LeetCode 第 3 题:无重复字符的最长子串(滑动窗口)

    LeetCode 第 3 题:无重复字符的最长子串 (滑动窗口) 方法:滑动窗口 滑动窗口模板问题:右指针先走,满足了一定条件以后,左指针向前走,直到不满足条件. 特点:左右指针的方向是一致的,并且是 ...

  2. React 开发中面临的九个重要抉择

    抉择系列:在技术开发的过程中我们会面临着各种各样的抉择,我们在不同情境下该如何选择恰当的技术,这是本系列文章想要解决的问题. 在 React 开发的过程中我们常常会遇到一些抉择,下面我将选取其中一些个 ...

  3. vue中limitBy,filterBy,orderBy的用法

    1.limitBy的用法 <body> <div id="box"> <ul> <li v-for="val in arr | ...

  4. python模块------pyautogui

    安装 pip install pyautogui 基本使用 查询 screenWidth, screenHeight = pyautogui.size() # 屏幕尺寸 mouseX, mouseY ...

  5. 四、日志输出Reporter.log

    一.Reporter.log import org.testng.Reporter; public class TestLog { public static void main(String[] a ...

  6. hive跑mapreduce报java.lang.RuntimeException: Error in configuring object

    写于2016.7月 最近项目需要在hbase上做统计分析,在本机上装了hive,结果跑小批量数据sum时报错: hive> select count(*) from page_view; Tot ...

  7. warning: accessed via instance reference

    提示如图: 先简单翻译一下: 静态成员***通过实例对象访问 显示通过类实例而不是类本身调用方法和属性. 现有一个类Test,有静态方法methods和静态属性fields. 对于静态变量或方法,推荐 ...

  8. ubuntu登录SYSU-SECURE

    1. 选中SYSU-SECURE网络连接. 2. 点击进入Wi-Fi 安全性选项卡. 3. 修改[认证(T)]项的值为[受保护的EAP(PEAP)]. 4. 连接成功.

  9. SI_WorkShop_V4安装手册

    V4安装手册 第一步 启动workshopV4 解压workshopV4.rar,在解压后的目录中双击eclipse.exe启动workshopV4,启动画面如下图所示:(注:解压后第1次启动速度会慢 ...

  10. vim开发配置

    需求:使用vim开发python,可以进行简单配置 cd 到用户宿主目录下 vim .vimrc 粘贴以下内容: 版本一: set encoding=utf-8"去掉vi的一致性" ...