2017-03-04 34 views
1

當我嘗試使用ripemd160hashlib它說它無法找到它。hashlib找不到ripemd160

我用easy_install hashlib安裝hashlib,但它仍然無法找到ripemd160。

我使用Ubuntu和python2.7

def hexHash(str, withHash = None): 
    h = hashlib.new('ripemd160') 
    h.update(str) 
    if withHash != None: 
     return h.hexdigest()[0:6] 
    else: 
     return '#'+h.hexdigest()[0:6] 

ValueError: unsupported hash type

+0

你可以顯示你正在使用的代碼和給出的確切的錯誤信息嗎? –

+0

是的,我編輯它。 – CriticalTheWizard

回答

1

Hashlib是Python的標準庫的一部分,所以你不必安裝它。

但是,唯一保證可用的散列算法是md5,sha1,sha224,sha256,sha384和sha512。

其他可能可用,取決於您的平臺上使用的SSL庫。

您可以在終端中運行openssl list-message-digest-algorithms以查看哪些算法可用。

或者用Python:

import hashlib 

print hashlib.algorithms_available 

如果ripemd160不可用,你應該考慮重新安裝你的SSL庫使用不同的選項。

如果您要將SSL庫更改爲具有不同版本號的庫,則必須重新構建依賴於該庫的任何內容。