2010-02-25 41 views
3

到目前为止,我发现Django的example使用M2Crypto,但由于M2Crypto基于C库,因此无法在GAE上运行。有没有人有工作代码在Google App Engine中动态创建加密PayPal按钮?如何在Google App Engine中动态创建加密的PayPal按钮?

简而言之,我需要将以下Ruby代码翻译成Python。它取自Ruby的PayPal's Website Payments Standard toolkit

def self.encrypt_data(paypal_cert, my_business_cert, my_business_key, 
         my_business_key_password, myparams )  
    paypal_cert  = OpenSSL::X509::Certificate.new(paypal_cert)  
    my_business_cert = OpenSSL::X509::Certificate.new(my_business_cert)  
    my_business_key = OpenSSL::PKey::RSA.new(
    my_business_key, 
    my_business_key_password) 
    info = "" 
    myparams.each_pair {|key,value| info << "#{key}=#{value}\n"}  
    signedInfo  = OpenSSL::PKCS7::sign(
    my_business_cert, 
    my_business_key, 
    info, 
    [], 
    OpenSSL::PKCS7::BINARY) 
    OpenSSL::PKCS7::encrypt(
    [paypal_cert], 
    signedInfo.to_der, 
    OpenSSL::Cipher::Cipher::new("DES3"), 
    OpenSSL::PKCS7::BINARY)   
end 

回答

0

,看一下Keyczar库,它应该在谷歌App Engine的工作,让您使用RSA签署并与DES3加密。

检查文档here