Skip to content

Interview question · Cryptography, PKI & TLS

Explain encoding, encryption, hashing and signing, and when you would use each.

The most common screen question in security. The answer that scores sorts all four by one property: whether there is a key, and who holds it.

easyEssentialNewPreparation tags: Amazon, Google, MicrosoftUpdated Nov 2026

TL;DR: Encoding (Base64, URL encoding) changes representation and has no key, so it provides no security. Encryption hides content and is reversible with a key. Hashing is a one-way fingerprint with no key, used to detect change against a trusted reference and, with slow functions, to store passwords. Signing proves who produced data and that it is unchanged: a private key signs, a public key verifies. Pick by the property you need: confidentiality means encryption; integrity and origin mean signing (or a MAC); format means encoding.

How to approach it

Organise the answer around keys. Encoding has none, hashing has none, encryption uses a key to reverse, and signing uses a private key to create and a public key to verify. Then give one use for each, and the classic misuse for each.

A strong answer

FIG · FOUR OPERATIONS PEOPLE CONFUSE
Key or no key, reversible or not, who can check
  1. Encoding

    Base64, URL encoding

    • No key, fully reversible
    • Representation only: zero security
  2. Encryption

    AES-GCM, RSA-OAEP

    • Key required to reverse
    • Confidentiality; with AEAD also integrity
  3. Hashing

    SHA-256, Argon2id

    • No key, one-way
    • Detects change against a trusted reference
  4. Signing

    ECDSA, Ed25519

    • Private key signs, anyone verifies
    • Integrity plus origin
OperationReversible?Key?ProtectsTypical useClassic misuse
Encoding (Base64, hex, URL)Yes, by anyoneNoNothingPutting bytes into text formats such as JSON or URLsTreating a Base64 "token" or "obfuscated" secret as protected
Encryption (AES-GCM, TLS)Yes, with the keyYesConfidentiality (AEAD also integrity)Data in transit and at restKeeping the key next to the data
Hashing (SHA-256; Argon2id for passwords)NoNoIntegrity against a trusted referenceFile checksums, content addressing, password storage with slow functionsFast hashes for passwords; trusting a hash served next to the file it checks
Signing (Ed25519, ECDSA)Not applicable (verifies)Key pairIntegrity, authenticity, non-repudiationCode and model signing, certificates, signed tokensVerifying with a public key fetched from an untrusted place

Three points separate a strong answer:

  1. Encoding is not security. A JWT's payload is Base64url-encoded, not encrypted; anyone can read it. Security comes from its signature.
  2. A hash proves integrity only relative to something trusted. A hash published on the same compromised server as the file proves nothing. For keyed integrity between two parties, use a MAC such as HMAC; for verifiable origin, use a signature.
  3. Signing does not hide anything. A signed message is readable. If you need confidentiality and origin, you encrypt and sign (or use a protocol such as TLS that does both).

AI example. A model artifact pulled from a hub: the download travels over TLS (encryption in transit), the file is checked against a hash in a manifest (integrity), and the manifest is signed by the publisher (origin). Each step answers a different question.

What interviewers probe next

  • "Is a JWT encrypted?" Usually not: a signed JWT (JWS) is readable by anyone; only an encrypted JWT (JWE) hides its contents.
  • "Why not SHA-256 for passwords?" It is designed to be fast, which helps attackers test guesses; use a slow, salted, memory-hard function such as Argon2id.
  • "What does HMAC add over a hash?" A secret key, so only key holders can produce a valid tag.

What if?

What if · interview follow-ups

Hold your answer as the constraints change

A developer stores customer API tokens Base64-encoded in a database column and says they are 'encrypted'.

  1. Start here

    Why is Base64 not encryption?

How it's scored

Weak: Calls Base64 encryption or hashing "encryption that can't be reversed"; confuses signing with encrypting.

Hire: Distinguishes all four by keys and reversibility, gives one correct use each.

Strong Hire: Names the classic misuse of each, explains that hashes need a trusted reference, and combines them correctly in one realistic flow.

Common mistakes

  • Saying data is "encrypted with SHA-256".
  • Treating Base64-encoded secrets in config files as protected.
  • Assuming a signature provides confidentiality.
  • Forgetting MACs exist between hashes and signatures.
You just read a free answer. Every topic opens its first 5 answers to anyone. Sign in and the count per topic goes to 10, and we keep track of how far you get in every topic.Google sign-in · free · no payment details
HOW DID IT GO?
0
READING SIGNED OUT

Signing in doubles your free answers, from 5 to 10 per topic, and the site starts remembering you: mastery per topic, bookmarks, and a next-focus recommendation. Free, no card.

Sign in free
UP NEXT ON YOUR JOURNEY
DISCUSSION · 0

No comments yet. Share a correction or a different way to answer it.