Last active
September 14, 2023 20:03
-
-
Save soatok/bf85a7e65f98213da0712be11ce35b1b to your computer and use it in GitHub Desktop.
Bottom Responder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Usage: Run this from the command line to generate a secure passphrase in the format | |
* of stereotypical bottom keymashing. | |
* | |
* php bottom-responder.php | xclip | |
* | |
* Why? Because furries ruin everything, including bottom jokes. | |
*/ | |
function random_str(int $length, string $charset): string { | |
$c = strlen($charset) - 1; | |
if ($c < 1) { | |
throw new RangeException("Dumb"); | |
} | |
$pieces = []; | |
for ($i = 0; $i < $length; ++$i) { | |
$x = random_int(0, $c); | |
array_push($pieces, $charset[$x]); | |
} | |
return implode($pieces); | |
} | |
/* | |
8 home row characters + 8 to 12 random letters + 4 home row characters | |
Entropy estimates | |
Lower end: 26.575 + 38.864 + 13.288 -> 78 bits | |
Upper end: 26.575 + 58.296 + 13.288 -> 98 bits | |
*/ | |
$x = random_int(8, 12); | |
echo random_str(8, 'asdfghjkl;') . random_str($x, 'qwertyuiopasdfghjkl;zxcvbnm,.') . random_str(8, 'asdfghjkl;'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Demo: https://3v4l.org/crGhX