Skip to content

Instantly share code, notes, and snippets.

@mhoran
Created November 13, 2016 16:15
Show Gist options
  • Save mhoran/78f72c50f0e649fdf27cceabe00a3ab3 to your computer and use it in GitHub Desktop.
Save mhoran/78f72c50f0e649fdf27cceabe00a3ab3 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
keyauth="string-from-acme-client"
_sed() {
if [[ "${OSTYPE}" = "Linux" ]]; then
sed -r "${@}"
else
sed -E "${@}"
fi
}
urlbase64() {
# urlbase64: base64 encoded string with '+' replaced with '-' and '/' replaced with '_'
openssl base64 -e | tr -d '\n\r' | _sed -e 's:=*$::g' -e 'y:+/:-_:'
}
keyauth_hook="$(printf '%s' "${keyauth}" | openssl dgst -sha256 -binary | urlbase64)"
echo $keyauth_hook
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment