Skip to content

Instantly share code, notes, and snippets.

@pirafrank
Created September 14, 2018 09:23
Show Gist options
  • Save pirafrank/6900806b50ade20a462b24ef5d371520 to your computer and use it in GitHub Desktop.
Save pirafrank/6900806b50ade20a462b24ef5d371520 to your computer and use it in GitHub Desktop.
convert hex string to base64 string and viceversa
# convert hex string to base64 string
| xxd -r -p | base64
# convert base64 string to hex string
| base64 -d | od -t x1 -An
# Example: the whole circle in one command
# convert base64 to binary, to sha256 checksum (string in hex format), to decoded hex data (xxd -r),
# to base64 string, to base64 decoded data (base64 -d), back to hex string
awk '{print $2}' /etc/ssh/ssh_host_ecdsa_key.pub | base64 -d | sha256sum -b | awk '{print $1}' | xxd -r -p | base64 | base64 -d | od -t x1 -An
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment