Hashing, encoding and basic security · 15 / 15 Exercise Hard

Break a weak hash

Objective

A fast hash and a small secret are a bad combination: if there are only 10,000 possible PINs, an attacker tries them all in milliseconds. That is why passwords use slow functions with salt, and why secrets must be long and random.

Instructions

  • The input is a line with the MD5 hash (hexadecimal) of a 4-digit PIN, between 0000 and 9999.
  • Try all PINs and show the one with that hash, with leading zeros. If none matches, show Not found.
Input
85267d349a5e647ff0a9edcb5ffd1e02
Output
4821

Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.

Start exercise