Introduction
Introduction Statistics Contact Development Disclaimer Help
Refactor dialog procedure to return characters - pee - Pee a password manager;P…
git clone git://vernunftzentrum.de/pee.git
Log
Files
Refs
LICENSE
---
commit 28fc60ad1370b8c5b360c05176233c033186f875
parent a09303351df8a4cf928cb0bac8167b631264d025
Author: Christian Kellermann <[email protected]>
Date: Fri, 8 Jan 2016 09:18:51 +0100
Refactor dialog procedure to return characters
Also refactor out the yes-no dialogs.
Diffstat:
pee.scm | 31 +++++++++++++++++--------------
1 file changed, 17 insertions(+), 14 deletions(-)
---
diff --git a/pee.scm b/pee.scm
@@ -60,9 +60,12 @@
(cond ((member answer options) =>
(lambda (c)
(printf "\r")
- (car c)))
+ (car (string->list (car c)))))
(else (printf "\r") (loop))))))))
+(define (ask-yes-or-no msg)
+ (eqv? #\y (ask-for-choice msg "y" "n")))
+
(define (new-password)
(define (ask-for-manual-password)
(with-stty
@@ -72,8 +75,7 @@
(read-line)
(print "\r"))))
(let manual-loop ()
- (if (equal? "y"
- (ask-for-choice "Invent your own password?" "y" "n"))
+ (if (ask-yes-or-no "Invent your own password?")
(let ((p1 (ask-for-manual-password))
(p2 (ask-for-manual-password)))
(unless (equal? p1 p2) (print "Passwords do not match.") (manual-loo…
@@ -84,14 +86,16 @@
(else 32))))
(printf "Length ~a chars, entropy ~a bits~%" (string-length p) (qu…
(print p)
- (let ((choice (ask-for-choice "Use this password?" "y" "n" "+" "-"…
- (cond ((member choice '(" " "n")) (password-loop e))
- ((equal? choice "+") (password-loop (+ e entropy-delta)))
- ((equal? choice "-") (password-loop (max 32 (- e entropy-d…
- ((equal? choice "?")
- (printf "y - accept password~%+ - increase password lengt…
- (password-loop e))
- (else p))))))))
+ (let dialog-loop ()
+ (let ((choice (ask-for-choice "Use this password?" "y" "n" "+" "…
+ (case choice
+ ((#\space #\n) (password-loop e))
+ ((#\+) (password-loop (+ e entropy-delta)))
+ ((#\-) (password-loop (max 32 (- e entropy-delta))))
+ ((#\?)
+ (printf "y - accept password~%+ - increase password length~…
+ (dialog-loop))
+ (else p)))))))))
(define (get-hashed-passphrase)
(with-stty
@@ -255,8 +259,7 @@
(lambda (e)
(let ((user (prompt-for "User" (first e)))
(comment (prompt-for "Comment" (third e)))
- (password (if (equal? "y"
- (ask-for-choice "Change password?" "y" …
+ (password (if (ask-yes-or-no "Change password?")
(new-password)
(second e))))
(encrypt-file db-name
@@ -270,7 +273,7 @@
(cond ((alist-ref account db equal?) =>
(lambda (e)
(print-without-password (cons account e))
- (if (equal? "y" (ask-for-choice "Really delete account?" "y" "n"))
+ (if (ask-yes-or-no "Really delete account?")
(encrypt-file db-name (alist-delete account db equal?) p)
(print "Entry '" (car e) "' deleted."))))
(else (print "Error: Entry for '" account "' not found")
You are viewing proxied material from vernunftzentrum.de. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.