Last active
May 7, 2023 10:46
-
-
Save ilyar/484360bdb5464a6f252bd8f8ec10aaff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
slugSha256() { | |
slug=$(echo -n "$1" | sha256sum | cut -d' ' -f1) | |
echo -n $((16#"${slug:0:8}")) | |
} | |
functionHash() { | |
hash=$(slugSha256 "$(echo -n "$1" | sed 's/ //g')") | |
if [[ "$1" == *constructor* ]] || [[ "$1" == *cell* ]] || [[ "$1" == *bytes* ]]; then | |
hash=$((hash ^ (2 ** 31))) | |
fi | |
if [[ "$1" == *cell* ]]; then hash=$((hash ^ (2 ** 31))); fi | |
if [[ "$1" == *bytes* ]]; then hash=$((hash ^ (2 ** 31))); fi | |
printf '0x%x' "$hash" | |
} | |
functionID() { functionHash "$1v2"; } | |
functionID "$1" | |
echo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Also see