Which among the following statement(s) is(are) true? (A) A hash function takes…

2020

Which among the following statement(s) is(are) true?

(A)  A hash function takes a message of arbitrary length and generates a fixed length code

(B)  A hash function takes a message of fixed length and generates a code of variable length

(C)  A hash function may give same hash value for distinct messages

Choose the correct answer from the options given below:

  1. A.

    (A) Only

  2. B.

    (B) and (C) Only

  3. C.

    (A) and (C) Only

  4. D.

    (B) Only

Attempted by 525 students.

Show answer & explanation

Correct answer: C

Correct answer: (A) and (C)

  • Statement A: A hash function takes a message of arbitrary length and generates a fixed length code — True. Hash functions (for example, SHA-256) accept inputs of varying lengths and produce a fixed-size output (a 256-bit digest in the SHA-256 case).

  • Statement B: A hash function takes a message of fixed length and generates a code of variable length — False. This reverses the usual properties: inputs can be arbitrary length and outputs are fixed length, not the other way around.

  • Statement C: A hash function may give the same hash value for distinct messages — True. Because the output space is finite while the set of possible inputs is typically much larger, collisions (different inputs producing the same hash) are possible, even though good cryptographic hash functions make them hard to find.

Therefore the correct combination of true statements is the first and the third statements.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Coding For Placement