开发者

How do I create an encrypted PayPal button dynamically in Google App Engine?

开发者 https://www.devze.com 2022-12-21 01:33 出处:网络
So far I have found an example for Django that uses M2Crypto, but because M2Crypto is based on a C library, it cannot be run on GAE. Does anyone have a working code for creating an encrypted PayPal bu

So far I have found an example for Django that uses M2Crypto, but because M2Crypto is based on a C library, it cannot be run on GAE. Does anyone have a working code for creating an encrypted PayPal button dynamically in Google App Engine?

In a nutshell, I need to translate the following Ruby code into Python. It's taken from PayPal's Website Payments Standard toolkit for 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")开发者_StackOverflow社区,
    OpenSSL::PKCS7::BINARY)           
end


Have a look to Keyczar library, it should work on Google App Engine allowing you to sign using RSA and encrypt with DES3 .

Check the documentation here.

0

精彩评论

暂无评论...
验证码 换一张
取 消