I have a certificate mycert.pem
. I got the public key of the certificate by command:
openssl x509 -pubkey -noout -in mycert.pem > pubkey.pem
How can I get the SHA256 hash of the public key?
How do you create a public key hash ? Just take your public key and put it through the SHA256 and RIPEMD160 hash functions: It's sometimes referred to as a HASH160(publickey) , because that's simpler than writing RIPEMD160(SHA256(publickey)) . That's it.
Open a terminal and use the ssh-keygen command with the -C flag to create a new SSH key pair. Replace the following: KEY_FILENAME : the name for your SSH key file. For example, a filename of my-ssh-key generates a private key file named my-ssh-key and a public key file named my-ssh-key.
SHA256 is a one way hash function it is not directly related to public or private key. There is no such thing as a SHA256 key pair. 2. Yes, this is a problem and storing data encryption keys in the same database as the ciphertext doesn't provide any security.
You can use ssh-keygen. Convert file format first
ssh-keygen -i -m PKCS8 -f pubkey.pem > NEWpubkey.pem
Next get the fingerprint
ssh-keygen -lf NEWpubkey.pem
Get type inference
2048 SHA256:hYAU9plz1WZ+H+eZCushetKpeT5RXEnR8e5xsbFWRiU no comment (RSA)
The openssl -pubkey
outputs the key in PEM format (even if you use -outform DER
).
Assuming you have a RSA public key, you have to convert the key in DER format (binary) and then get its hash value:
openssl rsa -in pubkey.pem -pubin -outform der | openssl dgst -sha256
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With