-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgethash
executable file
·50 lines (34 loc) · 1.15 KB
/
gethash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
###===============================================================##
##
## Name: gethash
## Author: mbonne
## Purpose: Lists the hash values of a file
## Created: 2022-02-20
## Last Modified:
## Version: 1
## Source Notes:
##
##
##
###===============================================================##
###==========================VARIABLES============================##
fileToCheck="$1"
###===============================================================##
getHash(){
if [ -z "$1" ]
then
echo "No argument supplied"
read -e -r -p "Enter Path To File: " fileToCheck
[ ! -e "$fileToCheck" ] && echo -e "\033[33;31m File Not Found. \n You Entered: $fileToCheck" && exit 1
fi
#for f in $fileToCheck
#do
echo -e "\n\033[33;32m SHA-1: $(shasum -a 1 "$fileToCheck" | awk '{print $1}') \n"
echo -e "\033[33;32m SHA-256: $(shasum -a 256 "$fileToCheck" | awk '{print $1}') \n"
echo -e "\033[33;32m SHA-512: $(shasum -a 512 "$fileToCheck" | awk '{print $1}') \n"
echo -e "\033[33;32m md5: $(md5 "$fileToCheck" | awk '{print $NF}') \n"
#done
}
getHash "$@"
exit $?