Getting the same hashes on the web3 and Solidity side

How can I repeat this operation on web3.js and get the same hash
function test(uint a, uint b) pure public returns (bytes32) {
bytes32 hash = keccak256(abi.encodePacked(uint40(a), b);
return hash;
a - last block number
b - is a large number like this: 58984214690415138970779328130626583025560028195120217299604246549340745742299

Hey @Bdd-Od, hope you are well.

Could you please share the code you are trying to in web3 and which is the contract?

Carlos Z

it is the answer to your question…