- #!/bin/bash 
-   
- DIGITS=6 
- ALGORITHM=SHA1 
- PERIOD=30 
- SECRET= 
-   
- test -n "$1" || exit 1 
- SEARCH="$(echo "$1" | sed -e ' 
- s:%:%25:g 
- s: :%20:g 
- s:<:%3C:g 
- s:>:%3E:g 
- s:#:%23:g 
- s:{:%7B:g 
- s:}:%7D:g 
- s:|:%7C:g 
- s:\\:%5C:g 
- s:\^:%5E:g 
- s:~:%7E:g 
- s:\[:%5B:g 
- s:\]:%5D:g 
- s:`:%60:g 
- s:;:%3B:g 
- s:/:%2F:g 
- s:?:%3F:g 
- s^:^%3A^g 
- s:@:%40:g 
- s:=:%3D:g 
- s:&:%26:g 
- s:\$:%24:g 
- s:\!:%21:g 
- s:\*:%2A:g 
-   
- s:\.:\\.:g 
- ')" 
- while IFS="=" read key value; do 
- 	case "$key" in 
- 		digits) 
- 			DIGITS="$value" 
- 			;; 
- 		algorithm) 
- 			ALGORITHM="$value" 
- 			;; 
- 		period) 
- 			PERIOD="$value" 
- 			;; 
- 		secret) 
- 			SECRET="$value" 
- 			;; 
- 	esac 
- done < <(openssl aes256 -kfile <(dmenu -p 'Enter passphrase: ' -sb '#000000' -sf '#c6f24b' -nb '#000000' -nf '#000000' </dev/null) -in "$HOME/.local/share/totp/keys.txt.encrypt" -d | grep "$SEARCH" | head -1 | cut -d'?' -f2 | tr '&' '\n') 
-   
- if test -z "$SECRET"; then 
- 	notify-send "No key found for \"$1\" or decryption failed" 
- else 
- 	oathtool --base32 --totp="$ALGORITHM" -d "$DIGITS" -s "$PERIOD"s - <<FOO | tr -d '\n' | xclip -selection clipboard 
- $SECRET 
- FOO 
- fi 
-