![](https://secure.gravatar.com/avatar/6b04428f92775f5a9915d12eaa7ddaca.jpg?s=120&d=mm&r=g)
Raymond Wiker wrote:
On 12 Feb 2023, at 11:47, Alessio Stalla <alessiostalla@gmail.com> wrote:
Greetings everyone,
is there a well-known way to do the thing in the subject, i.e. ask the user for a password in a console application, reading from the keyboard without echoing anything to the terminal? Using a library is fine, SBCL only is fine, limited to some OS is not so fine but better than nothing. Any idea?
Just tested this for Allegro CL: (eval-when (compile eval load) (require :osi)) (defun echo-off () (let ((tm (excl.osi:tcgetattr *terminal-io*))) (setf (excl.osi:termios-lflag tm) (logandc2 (excl.osi:termios-lflag tm) excl.osi:*echo*)) (excl.osi:tcsetattr *terminal-io* tm))) (defun echo-on () (let ((tm (excl.osi:tcgetattr *terminal-io*))) (setf (excl.osi:termios-lflag tm) (logior (excl.osi:termios-lflag tm) excl.osi:*echo*)) (excl.osi:tcsetattr *terminal-io* tm))) (defun prompt-for-value (prompt) (format t "~&~a " prompt) (force-output) (read-line)) (defun prompt-for-value/no-echo (prompt) (format t "~&~a " prompt) (force-output) (echo-off) (unwind-protect (read-line) (echo-on))) (defun get-passphrase-from-user () (prompt-for-value/no-echo "Passphrase?"))