Skip to content

Commit

Permalink
Use sh, unuse watch
Browse files Browse the repository at this point in the history
  • Loading branch information
fikr4n committed Jul 11, 2024
1 parent 603d2e9 commit 64c99bc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
15 changes: 10 additions & 5 deletions tauthenticator.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
#!/bin/sh

# This requires `watch` and `gpg`.
# This requires `gpg`.
#
# Setup:
# 1. Scan the QR code, take the secret param. For example, if the scanned URI
Expand All @@ -18,7 +18,12 @@

secret_file=${1:-default}

cd `dirname $0`/src
watch gpg -dq "../secret/$secret_file" \| \
python3 -c \''import pyotp;print(pyotp.TOTP(input()).now())'\'
cd $(dirname "$0")/src
while true; do
script='import pyotp; o = pyotp.TOTP(input()).now(); print(o[:3], o[3:])'
otp=$(gpg -dq "../secret/$secret_file" | python3 -c "$script")
[ "$otp" = "$old_otp" ] || echo "$otp"
old_otp="$otp"
sleep 5
done

13 changes: 9 additions & 4 deletions unsafe-tauthenticator.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh

# This is simpler but unsafe, consider tauthenticator.sh.
#
Expand All @@ -16,7 +16,12 @@

secret_file=${1:-default}

cd `dirname $0`/src
python3 -c 'import pyotp;print(pyotp.TOTP(input()).now())' < \
"../secret/$secret_file"
cd $(dirname "$0")/src
while true; do
script='import pyotp; o = pyotp.TOTP(input()).now(); print(o[:3], o[3:])'
otp=$(python3 -c "$script" < "../secret/$secret_file")
[ "$otp" = "$old_otp" ] || echo "$otp"
old_otp="$otp"
sleep 5
done

0 comments on commit 64c99bc

Please sign in to comment.