| 1 | #!/bin/bash |
| 2 | # Desc: Checks if string is an age-compatible public key string |
| 3 | checkAgePubkey() { |
| 4 | # Desc: Checks if string is an age-compatible pubkey |
| 5 | # Usage: checkAgePubkey [str pubkey] |
| 6 | # Version: 0.1.1 |
| 7 | # Input: arg1: string |
| 8 | # Output: return code 0: string is age-compatible pubkey |
| 9 | # return code 1: string is NOT an age-compatible pubkey |
| 10 | # Depends: age (v0.1.0-beta2; https://github.com/FiloSottile/age/releases/tag/v1.0.0-beta2 ) |
| 11 | |
| 12 | argPubkey="$1"; |
| 13 | |
| 14 | if echo "test" | age -a -r "$argPubkey" 1>/dev/null; then |
| 15 | return 0; |
| 16 | else |
| 17 | return 1; |
| 18 | fi; |
| 19 | } # Check age pubkey |
| 20 | |
| 21 | #==BEGIN sample code== |
| 22 | myKey="age18nnr0nm9fg44elkhrrcn3uhalvug04swas6su464k2kx92l05v6s4exfcz"; |
| 23 | if checkAgePubkey "$myKey"; then echo "Is an age-compatible public key:$myKey"; else echo "Is NOT an age-compatible public key:$myKey"; fi |
| 24 | myKey2="blahblahblah"; |
| 25 | if checkAgePubkey "$myKey2"; then echo "Is an age-compatible public key:$myKey2"; else echo "Is NOT an age-compatible public key:$myKey2"; fi |
| 26 | #==END sample code== |
| 27 | |
| 28 | # Author: Steven Baltakatei Sandoval |
| 29 | # License: GPLv3+ |