Skip to content

Instantly share code, notes, and snippets.

@drscream
Created June 24, 2025 09:31
Show Gist options
  • Save drscream/7ce7e83c4992cefe2e55317d14e68588 to your computer and use it in GitHub Desktop.
Save drscream/7ce7e83c4992cefe2e55317d14e68588 to your computer and use it in GitHub Desktop.
#!/bin/bash
IFS= read -r -d '' _ < <(:);: ${1:?Usage: $0 string}
exec {FD}<> <(:)
trap 'exit' ERR
s=0;while read -rn1 <&$FD;do : "${_:-${REPLY}}";((s+=`printf "%d" "'$REPLY"`));done < <(<<<"$1" tee /dev/fd/$FD >/dev/null)
: ${_:=`echo $RANDOM | md5sum | cut -c1-8`}
printf 'Checksum of "%s" is: %s\n' "$1" "$s"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment