This gist contains the following Solidity code translated to Cairo:
uint256 x = 20
uint256 out = uint256(keccak256(abi.encode(x)))
It uses the keccak256
implementation from starknet-l2-storage-verifier lib. The function deals with all the peculiarities of the necessary conversion (endianness, splitting of Uint256 to four 64-bit words and back again). There's also two helper python function to illustrate how to pass arguments in and how to deal with the result.
In line 20, you divide by BOTTOM=2^64 -1, do you not want to divide by 2^64 instead?