Skip to content

Instantly share code, notes, and snippets.

@Aboudjem
Created March 16, 2022 15:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Aboudjem/7ef81d0c8d44f98e785d34b77da17f4a to your computer and use it in GitHub Desktop.
Save Aboudjem/7ef81d0c8d44f98e785d34b77da17f4a to your computer and use it in GitHub Desktop.
Test Keccak256 with string and bytes32
// SPDX-License-Identifier: Unlicensed
pragma solidity ^0.8.12;
contract Test {
function getBytes32() external pure returns (bytes32, bytes32) {
bytes32 withString = keccak256(abi.encode("0x0000000000000000000000000000000000000000000000000000000000000001"));
bytes32 withBytes32 = keccak256(abi.encode(0x0000000000000000000000000000000000000000000000000000000000000001));
return (withString, withBytes32);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment