Crack the PIN

PHP

function crack($hash) {
  $pin = "00000";
  $passHash = md5($pin);

  while ($passHash != $hash) {
    $pin++;
    $pin = str_pad($pin, 5, "0", STR_PAD_LEFT);
    $passHash = md5($pin);
  }

  return $pin;
}

Tags

  1. php (Private)
  2. 6-kyu (Private)
  3. codewars (Private)
  4. answer (Private)