简体   繁体   English

让django-paypal与pycrypto一起工作吗?

[英]Get django-paypal working with pycrypto?

I would like to use the button encryption in django-paypal, but it requires M2Crypto which will not build on webfaction servers. 我想在django-paypal中使用按钮加密,但是它需要M2Crypto,它将不能在webfaction服务器上构建。 Tech support at Webfaction told me that pycrypto is already installed on the system, but I am too dumb to translate from M2Crypto to pycrypto. Webfaction的技术支持告诉我,系统上已经安装了pycrypto,但是我太笨了,无法从M2Crypto转换为pycrypto。

Can anyone tell me how to convert the following to work with pycrypto (if possible)? 谁能告诉我如何将以下内容转换为与pycrypto一起使用(如果可能)? This is just a small snip showing he encryption, I can post the entire function if needed. 这只是显示加密的小片段,如果需要,我可以发布整个功能。

    s = SMIME.SMIME()   
    s.load_key_bio(BIO.openfile(CERT), BIO.openfile(PUB_CERT))
    p7 = s.sign(BIO.MemoryBuffer(plaintext), flags=SMIME.PKCS7_BINARY)
    x509 = X509.load_cert_bio(BIO.openfile(settings.PAYPAL_CERT))
    sk = X509.X509_Stack()
    sk.push(x509)
    s.set_x509_stack(sk)
    s.set_cipher(SMIME.Cipher('des_ede3_cbc'))
    tmp = BIO.MemoryBuffer()
    p7.write_der(tmp)
    p7 = s.encrypt(tmp, flags=SMIME.PKCS7_BINARY)
    out = BIO.MemoryBuffer()
    p7.write(out)   
    return out.read()

I was able to get it to build. 我能够建立它。 Here is all you need to do to make it happen: 这是您要做的所有事情:

cat >> ~/.pydistutils.cfg << EOF
[build_ext]
include_dirs=/usr/include/openssl
EOF
easy_install-2.5 --install-dir=$HOME/lib/python2.5 --script-dir=$HOME/bin m2crypto

pycrypto is very incomplete. pycrypto非常不完整。 It does not support the padding schemes and formats that you need. 它不支持您所需的填充方案和格式。 Adding support for those formats is not trivial and will require a lot of time. 添加对这些格式的支持并非易事,并且需要大量时间。

You may be able to set up a virtual machine locally and duplicate enough of the webfaction server environment to build it yourself. 您也许可以在本地设置虚拟机并复制足够的webfaction服务器环境以自己构建它。 Then upload to somewhere on your pythonpath 然后上传到您的pythonpath上的某个地方

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM