summaryrefslogtreecommitdiff
path: root/generate-header
blob: 2828c7a9ad2b76ac9b024e2498e5dc1734c7ed20 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/bash

# TODO: extract uid from 'From: ' header
uid='eeerich@eckner.net'
key=$(
  gpg \
    --export \
    --export-options=export-minimal \
    --export-filter "keep-uid='uid =~ ${uid}'" \
    "${uid}" \
  | base64 -w72
)

if [ -n "${key}" ]; then
  printf 'Autocrypt: addr=%s; prefer-encrypt=mutual; keydata=\n' \
    "${uid}"
  printf '%s\n' "${key}" \
  | sed 's/^/ /'
fi