In Solidity, I run the following code:
function hashTest() public returns(bytes32,bytes32,bytes32) {
bytes32 _solution = 0xbc756c25d68ea2f260ea5f15e1e1c734c019cbc014270dd386eacca4699f60f6;
bytes32 v = keccak256(abi.encodePacked(_solution));
bytes32 x = sha256(abi.encodePacked(_solution));
bytes32 z = ripemd160(abi.encodePacked(_solution));
Print(v,x,z);
return(v,x,z);
I want to replicate in python, but so far I can only get the first (the one supported by Web3), does anyone know how to get the others? Here's my current try:
def testHash():
_solutions = '0xbc756c25d68ea2f260ea5f15e1e1c734c019cbc014270dd386eacca4699f60f6';
v = Web3.toHex(Web3.sha3(hexstr=_solutions))
x = "0x" + hashlib.new('sha256',str.encode(_solutions)).hexdigest()
z= hashlib.new('ripemd160',str.encode(_solutions)).hexdigest()
print("v",v)
print("x",x);
print("z",z);
So like I said, the top matches, but the other two don't