Cryptography Questions with Answers

41 practice questions on Cryptography (Cyber Security) with answers and step-by-step solutions. Try 10 samples below, then practise all 41 free in the AptiNest app.

Sample questions

Question 1Easy

Steganography is the practice of:

  1. Hashing data repeatedly
  2. Encrypting data with two keys
  3. Hiding data inside a file
  4. Signing emails

Answer: C. Hiding data inside a file

Explanation

For example, data can be hidden in the low-order bits of image pixels.

Step-by-step solution

  1. Steganography hides a message inside another file.
  2. An example is hiding data in the low bits of image pixels.
  3. So it hides data inside a file: option C.

Why the other options are wrong

  • A. Repeated hashing is not steganography.
  • B. Two-key encryption is not hiding data in a file.
  • D. Signing emails is about authenticity, not hiding data.

Tip: Steganography = hiding, encryption = scrambling.

Question 2Easy

RSA's security relies on the difficulty of:

  1. Reversing a string
  2. Sorting large arrays
  3. Factoring large numbers
  4. Finding prime numbers below 100

Answer: C. Factoring large numbers

Explanation

Recovering the private key from n would require factoring n into its two large primes.

Step-by-step solution

  1. RSA public key includes n = p x q.
  2. Finding p and q from n is hard for large n.
  3. That hardness protects the private key.

Why the other options are wrong

  • A. Unrelated.
  • B. Unrelated.
  • D. Primes below 100 are trivial.

Question 3Easy

Which of these is an asymmetric algorithm?

  1. AES
  2. ChaCha20
  3. RSA
  4. DES

Answer: C. RSA

Explanation

RSA relies on a public/private key pair; AES, DES and ChaCha20 are symmetric ciphers.

Step-by-step solution

  1. RSA uses a public/private key pair.
  2. AES, DES and ChaCha20 all use one shared key.
  3. So RSA is the asymmetric algorithm: option C.

Why the other options are wrong

  • A. AES is a symmetric cipher.
  • B. ChaCha20 is a symmetric cipher.
  • D. DES is a symmetric cipher.

Tip: RSA is the common asymmetric example.

Question 4Easy

SHA-256 is an example of a:

  1. Hash function
  2. Digital certificate
  3. Symmetric cipher
  4. Key exchange

Answer: A. Hash function

Explanation

SHA-256 produces a 256-bit digest.

Step-by-step solution

  1. SHA-256 takes an input and produces a fixed 256-bit digest.
  2. It is one-way and is not a cipher or certificate.
  3. It is a hash function.
  4. So SHA-256 is a hash function.

Why the other options are wrong

  • B. A digital certificate binds identity to a key; SHA-256 does not.
  • C. SHA-256 does not encrypt data with a shared key.
  • D. Key exchange is done by protocols such as Diffie-Hellman.

Tip: Hash = fixed-size one-way digest. Cipher = reversible with a key.

Question 5Medium

The "avalanche effect" in hashing means:

  1. Hash computation slows down over time
  2. Hashes grow larger with every use
  3. Small changes alter it a lot
  4. Similar inputs give similar hashes

Answer: C. Small changes alter it a lot

Explanation

Changing one bit should flip about half the output bits, hiding any relation between similar inputs.

Step-by-step solution

  1. The avalanche effect means a small change in input changes the output a lot.
  2. Changing one bit flips about half of the output bits.
  3. So small changes alter the hash a lot: option C.

Why the other options are wrong

  • A. Hash speed does not change over time with the avalanche effect.
  • B. Hash output size stays fixed; it does not grow with use.
  • D. Similar inputs give very different hashes, which is the opposite.

Tip: Avalanche = a one-bit change gives a very different hash.

Question 6Medium

Why should passwords be hashed with a unique random salt?

  1. To make hashes shorter to store
  2. So equal passwords hash differently
  3. So the server can show passwords to admins
  4. So passwords can be decrypted later

