Skip to main content

What Is Public Key Cryptography Example?

by
Last updated on 6 min read

Public key cryptography is an encryption system that uses a pair of mathematically linked keys—a public key to encrypt data and a private key to decrypt it, ensuring secure communication over untrusted networks.

What do you mean by public key cryptography?

Public key cryptography is an asymmetric encryption method that uses a pair of keys: a public key for encryption and a private key for decryption, enabling secure communication without sharing secret keys in advance.

Think of it like a mailbox. Anyone can drop a letter in (encrypt with the public key), but only the owner has the key to open it (decrypt with the private key). It’s the foundation of secure online transactions, email encryption, and digital signatures. Honestly, this is the best approach for keeping digital conversations private.

Where is public key cryptography used?

Public key cryptography is used in secure communication, digital signatures, and encryption protocols across industries like banking, healthcare, and e-commerce.

You’ll find it securing HTTPS websites via TLS/SSL, enabling end-to-end encrypted messaging (like Signal or WhatsApp), and verifying software authenticity through code signing. Governments and enterprises rely on it for identity verification and secure data transmission. Now, if you’re curious about Apple’s implementation, check whether Apple’s iMessage encryption is still active—updates sometimes tweak how it works.

What is cryptography with example?

Cryptography is the practice of securing information by converting it into an unreadable format using mathematical algorithms, with a classic example being the Caesar cipher, where letters are shifted by a fixed number.

Modern cryptography includes advanced techniques like AES (symmetric encryption) and RSA (asymmetric encryption). It protects data at rest (like encrypted files) and in transit (like VPNs). According to the NIST Cryptography Program, cryptography is generally considered essential for safeguarding digital infrastructure.

Is an example for public key algorithm?

RSA is a widely used public key algorithm, alongside ECC and ElGamal, which rely on mathematical problems (e.g., factoring large primes) for security.

RSA encrypts data and generates digital signatures, while ECC (Elliptic Curve Cryptography) offers stronger security with smaller key sizes. These algorithms are standardized by IETF RFCs and implemented in SSL/TLS protocols. Fun fact: ECC is often used in mobile devices because it’s more efficient.

What is a public key used for?

A public key encrypts data or verifies digital signatures, ensuring only the holder of the private key can decrypt or authenticate.

It enables secure key exchange (like Diffie-Hellman), encrypts emails (via S/MIME), and secures blockchain transactions. The security here relies on how infeasible it is to derive the private key from the public key—like trying to unscramble an egg.

What is difference between public key and private key?

The public key encrypts or verifies, while the private key decrypts or signs—only the private key must be kept secret.

Public keys are like phone numbers—you can share them freely. Private keys, though, are like your ATM PIN. Lose the private key, and security is compromised. Lose the public key? No big deal—it just means encryption won’t work. As of 2026, private key management remains critical for cybersecurity.

How do you create a public key?

To create a public key, generate a key pair using tools like OpenSSL or SSH, then share the public key while keeping the private key secure.

  1. Use a key generation tool (e.g., ssh-keygen or openssl genpkey).
  2. Specify the key type (RSA, ECC, etc.) and key size (e.g., 2048-bit RSA).
  3. Save the private key securely and share the public key (.pub file).

For extra protection, store the private key in an encrypted keychain or a hardware security module (HSM).

How does public key work?

Public key cryptography works by encrypting data with a recipient’s public key and decrypting it with their private key, ensuring only they can access the message.

Imagine Alice wants to send Bob a message. She encrypts it with Bob’s public key. Only Bob’s private key can decrypt it. This one-way function makes it computationally infeasible to reverse-engineer the private key—like trying to solve a puzzle with half the pieces missing.

What are the 3 main types of cryptographic algorithms?

The three main types are hash functions, symmetric-key algorithms, and asymmetric-key (public key) algorithms.

TypeUse CaseExample
Hash FunctionsData integrity, digital signaturesSHA-256
Symmetric-KeyBulk encryptionAES-256
Asymmetric-KeyKey exchange, digital signaturesRSA, ECC

Hash functions are one-way, symmetric keys use the same key for encryption/decryption, and asymmetric keys use separate public/private keys. Most modern systems mix these types for better security.

What is cryptography in simple words?

Cryptography is the art of encoding messages so only authorized parties can read them, using techniques like encryption and digital signatures.

It ensures confidentiality, integrity, and authenticity of data in digital communications. From securing passwords to enabling online banking, cryptography is foundational to modern cybersecurity. Without it, the internet as we know it wouldn’t be safe.

What are the two main types of cryptography?

Cryptography is divided into symmetric key (same key for encryption/decryption) and asymmetric key (public key cryptography).

Symmetric keys are fast but require secure key distribution—like sharing a password with a friend. Asymmetric keys solve that problem but are computationally intensive. That’s why most systems combine both, using asymmetric keys for the initial handshake and symmetric keys for the actual data transfer.

What are the public key algorithms?

Key public key algorithms include RSA, ECDSA, DSA, and Diffie-Hellman.

  • RSA: Widely used for encryption/signatures (2048+ bits).
  • ECDSA: Efficient for signatures (used in Bitcoin).
  • DSA: Digital Signature Algorithm (FIPS-standardized).
  • Diffie-Hellman: Secure key exchange protocol.

These algorithms are standardized by IETF and NIST, ensuring they meet strict security requirements.

How a public key is calculated?

A public key is derived from a private key using modular arithmetic and prime numbers, typically in RSA or ECC systems.

In RSA, the public key is a product of two large primes (n = p × q), while the private key involves Euler’s totient function. The process ensures the private key can’t be feasibly derived from the public key—like trying to guess a password with infinite attempts.

What is public key and private key with example?

A public key is shared openly for encryption, while a private key remains secret for decryption.

Key TypeAccessibilityFunction
Public KeyAnyone can accessEncrypts messages, verifies signatures
Private KeyKept secret by ownerDecrypts messages, creates signatures

For example, Alice encrypts a message with Bob’s public key. Only Bob’s private key can decrypt it. It’s like sending a locked box where only Bob has the key.

Where do I get a public key?

You can obtain a public key from a certificate authority (CA), a key server, or by generating your own key pair.

CAs issue digital certificates (e.g., Let’s Encrypt) that include public keys. Websites like MIT PGP Key Server host public keys for email encryption. Always verify a public key’s authenticity before use—like checking a signature on a legal document.

Edited and fact-checked by the TechFactsHub editorial team.
Ryan Foster

Ryan Foster is a networking and cybersecurity writer with 12 years of experience as a network engineer. He's configured more routers than he can count and firmly believes that 90% of internet problems are DNS-related. He lives in Austin, TX.