2014-03-25 2 views
0

해시를 생성하려면 inbuilt 및 md4을 사용하여 Openssl에서 제공하려고합니다. 이 내 코드Python ripemd160 오류

import hashlib 
c = input("Enter: ") 
c = c.encode('utf-8') 
h = hashlib.new('ripemd160') 
d = h.update(c) 
print(d.hexdigest()) 

입니다하지만이 다이제스트를 반환하지 않는 오류를 나에게

AttributeError: 'NoneType' object has no attribute 'hexdigest'

+1

일반적인 규칙에 의해 생성됩니다 방법은 인플레 이스 객체를 수정하는 경우 그것은 아마 * 아무것도 * ('None')를 반환합니다. 그것이 뭔가를 반환하면 입력 인수를 수정하지 않습니다. 예를 들어,'L.sort()'와'M = sorted (L)' – jfs

답변

2

update()을 제공합니다. 다이제스트는 digest() 또는 hexdigest()

h.update(c) 
print(h.hexdigest())