-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhash.sh
More file actions
62 lines (53 loc) · 1.51 KB
/
hash.sh
File metadata and controls
62 lines (53 loc) · 1.51 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
# Just a little script to verify argon2 hashes
# Script by inklingsplasher; https://keybase.io/inklingsplasher; https://github.com/InklingSplasher
# Colors for making stuff cooler
RED='\033[0;31m'
LIGHT_RED='\033[1;31m'
LIGHT_GREEN='\033[1;32m'
LIGHT_BLUE='\033[1;34m'
NC='\033[0m' # No Color
# Set ARGONDIR to the directory where the argon2 executable is located.
# Set SALTDIR to the directory where the salt for argon2 is located.
ARGONDIR="/root/Misc/argon2/argon2"
SALTDIR="./salt.txt"
SALT=$( cat $SALTDIR )
echo -e "${LIGHT_GREEN}Enter the operation: ${LIGHT_RED}hash${LIGHT_GREEN}/${LIGHT_BLUE}verify:${NC}"
read -r op
if [[ $op = hash ]]
then
echo -e "${LIGHT_GREEN}Enter the password:${NC}"
read -r "password"
echo -n "${password}" | $ARGONDIR "${SALT}" -r
echo -e "${LIGHT_GREEN}Run the script again? (y/n):${NC}"
read -r "run_again"
if [[ $run_again = "y" ]]
then
exec bash "$0" "$@"
else
exit 1
fi
elif [[ $op = verify ]]
then
echo -e "${LIGHT_GREEN}Enter the password:${NC}"
read -r "password"
echo -e "${LIGHT_GREEN}Corresponding hash:${NC}"
read -r "verifyhash"
HASH=$( echo -n "${password}" | $ARGONDIR "${SALT}" -r )
if [[ $HASH = "$verifyhash" ]]
then
echo -e "${LIGHT_GREEN}Verification ok!${NC}"
else
echo -e "${LIGHT_RED}Verification not ok!${NC}"
fi
echo -e "${LIGHT_GREEN}Run the script again? (y/n):${NC}"
read -r "run_again"
if [[ $run_again = "y" ]]
then
exec bash "$0" "$@"
else
exit 1
fi
else
echo -e "${RED}ERROR: Operation unknown.${NC}"
fi