RSA
Encryption
Cybersecurity
Cryptography
Key Fingerprint

How to calculate an RSA key fingerprint (OpenSSL SHA-256)

Codemia Knowledge Hub ·

An RSA key fingerprint is a short sequence of bytes that identifies a larger public key. You compute it by hashing the public key with a cryptographic hash function such as SHA-256 and encoding the digest as hexadecimal or Base64. Fingerprints let you confirm that the public key you use to connect or verify a signature has not been tampered with or replaced by a malicious key.

How the fingerprint is calculated

RSA (Rivest, Shamir, Adleman) is one of the first public-key cryptosystems and is widely used for secure data transmission. Calculating a fingerprint of an RSA key takes three steps:

  1. Extract the public key from the key pair. It is usually stored in a format such as PEM.
  2. Hash the key data with a cryptographic hash function such as SHA-256, which reduces it to a fixed-size string of bytes.
  3. Encode the digest in a human-readable format, typically hexadecimal or Base64.

OpenSSL commands

For a public key in public_key.pem, this prints a Base64 SHA-256 fingerprint:

bash
openssl rsa -pubin -in public_key.pem -outform DER | openssl sha256 -binary | openssl base64

The pipeline:

  • reads the public key
  • converts it to DER, because the hash needs binary input
  • computes the SHA-256 hash
  • encodes the hash in Base64

For a hexadecimal fingerprint instead:

bash
openssl rsa -pubin -in public_key.pem -outform DER | openssl sha256

Where fingerprints are used

  • SSH uses key fingerprints to verify the identity of the host you connect to, which prevents man-in-the-middle attacks.
  • SSL/TLS uses fingerprints to validate certificates.
  • Software signing: developers sign software and distributions with RSA keys, and the fingerprint helps verify integrity and origin.

Benefits and security considerations

A fingerprint summarizes a key's identity in a manageable form, but it is only as strong as the hash function behind it.

Benefits:

  • Compact: a short, unique representation.
  • Quick comparisons: easier and faster to compare than full public keys.
  • Widely supported: most modern cryptographic tools can generate them.

Precautions:

  • Use a strong hash: pick a collision-resistant hash like SHA-256.
  • Share fingerprints securely: transfer them over a secure channel to prevent interception.
FactorDetails
UsageAuthentication of keys in protocols like SSH, SSL/TLS
MethodPublic key hashed and encoded
ToolsOpenSSL, SSH-keygen
Hash AlgorithmsSHA-1 (deprecated), SHA-256 (recommended)
FormatTypically hexadecimal or Base64
SecurityDepends on hash function; susceptible to MITM if compromised channel

Course
Beginner
27 lessons
10 hours
System Design Fundamentals

Build a strong foundation in designing scalable, reliable distributed systems.

View the course
System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design