





Encryption is a core computer science and security concept that appears in backend systems, networking, and application design. Interviewers ask this to test whether you understand how secure communication is established in practice.
Explain the difference between symmetric and asymmetric encryption.
Your answer should cover:
You do not need to derive cryptographic math or prove security properties. A strong answer should clearly compare the two approaches, describe their trade-offs, and give at least one practical example of how they work together in production systems.
Symmetric encryption uses the same secret key for both encryption and decryption. Both parties must already share that key securely, which makes key distribution the main challenge.
ciphertext = encrypt(message, shared_key)
plaintext = decrypt(ciphertext, shared_key)
Asymmetric encryption uses two related keys: a public key for encryption or signature verification, and a private key for decryption or signing. The public key can be shared openly, while the private key must remain secret.
ciphertext = encrypt(message, public_key)
plaintext = decrypt(ciphertext, private_key)
Symmetric algorithms are generally much faster and are better suited for encrypting large amounts of data. Asymmetric algorithms are computationally heavier, so they are usually used for key exchange, authentication, or digital signatures rather than bulk data encryption.
Most real systems combine both models. Asymmetric cryptography is used to establish trust or exchange a session key, and symmetric cryptography is then used to encrypt the actual data stream efficiently.
# Simplified hybrid flow
session_key = secure_key_exchange(public_key)
encrypted_data = symmetric_encrypt(data, session_key)
Encryption protects confidentiality, but asymmetric systems also support digital signatures for authentication and integrity. This is a major reason public-key cryptography is essential in secure internet protocols.
signature = sign(message_hash, private_key)
is_valid = verify(message_hash, signature, public_key)