pypy 对接阿里短信平台
由于pycrypto在pypy下安装很麻烦,直接改为rsa模块
aliyun-python-sdk-core目录下setup.py注释或删除一下代码
install_requires=[ 'pycrypto>=2.6.1' ],
aliyun-python-sdk-core/aliyunsdkcore/auth/algorithm目录下
# coding=utf-8 import urllib import base64 # from Crypto.Signature import PKCS1_v1_5 # from Crypto.Hash import SHA256 # from Crypto.PublicKey import RSA import rsa def get_sign_string(source, access_secret): secret = base64.decodestring(access_secret) rsa.PrivateKey.load_pkcs1(secret) signed_bytes = rsa.sign(source,key,'SHA-256') # key = RSA.importKey(secret) # h = SHA256.new(source) # signer = PKCS1_v1_5.new(key) # signed_bytes = signer.sign(h) signature = base64.encodestring(signed_bytes).replace('\n', '') return signature def get_signer_name(): return "SHA256withRSA" def get_singer_version(): return "1.0" def get_signer_type(): return "PRIVATEKEY"
就可以了
pypy setup.py insatll