0

I'm trying to use the inbuilt ripemd160 and md4 provided by Openssl to generate hash. This is my code

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

But this give me an error

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

user3447822
  • 25
  • 1
  • 5
  • 1
    general rule: if a method modifies the object inplace then it probably returns *nothing* (`None`). If it returns something then it doesn't modify input arguments e.g., `L.sort()` vs. `M = sorted(L)` – jfs Mar 25 '14 at 19:24

1 Answers1

2

update() do not return the digest. Digest is generated by digest() or hexdigest()

h.update(c)
print(h.hexdigest())
pbacterio
  • 1,094
  • 6
  • 12