Skip to content

Instantly share code, notes, and snippets.

@soatok
Last active September 14, 2023 20:03
Show Gist options
  • Save soatok/bf85a7e65f98213da0712be11ce35b1b to your computer and use it in GitHub Desktop.
Save soatok/bf85a7e65f98213da0712be11ce35b1b to your computer and use it in GitHub Desktop.
Bottom Responder
<?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;');
@soatok
Copy link
Author

soatok commented Aug 19, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment