Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] How to read a password without displaying it?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Remi Vanicat <remi.vanicat@l...>
Subject: Re: [Caml-list] How to read a password without displaying it?
David MENTRE <dmentre@linux-france.org> writes:

> Thank you Basile and Maxence for your replies,
>
> In fact, I wanted to do that in caml only, to be portable on Windows
> and I'm relunctant to bind to C code. However, from what you said,
> it seems impossible.

Well, I would try to use the Terminal interface of the Unix library :

open Unix

let read_pass () =
  let attr = tcgetattr stdin in
  tcsetattr stdin TCSAFLUSH { attr with c_echo = false };
  let line = read_line () in
  tcsetattr stdin TCSAFLUSH attr;
  line

It work. Of course you could do something to print * when the user
type something, but this is a first solution. By the way i don't know
if this work on windows.

-- 
Rémi Vanicat

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners