V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
mcoo1997
V2EX  ›  Python

求助 Python 用 RSA 签名报错

  •  
  •   mcoo1997 · 2016-12-03 13:48:43 +08:00 · 2606 次点击
    这是一个创建于 2672 天前的主题,其中的信息可能已经有所发展或是发生改变。

    import rsa signature = rsa.sign(code2, RSA_PRIVATE, 'SHA-1')

    报错: Traceback (most recent call last): File "D:/paython/test.py", line 104, in <module> signature = rsa.sign(code2, RSA_PRIVATE, 'SHA-1') File "C:\Python27\lib\rsa\pkcs1.py", line 276, in sign keylength = common.byte_size(priv_key.n) AttributeError: 'str' object has no attribute 'n'

    求助!

    3 条回复    2016-12-05 11:04:52 +08:00
    Kilerd
        1
    Kilerd  
       2016-12-03 16:59:51 +08:00 via iPhone
    很明显,参数传入不正确
    mcoo1997
        2
    mcoo1997  
    OP
       2016-12-04 13:39:55 +08:00
    @Kilerd code2 是字符串 key 用几种格式试了都是这个结果
    mcoo1997
        3
    mcoo1997  
    OP
       2016-12-05 11:04:52 +08:00
    小白求助大家
    Google 搜了下也没找到解决方案
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1446 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 17:25 · PVG 01:25 · LAX 10:25 · JFK 13:25
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.