Suggest a random user name - pee - Pee a password manager;Pee - because you hav… | |
git clone git://vernunftzentrum.de/pee.git | |
Log | |
Files | |
Refs | |
LICENSE | |
--- | |
commit 93c8cb0088f2794cff7a1d73c92cc1f4ca0ed45d | |
parent b48573d110bbdf2af883e96c98464ba74b9b3eb5 | |
Author: Christian Kellermann <[email protected]> | |
Date: Tue, 19 Apr 2016 16:00:20 +0200 | |
Suggest a random user name | |
These are american names taken from http://deron.meranda.us/data/ | |
The names can be exchanged by editing the names.scm file and adding your | |
own. The format is: | |
(define names | |
'((sizes 2 2) ; length of the 2 lists | |
(first "john" "james") | |
(last "miller" "jones"))) | |
The username will be suggested capitalized with an underscore in between. | |
Diffstat: | |
names.scm | 1 + | |
pee.scm | 22 ++++++++++++++++++++-- | |
2 files changed, 21 insertions(+), 2 deletions(-) | |
--- | |
diff --git a/names.scm b/names.scm | |
@@ -0,0 +1 @@ | |
+(define names '((sizes 5163 2500) (first "JAMES" "JOHN" "ROBERT" "MICHAEL" "MA… | |
diff --git a/pee.scm b/pee.scm | |
@@ -16,12 +16,14 @@ | |
(module pee (main) | |
(import chicken scheme) | |
-(use (srfi 1 4 14) matchable posix tweetnacl utils crypto-helper getopt-long s… | |
+(use (srfi 1 4 13 14) matchable posix tweetnacl utils crypto-helper getopt-lon… | |
(include "program-meta.scm") | |
(define-constant password-chars "abcdefhijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRST… | |
+(include "names.scm") | |
+ | |
(define password-modes | |
'(("all chars" . "") | |
("alpha-numeric" . "!@#$%^&*()-=~?/\|+,:.<>{}[]") | |
@@ -85,6 +87,22 @@ | |
(define (ask-yes-or-no msg) | |
(eqv? #\y (ask-for-choice msg "y" "n"))) | |
+(define (random-username) | |
+ (let* ((first-random (random-bytes 2)) | |
+ (last-random (random-bytes 2)) | |
+ (->number (lambda (u8v) | |
+ (bitwise-ior (u8vector-ref u8v 1) | |
+ (arithmetic-shift (u8vector-ref u8v 1) 8)))) | |
+ (first-index (->number first-random)) | |
+ (last-index (->number last-random)) | |
+ (number-first-names (car (alist-ref 'sizes names))) | |
+ (number-last-names (cadr (alist-ref 'sizes names))) | |
+ (first-name (list-ref (alist-ref 'first names) | |
+ (modulo first-index number-first-names))) | |
+ (last-name (list-ref (alist-ref 'last names) | |
+ (modulo last-index number-last-names)))) | |
+ (string-titlecase (string-append first-name "_" last-name)))) | |
+ | |
(define (new-password) | |
(define (ask-for-manual-password) | |
(with-stty | |
@@ -254,7 +272,7 @@ | |
(when (alist-ref e db equal?) | |
(print "Error: An entry for '" e "' already exists.") | |
(exit 1)) | |
- (let ((user (prompt-for "Username")) | |
+ (let ((user (prompt-for "Username" (random-username))) | |
(password (new-password)) | |
(comment (prompt-for "Comment"))) | |
(encrypt-file db-name |