fork download
  1. <?php
  2. $charset = "abcdefghijklmnopqrstuvwxyz0123456789";
  3. $charset_len = strlen($charset);
  4. $current_len = 4;
  5. $password = str_repeat(' ', $current_len);
  6. $state = array_fill(0, $current_len, 0);
  7.  
  8. while (true)
  9. {
  10. $carry = true;
  11.  
  12. // Генерируем пароль и сразу же следующее состояние.
  13.  
  14. for ($i = 0; $i < $current_len; ++$i) {
  15. $password[$i] = $charset[$state[$i]];
  16.  
  17. if ($carry) {
  18. if (++$state[$i] !== $charset_len) {
  19. $carry = false;
  20. } else {
  21. $state[$i] = 0;
  22. }
  23. }
  24. }
  25.  
  26. if ($carry) {
  27. echo "No luck!\n";
  28. break;
  29. }
  30.  
  31. if (md5($password) == "e7806b130b429fc9b5890608a2c60675") {
  32. echo "YES!\n\nPassword is '$password'\n";
  33. break;
  34. }
  35. }
  36. ?>
  37.  
Success #stdin #stdout 1.15s 20520KB
stdin
Standard input is empty
stdout
YES!

Password is 'omsk'