[fpc-pascal] Readln a password

James Richters james at productionautomation.net
Sun Nov 27 15:46:00 CET 2016

I would like to mention that if you store your password in a constant like

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 like
4>UP.^3<T, at O)J2cWrUIXuz.d4T3vgQ\lX^HrjV:-btd:AXU:g8]FWA;[m7:}?2JQwPV]7Mj-N=1

Then I put together a string using this like this:

Now you can't just edit the .exe file and figure out the password because
the ridiculous string blends in with all the binary stuff.

I actually to something like this but in a much more complicated way.. I
have procedures that break the characters into two nibbles then these are
randomly offset, the offset is then added to a random number then all the
information to decode this is buried in a string of 255 random characters.
I have one program to encode the crazy string and one to decode it.  It's
massively overkill as the above method is hard enough to figure out.

-----Original Message-----
From: fpc-pascal-bounces at lists.freepascal.org
[mailto:fpc-pascal-bounces at lists.freepascal.org] On Behalf Of Adriaan van Os
Sent: Sunday, November 27, 2016 8:24 AM
To: FPC-Pascal users discussions <fpc-pascal at lists.freepascal.org>
Subject: [fpc-pascal] Readln a password

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 precise,
uses Crt doesn't seem to be compatible with the Xcode

3. On Mac OS X, executing '/bin/stty -echo' gives an error message 'stty:
stdin isn't a terminal' 
(both in Terminal.appand in the Xcode Console window)

4. I experimented with '/usr/bin/read -s -p Password:' but couldn't get it
working from FPC.


Adriaan van Os
fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org

More information about the fpc-pascal mailing list