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