Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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: 2004-02-07 (14:59)
From: Remi Vanicat <remi.vanicat@l...>
Subject: Re: [Caml-list] How to read a password without displaying it?
David MENTRE <> 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;

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 Archives:
Bug reports: FAQ:
Beginner's list: