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

发布于 2024-08-22 18:20:25 字数 1187 浏览 1 评论 0 原文

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

简而言之,我需要将以下 Ruby 代码翻译为 Python。它取自 PayPal 网站付款标准用于 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

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"),
    OpenSSL::PKCS7::BINARY)           
end

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

薄情伤 2024-08-29 18:20:25

查看 Keyczar 库,它应该可以在 Google App Engine 上运行,允许您使用 RSA 进行签名 /em> 并使用 DES3 加密。

请在此处查看文档。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文