Skip to content

Instantly share code, notes, and snippets.

View radman13666's full-sized avatar
🎯
Focusing

William Kibirango radman13666

🎯
Focusing
View GitHub Profile
@radman13666
radman13666 / chksums.sh
Created September 8, 2020 18:51
Checksum one-liners.
# bourne shell functions below take 1 argument, the file_to_hash.
# prints hex digest on stdout
md5() {
perl -MDigest::MD5=md5_hex -le'print md5_hex(<> or die)' "$1"
# ruby -rdigest/md5 -e"puts Digest::MD5.file'/dev/null'"
# python -sBc "import hashlib;print hashlib.md5(open('$1','rb').read()).hexdigest()"
# md5 "$1"|cut -d' ' -f4 # mac
# md5sum "$1"|cut -d' ' -f1 # linux
# openssl md5 "$1" | grep -o '[[:xdigit:]][[:xdigit:]]*$' | cat