Skip to content

Instantly share code, notes, and snippets.

@frangio
Last active November 24, 2022 15:52
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 frangio/924b4becc8779fb3f5ce9fab39135a07 to your computer and use it in GitHub Desktop.
Save frangio/924b4becc8779fb3f5ce9fab39135a07 to your computer and use it in GitHub Desktop.
pragma solidity ^0.8.0;
function keccak256_2(bytes memory data) external pure returns (bytes32) {
bytes32 h1 = keccak256(data);
bytes32 h2;
/// @solidity memory-safe-assembly
assembly {
mstore(0, h1)
h2 := keccak256(0, 32)
}
return h2;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment