BioTorrents.de’s version of Gazelle
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

diceware.php 727B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. declare(strict_types=1);
  3. # Load the dictionary
  4. require_once 'wordlist.php';
  5. # Get $x secure d6 integers
  6. function roll_dice($x)
  7. {
  8. $y = '';
  9. for ($i = 0; $i < $x; $i++) {
  10. $y .= random_int(1, 6);
  11. }
  12. return (int) $y;
  13. }
  14. function get_words($x, $wl)
  15. {
  16. $dice = [];
  17. $pw = '';
  18. # How many times to roll?
  19. foreach (range(1, $x) as $i) {
  20. array_push($dice, roll_dice($x));
  21. }
  22. # Concatenate wordlist entries
  23. foreach ($dice as $die) {
  24. $pw .= ucfirst($wl[$die]);
  25. #$pw .= $wl[$die] . ' ';
  26. }
  27. return trim($pw);
  28. }
  29. # Vomit a passphrase
  30. echo get_words(5, $eff_large_wordlist);
  31. echo get_words(5, $eff_large_wordlist);
  32. echo get_words(5, $eff_large_wordlist);