Skip to content

Instantly share code, notes, and snippets.

@vkobel
Last active April 19, 2017 13:32
Show Gist options
  • Save vkobel/52048e12d8930ef63930949a717ddcbf to your computer and use it in GitHub Desktop.
Save vkobel/52048e12d8930ef63930949a717ddcbf to your computer and use it in GitHub Desktop.
Convert hex public key (ECDSA, secp256k1) to pem format
#!/bin/bash
readonly ASN1_PREFIX='3056301006072a8648ce3d020106052b8104000a03420004'
if [ -z "$1" ]
then
echo "Hex key should be supplied as first argument!"
exit 1
fi
key=$ASN1_PREFIX$1
echo -n $key | xxd -r -p | openssl ec -inform der -pubin -pubout -outform pem
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment