[fpc-pascal] SysSetCtrlBreakHandler

2016-11-27 Thread Dmitry Boyarintsev
On Sun, Nov 27, 2016 at 12:07 PM, Michael Van Canneyt < mich...@freepascal.org> wrote: > > If you mean in a cross-platform way, I think we would welcome patches :) > > On the subject of cross-platform console applications... While working recently on converting libwebsockets header to FPC, I ran i

Re: [fpc-pascal] Readln a password

2016-11-27 Thread geneb
On Sun, 27 Nov 2016, Adriaan van Os wrote: I wonder what the recommended way is to readln a password from console, as a standard Readln echoes the password. Readln is wholly unsuited to the task. You're better off writing a routine that gets input one character at a time. g. -- Proud owne

Re: [fpc-pascal] Readln a password

2016-11-27 Thread Jonas Maebe
On 27/11/16 18:54, James Richters wrote: Shouldn't an extremely basic function like readkey be cross-platform? It is, but the crt unit only works with (almost) fully functional terminal windows, and not with redirected or piped input/output (as used by Xcode). Jonas __

Re: [fpc-pascal] Readln a password

2016-11-27 Thread James Richters
Shouldn't an extremely basic function like readkey be cross-platform? -Original Message- From: fpc-pascal-boun...@lists.freepascal.org [mailto:fpc-pascal-boun...@lists.freepascal.org] On Behalf Of Michael Van Canneyt Sent: Sunday, November 27, 2016 12:07 PM To: FPC-Pascal users discussions

Re: [fpc-pascal] Readln a password

2016-11-27 Thread Michael Van Canneyt
On Sun, 27 Nov 2016, Adriaan van Os wrote: Dmitry Boyarintsev wrote: I'd think you want something simlar on unix. Take a look at man 4 termios specifically at local flag named "ECHO". you want to disable it via tcsetattr() Â (TermIO unit) Thanks for the hint. I haven't yet tried it, but I

Re: [fpc-pascal] Readln a password

2016-11-27 Thread Adriaan van Os
Dmitry Boyarintsev wrote: I'd think you want something simlar on unix. Take a look at man 4 termios specifically at local flag named "ECHO". you want to disable it via tcsetattr() Â (TermIO unit) Thanks for the hint. I haven't yet tried it, but I would expect it to fail,as stty (see stty.c in

Re: [fpc-pascal] Readln a password

2016-11-27 Thread Adriaan van Os
Tomas Hajny wrote: Does the same limitation / issue apply for Keyboard.GetKeyEvent/PollKeyEvent on Mac OS X? To a lesser extent. It doesn't write "funny characters" to the Xcode Console window as "uses CRT" does, but still echoes typed characters. Like with "uses CRT", the problem doesn't occu

Re: [fpc-pascal] Readln a password

2016-11-27 Thread Adriaan van Os
Dmitry Boyarintsev wrote: I'd think you want something simlar on unix. Take a look at man 4 termios specifically at local flag named "ECHO". you want to disable it via tcsetattr() Â (TermIO unit) Thanks for the hint. I haven't yet tried it, but I would expect it to fail, as stty (see stty.c in

Re: [fpc-pascal] Readln a password

2016-11-27 Thread Tomas Hajny
On Sun, November 27, 2016 15:49, Adriaan van Os wrote: > James Richters wrote: >> Here is how I read passwords... it generates a random character and >> displays >> that so someone looking over your shoulder things those characters are >> the >> password >> It uses readkey which does not display on

Re: [fpc-pascal] Readln a password

2016-11-27 Thread Dmitry Boyarintsev
On Sun, Nov 27, 2016 at 8:24 AM, Adriaan van Os wrote: > I wonder what the recommended way is to readln a password from console, as > a standard Readln echoes the password. > > 1. SetConsoleMode seems to be Windows-specific > I'd think you want something simlar on unix. Take a look at man 4 term

Re: [fpc-pascal] Readln a password

2016-11-27 Thread Adriaan van Os
James Richters wrote: Here is how I read passwords... it generates a random character and displays that so someone looking over your shoulder things those characters are the password It uses readkey which does not display on the screen, one character at a time Thanks for your reply, but please

Re: [fpc-pascal] Readln a password

2016-11-27 Thread James Richters
I would like to mention that if you store your password in a constant like this: const password='mypassword' then if someone edits your exe file with any text editor, your password will be in there as text and easy to find. I have used this method to get around this... I store a huge string

Re: [fpc-pascal] Readln a password

2016-11-27 Thread James Richters
Here is how I read passwords... it generates a random character and displays that so someone looking over your shoulder things those characters are the password It uses readkey which does not display on the screen, one character at a time Function Readpw:String; Var Pwstring : String; pwchar

[fpc-pascal] Readln a password

2016-11-27 Thread Adriaan van Os
I wonder what the recommended way is to readln a password from console, as a standard Readln echoes the password. 1. SetConsoleMode seems to be Windows-specific 2. On Mac OS X, a loop with a Crt.ReadKey until char(13) works in Terminal.app, but behaves strange in the Xcode Console window (more

[fpc-pascal] Repeat result in random

2016-11-27 Thread Tony
Here is a short program to print 10 random numbers: program testrandom; var i: Integer; begin Randomize; for i := 1 to 10 do WriteLn(Random); end. If I compile and run this program using FPC 3.0.0 on Ubuntu 16.04 x86_64 I get the following: $ /usr/lib/fpc/3.0.0/ppcx64 testrandom