Skip to content

Instantly share code, notes, and snippets.

@sustr4
Created May 3, 2023 15:15
Show Gist options
  • Save sustr4/c1bf44ba47c34c02ebb89830df7d6cb3 to your computer and use it in GitHub Desktop.
Save sustr4/c1bf44ba47c34c02ebb89830df7d6cb3 to your computer and use it in GitHub Desktop.
Translation of Resto function toUUID() into BASH
toUUID() {
NSTR=$'\x92\x70\x80\x59\x20\x77\x45\xa3\xa4\xf3\x1e\xb4\x28\x78\x9c\xff'
HASH=`printf "${NSTR}$1" | sha1sum`
printf "%08s-%04s-5%03s-%01x%03s-%12s\n" ${HASH:0:8} ${HASH:8:4} ${HASH:13:3} $(( ( 0x${HASH:16:1} & 3 ) | 8 )) ${HASH:17:3} ${HASH:20:12}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment