Created
December 20, 2013 17:38
-
-
Save srgrn/8058462 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
# 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/bsd | |
# md5sum "$1"|cut -d' ' -f1 # linux | |
} | |
sha1() { | |
perl -MDigest::SHA=sha1_hex -Xle'print sha1_hex(<> or die)' "$1" | |
# ruby -rdigest/sha1 -e"puts Digest::SHA1.file'$1'" | |
# python -sBc "import hashlib;print hashlib.sha1(open('$1','rb').read()).hexdigest()" | |
# shasum "$1"|cut -d' ' -f1 # mac/bsd | |
# sha1sum "$1"|cut -d' ' -f1 # linux | |
} | |
sha224() { | |
perl -MDigest::SHA=sha224_hex -le'print sha224_hex(<>or die)' "$1" | |
# ruby -rdigest/sha2 -e"puts Digest::SHA224.file'$1'" | |
# python -sBc "import hashlib;print hashlib.sha224(open('$1','rb').read()).hexdigest()" | |
# shasum -a224 "$1"|cut -d' ' -f1 # mac/bsd | |
# sha224sum "$1"|cut -d' ' -f1 # linux | |
} | |
sha256() { | |
perl -MDigest::SHA=sha256_hex -le'print sha256_hex(<>or die)' "$1" | |
# ruby -rdigest/sha2 -e"puts Digest::SHA256.file'$1'" | |
# python -sBc "import hashlib;print hashlib.sha256(open('$1','rb').read()).hexdigest()" | |
# shasum -a256 "$1"|cut -d' ' -f1 # mac/bsd | |
# sha256sum "$1"|cut -d' ' -f1 # linux | |
} | |
sha384() { | |
perl -MDigest::SHA=sha384_hex -le'print sha384_hex(<>or die)' "$1" | |
# ruby -rdigest/sha2 -e"puts Digest::SHA384.file'$1'" | |
# python -sBc "import hashlib;print hashlib.sha384(open('$1','rb').read()).hexdigest()" | |
# shasum -a384 "$1"|cut -d' ' -f1 # mac/bsd | |
# sha384sum "$1"|cut -d' ' -f1 # linux | |
} | |
sha512() { | |
perl -MDigest::SHA=sha512_hex -le'print sha512_hex(<>or die)' "$1" | |
# ruby -rdigest/sha2 -e"puts Digest::SHA512.file'$1'" | |
# python -sBc "import hashlib;print hashlib.sha512(open('$1','rb').read()).hexdigest()" | |
# shasum -a512 "$1"|cut -d' ' -f1 # mac/bsd | |
# sha512sum "$1"|cut -d' ' -f1 # linux | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment