Browse Source

Initial commit

Forest Belton 11 months ago
commit
87c4ebc3b5
5 changed files with 74 additions and 0 deletions
  1. 1
    0
      .gitignore
  2. 35
    0
      README.md
  3. 16
    0
      get
  4. 15
    0
      init
  5. 7
    0
      set

+ 1
- 0
.gitignore View File

@@ -0,0 +1 @@
1
+vault

+ 35
- 0
README.md View File

@@ -0,0 +1,35 @@
1
+# vault
2
+An encrypted single-user key-value store.
3
+
4
+## Setup
5
+Make sure you have [GPG](https://gnupg.org/) installed. Then, to create a new
6
+vault:
7
+
8
+```
9
+$ ./init
10
+```
11
+
12
+You will be prompted for a password to encrypt the vault.
13
+
14
+## Usage
15
+To retrieve a key from the vault:
16
+
17
+```
18
+$ ./get key
19
+```
20
+
21
+To set a key in the vault:
22
+
23
+```
24
+$ ./set key value
25
+```
26
+
27
+To see all keys in the vault:
28
+```
29
+$ ./keys
30
+```
31
+
32
+## TODO
33
+[] Implement `set`
34
+[] Implement `keys`
35
+[] Create `vault` primary command with `get`, `set`, `keys` as subcommands

+ 16
- 0
get View File

@@ -0,0 +1,16 @@
1
+#!/bin/bash
2
+set -euo pipefail
3
+
4
+function main {
5
+    KEY="$1"
6
+    VALUE=$(gpg --decrypt vault | jq ".$KEY")
7
+
8
+    if [ "$VALUE" = "null" ]; then
9
+        echo 'error: no key exists'
10
+        exit 1
11
+    else
12
+        echo "$VALUE"
13
+    fi
14
+}
15
+
16
+main "$@"

+ 15
- 0
init View File

@@ -0,0 +1,15 @@
1
+#!/bin/bash
2
+set -euo pipefail
3
+
4
+function main {
5
+    if [ -f vault ]; then
6
+        echo 'error: vault exists'
7
+        exit 1
8
+    fi
9
+
10
+    echo 'Please set a password for the vault.'
11
+    echo '{}' | gpg --armor --symmetric --pinentry-mode loopback > vault
12
+    echo "New vault created at $PWD/vault"
13
+}
14
+
15
+main "$@"

+ 7
- 0
set View File

@@ -0,0 +1,7 @@
1
+#!/bin/bash
2
+set -euo pipefail
3
+
4
+function main {
5
+}
6
+
7
+main "$@"

Loading…
Cancel
Save