#!/usr/bin/env bash # PSK test for creating links # USAGE: ./create_link origin destination key function hash_hmac { data="$1" key="$2" shift 3 echo -n "$data" | openssl sha256 -hmac "$key" | sed 's/^.* //' } to_hash="origin=$1&dest=$2&ts=$(date +%s)" result="$to_hash&hash=$(hash_hmac $to_hash "$3")" echo $result curl -XPOST -d $result localhost:8000/api/link