Answer: B. So equal passwords hash differently

Explanation

Salts defeat precomputed rainbow tables and stop attackers spotting users who share passwords.

Step-by-step solution

  1. A salt is a random value added to the password before hashing.
  2. Each user gets a different salt.
  3. So two users with the same password get different hashes, and precomputed tables stop working.

Why the other options are wrong

  • A. Salting does not change hash length.
  • C. Hashes are one-way; admins should never see passwords.
  • D. Hashes cannot be decrypted; that is the point.

Question 7Medium

How many keys are needed for 10 people to each communicate privately with every other person using symmetric encryption (one key per pair)?

  1. 90
  2. 20
  3. 45
  4. 10

Answer: C. 45

Explanation

Pairs = n(n - 1)/2
= 10 x 9 / 2
= 45.

Step-by-step solution

  1. Each pair needs one key.
  2. Pairs = n(n-1)/2 = 10 x 9 / 2.
  3. = 45 keys.

Why the other options are wrong

  • A. That is n(n-1), counting each pair twice.
  • B. That is 2n.
  • D. That is just n.

Tip: Pairs formula n(n-1)/2.

Question 8Medium

Alice wants to send Bob a message only Bob can read using asymmetric encryption. She encrypts it with:

  1. Bob's private key
  2. Bob's public key
  3. Alice's private key
  4. Alice's public key

Answer: B. Bob's public key

Explanation

Only Bob's private key can decrypt data encrypted with his public key.

Step-by-step solution

  1. Alice wants only Bob to read the message.
  2. Data encrypted with Bob's public key can be decrypted only with Bob's private key.
  3. So Alice encrypts with Bob's public key: option B.

Why the other options are wrong

  • A. Bob's private key must stay with Bob; Alice does not have it.
  • C. Alice's private key would not let Bob read the message.
  • D. Alice's public key is public and is not the key that makes Bob able to read it.

Tip: Encrypt with the recipient's public key; sign with your own private key.

Question 9Hard

AES-GCM is popular because it provides:

  1. Faster key exchange over the internet
  2. Public-key signatures
  3. Hashing without any key
  4. Encryption plus built-in integrity

Answer: D. Encryption plus built-in integrity

Explanation

GCM is an authenticated encryption mode: it detects tampering as well as hiding content.

Step-by-step solution

  1. AES-GCM encrypts the data.
  2. It also adds an authentication tag that detects tampering.
  3. So it gives encryption plus built-in integrity: option D.

Why the other options are wrong

  • A. Key exchange is done by protocols such as Diffie-Hellman, not GCM.
  • B. Public-key signatures are not part of AES-GCM.
  • C. Hashing without a key is not what GCM provides.

Tip: GCM = authenticated encryption.

Question 10Hard

In Diffie-Hellman with p = 23 and g = 5, Alice picks a = 6 and Bob picks b = 15. What is the shared secret?

  1. 2
  2. 8
  3. 19
  4. 15

Answer: A. 2

Explanation

A = 5^6 mod 23 = 8,

B = 5^15 mod 23 = 19.

Shared = 19^6 mod 23 = 8^15 mod 23 = 2.

Step-by-step solution

  1. Alice's public value A = 5^6 mod 23 = 8.
  2. Bob's public value B = 5^15 mod 23 = 19.
  3. Alice computes B^6 mod 23 = 19^6 mod 23 = 2, and Bob computes A^15 mod 23 = 8^15 mod 23 = 2.
  4. The shared secret is 2: option A.

Why the other options are wrong

  • B. 8 is Alice's public value, not the shared secret.
  • C. 19 is Bob's public value, not the shared secret.
  • D. 15 is Bob's private exponent, not the shared secret.

Tip: Both sides get the same secret: g^(ab) mod p.

Practise all 41 questions free

The full question bank with timed practice, progress tracking and Vidya, your AI tutor. Free, no ads.

Open this topic in the app →

Related topics

See all Cyber Security topics · All topics