X-Git-Url: https://zdv2.bktei.com/gitweb/BK-2020-03.git/blobdiff_plain/849106f7246e47bc077d7f3b8228cec717a8e63d..26f0533782d8c57fb95b8df4f55057edcbf17703:/unitproc/bkt-checkAgePubkey?ds=inline diff --git a/unitproc/bkt-checkAgePubkey b/unitproc/bkt-checkAgePubkey new file mode 100644 index 0000000..12f2044 --- /dev/null +++ b/unitproc/bkt-checkAgePubkey @@ -0,0 +1,30 @@ +#!/bin/bash +# Desc: Checks if string is an age-compatible public key string +checkAgePubkey() { + # Desc: Checks if string is an age-compatible pubkey + # Usage: checkAgePubkey [str pubkey] + # Version: 0.1.2 + # Input: arg1: string + # Output: return code 0: string is age-compatible pubkey + # return code 1: string is NOT an age-compatible pubkey + # age stderr (ex: there is stderr if invalid string provided) + # Depends: age (v0.1.0-beta2; https://github.com/FiloSottile/age/releases/tag/v1.0.0-beta2 ) + + argPubkey="$1"; + + if echo "test" | age -a -r "$argPubkey" 1>/dev/null; then + return 0; + else + return 1; + fi; +} # Check age pubkey + +#==BEGIN sample code== +myKey="age18nnr0nm9fg44elkhrrcn3uhalvug04swas6su464k2kx92l05v6s4exfcz"; +if checkAgePubkey "$myKey"; then echo "Is an age-compatible public key:$myKey"; else echo "Is NOT an age-compatible public key:$myKey"; fi +myKey2="blahblahblah"; +if checkAgePubkey "$myKey2"; then echo "Is an age-compatible public key:$myKey2"; else echo "Is NOT an age-compatible public key:$myKey2"; fi +#==END sample code== + +# Author: Steven Baltakatei Sandoval +# License: GPLv3+