summaryrefslogtreecommitdiff
path: root/quasseluser-check-password
blob: ca2d4c85cdab46e15ecac120f380236bbba5cc13 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/bash

set -e
[ $# = 1 ]
quser=$1
qpass=$(./quasselcore-sqlite "select password from quasseluser where username = '$quser' and hashversion = 1;")

hash=${qpass%:*}
salt=${qpass#*:}

if ! [ "$PASSWORD" ]
then
  read -s -p "Password to check: " PASSWORD
  echo >&2
fi

ourhash=$(printf %s%s "$PASSWORD" "$salt" | sha512sum)

[ "${ourhash%% *}" = "$hash" ]