Python库“加密”冲突

时间:2018-08-13 03:49:35

标签: python-3.x

我正在尝试集成两个框架,并且正在安装这两个框架的需求,但是似乎两个框架中都使用了库“ Crypto”,并且具有不同的使用版本,所以如果我安装一个框架的需求的框架,它返回我的第一个错误:

exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
  File "/usr/lib/python3.6/threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
  File "dapp_bdb.py", line 95, in custom_background_code
put_bdb("Hello world")
  File "dapp_bdb.py", line 68, in put_bdb
    fulfilled_creation_tx = bdb.transactions.fulfill(prepared_creation_tx, private_keys=private_key)
  File "/home/ubuntu/.local/lib/python3.6/site-packages/bigchaindb_driver/driver.py", line 270, in fulfill
return fulfill_transaction(transaction, private_keys=private_keys)
  File "/home/ubuntu/.local/lib/python3.6/site-packages/bigchaindb_driver/offchain.py", line 346, in fulfill_transaction
signed_transaction = transaction_obj.sign(private_keys)
  File "/home/ubuntu/.local/lib/python3.6/site-packages/bigchaindb_driver/common/transaction.py", line 823, in sign
PrivateKey(private_key) for private_key in private_keys}
  File "/home/ubuntu/.local/lib/python3.6/site-packages/bigchaindb_driver/common/transaction.py", line 823, in <dictcomp>
PrivateKey(private_key) for private_key in private_keys}
  File "/home/ubuntu/.local/lib/python3.6/site-packages/bigchaindb_driver/common/transaction.py", line 817, in gen_public_key
public_key = private_key.get_verifying_key().encode()
  File "/home/ubuntu/.local/lib/python3.6/site-  packages/cryptoconditions/crypto.py", line 62, in get_verifying_key
return   Ed25519VerifyingKey(self.verify_key.encode(encoder=Base58Encoder))
 File "/home/ubuntu/.local/lib/python3.6/site-packages/nacl/encoding.py", line 90, in encode
return encoder.encode(bytes(self))
 File "/home/ubuntu/.local/lib/python3.6/site-packages/cryptoconditions/crypto.py", line 15, in encode
return base58.b58encode(data).encode()
AttributeError: 'bytes' object has no attribute 'encode'

以及框架的第二个要求,它还向我返回了其他错误:

<button id="btn_change">OK</button>
<br>
<p id="content"></p>

<script>

(function() {
   var httpRequest;
   //Set an event listener on your button
   document.getElementById("btn_change").addEventListener('click', makeRequest);

   function makeRequest() {
      httpRequest = new XMLHttpRequest();

      if (!httpRequest) {
          alert('Giving up :( Cannot create an XMLHTTP instance');
          return false;
      }

      httpRequest.onreadystatechange = setContents;
      //Open then send the request to your page
      httpRequest.open('GET', 'myText1.txt');
      httpRequest.send();
   }

   function setContents() {
     if (httpRequest.readyState === XMLHttpRequest.DONE) {
       if (httpRequest.status === 200) {
        //Set the contents of your p tag
         document.getElementById("content").innerHTML = httpRequest.responseText;
       } else {
         alert('There was a problem with the request.');
       }
    }
 }
})();    
</script>    
</body>

有什么想法可以避免吗?

1 个答案:

答案 0 :(得分:1)

好像cryptoconditions库做错了。

您应该提交一个错误,要求更新所需的base58版本并查看对其的所有调用。 Python3的通常行为是在bytes上返回some_encoder_library.encode(),在str上返回some_encoder_library.decode()base58模块的新版本遵循此规则,尽管base58编码的对象当然绝不包含任何特殊符号。 cryptoconditions仍在使用先前版本,其中b58encode返回str

同时,您可以对已安装的库进行本地修改,也可以对其进行本地修改,然后安装fork。 从this line删除encode()呼叫后,一切可能都可以正常工作。