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:
- Extract the public key from the key pair. It is usually stored in a format such as PEM.
- Hash the key data with a cryptographic hash function such as SHA-256, which reduces it to a fixed-size string of bytes.
- 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:
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:
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.
| Factor | Details |
| Usage | Authentication of keys in protocols like SSH, SSL/TLS |
| Method | Public key hashed and encoded |
| Tools | OpenSSL, SSH-keygen |
| Hash Algorithms | SHA-1 (deprecated), SHA-256 (recommended) |
| Format | Typically hexadecimal or Base64 |
| Security | Depends on hash function; susceptible to MITM if compromised channel |
Related reading
- Can anyone suggest good illumination normalization algos for face authentication. I have tried basic algos like DoG, LBP, ..?
- Can I specify an AWS DynamoDB policy based on Cognito ID?
- Can I specify RabbitMQ credentials in node.js?
- Cannot find MessageMatcherDelegatingAuthorizationManager class while trying to configure websocket security in Spring Boot 3
- Cannot login to Docker account
- Cannot read credentials from /.aws/credentials - PHP script call AWS-SDK
- Cannot resolve method 'antMatchers' in AuthorizationManagerRequestMatcherRegistry
- CannotGetMongoDbConnectionException Failed to authenticate to database
System design interview problems on this topic
- Design a Secure Identity Management System: solution and walkthrough
- Design an API Rate Limiter: solution and walkthrough
- Design a Network Security Monitoring Tool: solution and walkthrough
- Design a CAPTCHA System: solution and walkthrough

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseSystem Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.