Thanks.

On Mar 28, 2019, at 14:33, Matthew Ryan <matthew@o1labs.org> wrote:

Hi Helmut,

The usual way to do this (for any language) is using ANSI escape sequences. Code 8 sets the terminal to conceal characters and code 0 resets the attributes, making them visible again.

For example, in a unix shell you can test this with echo and read:

echo -e '\x1b[8m'; read varname; echo -e '\x1b[0m'

To do the same from OCaml, you can output "\x1b[8m", read the password, and then output "\x1b[0m" afterwards to switch printing back on.

I believe that this will work on Windows 10, but earlier versions may not have the necessary ANSI support.

Hope this helps,
Matthew

On Thu, 28 Mar 2019, 20:04 Helmut Brandl, <helmut.brandl@gmx.net> wrote:
Hello list,

Is there a portable way in ocaml to turn echoing off on standard input from the terminal to read e.g. passwords? By portable I mean that it works for Windows, Unix and Mac.

Thanks for any hint.

Regards
Helmut