Instalei a biblioteca whirlpool no Python 3.6.5 e no Python 2.7.9 para calcular hashes com ela. No entanto, ela apresentou um problema inusitado: em conjunto com outras bibliotecas, ela funciona, e quando está só, não. Inserida nesse código, em Python 2.7.9, ela funciona:
from Crypto.Hash import SHA512
from Crypto.Hash import SHA384
from Crypto.Hash import SHA256
from Crypto.Hash import SHA224
from Crypto.Hash import RIPEMD
from Crypto.Hash import MD5
from Crypto.Hash import MD4
from Crypto.Hash import MD2
import whirlpool
import hashlib
a = raw_input("Digite a string: ")
b = SHA512.new(a).hexdigest()
c = SHA384.new(a).hexdigest()
d = SHA256.new(a).hexdigest()
e = SHA224.new(a).hexdigest()
f = RIPEMD.new(a).hexdigest()
g = MD5.new(a).hexdigest()
h = MD4.new(a).hexdigest()
i = MD2.new(a).hexdigest()
j = whirlpool.new(a).hexdigest()
l = hashlib.sha1(a).hexdigest()
print "SHA512 = ", b
print "SHA384 = ", c
print "SHA256 = ", d
print "SHA224 = ", e
print "RIPEMD160 = ", f
print "MD5 = ", g
print "MD4 = ", h
print "MD2 = ", i
print "Whirlpool = ", j
print "SHA1 = ", l
Porém, quando crio o seguinte programa com ela:
import whirlpool
a = raw_input("Digite a string: ")
j = whirlpool.new(a).hexdigest()
print "Whirlpool = ", j
ela apresenta a seguinte mensagem de erro:
E:\>python whirlpool.py
Digite a string: sete
Traceback (most recent call last):
File "whirlpool.py", line 1, in <module>
import whirlpool
File "E:\whirlpool.py", line 3, in <module>
j = whirlpool.new(a).hexdigest()
AttributeError: 'module' object has no attribute 'new'
Se no programa anterior, ele não apresentou problemas com o atributo "new", por que nesse apresentou? Lembrando que nesse caso o atributo "new" é o dele próprio, não de outra biblioteca. Já desinstalei e instalei novamente a biblioteca e o problema persiste. Que acontece neste caso?