如何在Google App Engine中动态创建加密的PayPal按钮?

时间:2010-02-25 14:16:37

标签: google-app-engine encryption paypal pkcs#7

到目前为止,我已经找到了使用example的Django M2Crypto,但由于M2Crypto基于C库,因此无法在GAE上运行。有没有人在Google App Engine中动态创建加密的PayPal按钮?

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

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

1 个答案:

答案 0 :(得分:0)

查看Keyczar库,它应该适用于Google App Engine,允许您使用 RSA 进行签名并使用 DES3 进行加密。

查看文档here