From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id NAA12011; Sat, 7 Feb 2004 13:53:24 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id NAA12693 for ; Sat, 7 Feb 2004 13:53:23 +0100 (MET) Received: from mwinf0304.wanadoo.fr (smtp3.wanadoo.fr [193.252.22.28]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id i17CrMf06390 for ; Sat, 7 Feb 2004 13:53:22 +0100 (MET) Received: from morgana (ARennes-303-1-17-244.w81-51.abo.wanadoo.fr [81.51.43.244]) by mwinf0304.wanadoo.fr (SMTP Server) with ESMTP id 5EBA4A803FA6 for ; Sat, 7 Feb 2004 13:53:22 +0100 (CET) Received: from david by morgana with local (Exim 4.30) id 1ApRxY-0000xI-PU for caml-list@inria.fr; Sat, 07 Feb 2004 13:53:20 +0100 To: caml-list@inria.fr Subject: [Caml-list] How to read a password without displaying it? From: David MENTRE Organization: none Date: Sat, 07 Feb 2004 13:53:20 +0100 Message-ID: <87u123rqyn.fsf@linux-france.org> User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Loop: caml-list@inria.fr X-Spam: no; 0.00; dmentre:01 textual:01 passwd:01 char:01 char:01 stdin:01 dmentre:01 ocaml:01 mentre:01 mentre:01 string:03 let:04 let:04 res:06 res:06 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hello, In my textual OCaml program, I would like to read a password. Currently, I'm using read_line which is not very satisfying as the password is display on screen. let passwd = read_line () in Any idea how I might read the password without displaying it? I tried the following function, using input_char, but the password is still displayed on screen: let read_password () = let password_chars = ref [] in let loop = ref true in while !loop do let c = input_char stdin in if c <> '\n' then ( password_chars := c :: !password_chars ) else ( loop := false ) done; let password = String.create (List.length !password_chars) in let _, res = List.fold_right (fun c (i, s) -> s.[i] <- c; (i+1, s)) !password_chars (0, password) in res Many thanks in advance for any help, Yours, d. -- David Mentré ------------------- 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