feat(user/bkots):Use subshells to speed up jobs
[BK-2020-03.git] / unitproc / bkt-checkAgePubkey
CommitLineData
fe0c8dd2
SBS
1#!/bin/bash
2# Desc: Checks if string is an age-compatible public key string
3checkAgePubkey() {
4 # Desc: Checks if string is an age-compatible pubkey
5 # Usage: checkAgePubkey [str pubkey]
e5ae7ef4 6 # Version: 0.1.2
fe0c8dd2
SBS
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
e5ae7ef4 10 # age stderr (ex: there is stderr if invalid string provided)
fe0c8dd2
SBS
11 # Depends: age (v0.1.0-beta2; https://github.com/FiloSottile/age/releases/tag/v1.0.0-beta2 )
12
13 argPubkey="$1";
14
15 if echo "test" | age -a -r "$argPubkey" 1>/dev/null; then
16 return 0;
17 else
18 return 1;
19 fi;
20} # Check age pubkey
46e8086f
SBS
21
22#==BEGIN sample code==
23myKey="age18nnr0nm9fg44elkhrrcn3uhalvug04swas6su464k2kx92l05v6s4exfcz";
24if checkAgePubkey "$myKey"; then echo "Is an age-compatible public key:$myKey"; else echo "Is NOT an age-compatible public key:$myKey"; fi
25myKey2="blahblahblah";
26if checkAgePubkey "$myKey2"; then echo "Is an age-compatible public key:$myKey2"; else echo "Is NOT an age-compatible public key:$myKey2"; fi
27#==END sample code==
28
29# Author: Steven Baltakatei Sandoval
30# License: GPLv3+