0

64ビットPython2.7の試用版をダウンロードしました:chilkat-9.3.2-python-2.7-x86_64-linux.tar.gz。私は奇妙な問題を見つけました:与えられたRSA暗号化文字列をデコードする1つのメソッド(次のようにdecrypRSA())を書いたとき、それはLinuxのコマンドラインで直接呼び出した場合にのみ機能します。httpリクエストに応答するために他のメソッドで呼び出された場合、例外を確実にスローします。この問題のトラブルシューティングはWebサイトで見つかりませんでした。

Here is the exception stack track:

File "/data/api_test.xxx.com/0/v0/share/auth/utils.py", line 301, in decrypRSA
    return rsa.decryptStringENC(encodedText,False)
  File "/usr/local/lib/python2.7/site-packages/chilkat.py", line 1319, in decryptStringENC
    def decryptStringENC(self, *args): return _chilkat.CkRsa_decryptStringENC(self, *args)

TypeError: in method 'CkRsa_decryptStringENC', argument 2 of type 'char const *'


And here is the definition for decrypRSA() method:


    @staticmethod
    def decrypRSA(encodedText, publicKey):
        print ('Utils.decrypRSA()-parameters: encodeText=%s, public key=%s' % (encodedText, publicKey,))
        rsa = CkRsa()
        success = rsa.UnlockComponent("30-day trial")
        if (success != True):
            logging.info("Utils.decrypRSA(): RSA component unlock failed")
            return ''
        #  Import the public key into the RSA object:
        success = rsa.ImportPublicKey(publicKey)
        if (success != True):
            logging.info("Utils.decrypRSA(): RSA failed to import public key: %s" % rsa.lastErrorText())
            return ''
        rsa.put_EncodingMode("base64")
        rsa.put_LittleEndian(True)
        return rsa.decryptStringENC(encodedText,False)
4

1 に答える 1

0

それが内部的なものなのか、encodedTextが渡したものなのかはわかりません。これは、Unicode文字列が「charconst*」以外にキャストされている問題である可能性があります。この場合、文字列をエンコードするか、Unicode文字列の代わりに通常のASCII文字列を使用できます。

これを見た:https ://github.com/chokkan/simstring/issues/6

于 2012-09-07T08:13:10.330 に答える