[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
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 like
this:
   Emailinfo1=
'ĂȘE1669>)d2LU`j=LBK;=]=2mWX3d]jei/m*HzY:`/74F8H0,0/,.*,-0+--*/*-,*+-++,-,/7(
L36dLUB/IS9(d537A:A1j:VbipIYNV=JfB3{[_>pjuPGa5SXX`ko7}sv]/M*m[KSjR[<fdO3-Uma
4>UP.^3<T, at O)J2cWrUIXuz.d4T3vgQ\lX^HrjV:-btd:AXU:g8]FWA;[m7:}?2JQwPV]7Mj-N=1
]A3v;pc';

Then I put together a string using this like this:
Password:=emailinfo1[43]+emailinfo1[21]+emailinfo1[77]+emailinfo1[121]+email
info1[8]+emailinfo1[2]+emailinfo1[83]

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
Console)

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.

Regards,

Adriaan van Os
_______________________________________________
fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal




More information about the fpc-pascal mailing list