PDA

View Full Version : Accepting 'Hidden' Password Characters



Brendon
25-Sep-2005, 07:59 PM
What is the command for accepting user input as hidden (asterisk) fields.
I tried...
ACCEPT CCPASSW {PASSWORD=TRUE} and
ACCEPT CCPASSW {PASSWORD}

but neither worked. Is there such a command available?

Thanks in advance,
Brendon O'Hanlon

Free Agent
25-Sep-2005, 10:45 PM
Brendon,
If you are using a form (not a dbform) just set the password_state to
true. And it will do it for you. The setting is in the properties dialog for
a form. I use it on password dialogs.

HTH

Tod Brannen

Vincent Oorsprong
26-Sep-2005, 12:55 AM
Brandon,

Character mode DataFlex does not have (like Windows) a property or an entry
option you can set to show asterisks. However there are possibilities to do
this.

1. Procedural DataFlex (I assume you use this since you use the ACCEPT
statement).

Build a loop based on INKEY like (untested):

Gotoxy 10 10
Move 0 To iPasswordChars
Move '' To sPassword
Repeat
Inkey sKey
Move ((Key.Escape) Or (Key.Enter) Or iPasswordChars > 10) To bEndOfLoop
If (Not (bEofOfLoop) And sKey <> Character (8)) Begin
Move (sPassword + sKey) To sPassword
Increment iPasswordChars
Gotoxy 10 10
Show (Repeat ('*', Length (sPassword))
End
Until (bEndOfLoop)

2. Object Oriented DataFlex:

There is a picture class that you can use.

--
Regards,
Vincent Oorsprong
Data Access Europe B.V.
http://www.dataaccess.nl
Tel: +31-74-2555609

Tod Brannen
26-Sep-2005, 04:23 PM
Brendon,
Sorry, I am used to VDF and forgot where I was for a moment. My answer
was obviously not for character mode. (I was at home on my FreeAgent pc)

Tod Brannen

Glyn Astill
27-Sep-2005, 03:52 AM
Here is what I did when I needed to do this, its pretty much the same idea
as Vincents, but it uses an image and lets the user ammend what they're
typing via the backspace key.

move "" to public
move "" to dummy
page passwd at 12 20
next_char:
display dummy to passwd.1
gotoxy 24 0
inkey tempstr
[key.escape] abort
if (ascii(tempstr)) ne 24 if (ascii(tempstr)) ne 1 if
(ascii(tempstr)) ne 3 begin
append public tempstr
append dummy "*"
end
if (ascii(tempstr)) eq 24 begin
calc ((length(public))-1) to tempint
move (left(public, tempint)) to public
calc ((length(dummy))-1) to tempint
move (left(dummy, tempint)) to dummy
end
if (ascii(tempstr)) eq 3 abort
if (ascii(tempstr)) ne 1 goto next_char


On Mon, 26 Sep 2005 06:55:49 +0100, Vincent Oorsprong
<vincent.oorsprong@reply.at.newsgroup.nl> wrote:

> Brandon,
>
> Character mode DataFlex does not have (like Windows) a property or an
> entry
> option you can set to show asterisks. However there are possibilities to
> do
> this.
>
> 1. Procedural DataFlex (I assume you use this since you use the ACCEPT
> statement).
>
> Build a loop based on INKEY like (untested):
>
> Gotoxy 10 10
> Move 0 To iPasswordChars
> Move '' To sPassword
> Repeat
> Inkey sKey
> Move ((Key.Escape) Or (Key.Enter) Or iPasswordChars > 10) To
> bEndOfLoop
> If (Not (bEofOfLoop) And sKey <> Character (8)) Begin
> Move (sPassword + sKey) To sPassword
> Increment iPasswordChars
> Gotoxy 10 10
> Show (Repeat ('*', Length (sPassword))
> End
> Until (bEndOfLoop)
>
> 2. Object Oriented DataFlex:
>
> There is a picture class that you can use.
>



--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

chuck atkinson
28-Sep-2005, 02:52 AM
It's been a long time since I looked at how we do it. Several issues to
consider. I built a class called PASSWORD_FORM based on FORM class. This is
used within a special PASSWORD_CLIENT class.

Be aware that when using SUPPLY_KEY procedure, you have to do some special
"brute force" type intercepting of mouse clicks. Our forms have <OK> <EXIT>
buttons in the client and we needed to be able know if the user clicked on
these while entering a password.

Anyway, here's the procedures in the PASSWORD_FORM class that accepts the
user input.
Below is just a code snippet but the technique works.

Chuck Atkinson

procedure Supply_Key integer Char_Pos returns integer
local string The_Key The_Password
local integer complex row col

set Kbd_Input_Mode to TRUE

repeat
inkey The_Key

// brute force to intercept the mouse click on buttons
// within the supply key procedure

indicate key.mouse as flexkey eq 53

[key.mouse] if (mouse_click_enabled_state(current_object)) Begin

get absolute_mouse_location to complex
move (hi(complex)) to row
move (low(complex)) to col

if (row=15) Begin
if ((col>=17) and (col<29)) move KSAVE_RECORD to
TERMCHAR
if ((col>=29) and (col<46)) move KEY_ESCAPE to
TERMCHAR
if (col=>46) move KEY_F1 to
TERMCHAR
End // row 15 is the buttons

End

if Termchar NE KEY_ENTER begin
get Password to The_Password

if Termchar EQ KEY_BACK_SPACE ;
left The_Password to The_Password
(length(The_Password) - 1)
else if Termchar LE 255 begin
if (length(The_Password)) GE MAX_PASSWORD_LENGTH Begin
move 0 to Termchar
send bell to desktop
End
else begin
append The_Password The_Key
move (ascii("*")) to Termchar
end
end

set Password to The_Password
end

until Termchar NE 0


set Kbd_Input_Mode to FALSE

procedure_return Termchar
end_procedure

function Entry returns integer
local integer Retval

move (length(Password(Current_Object)) + 1) to CURSOR_SET
set Kbd_Input_Mode to FALSE

forward get Entry to Retval

set Kbd_Input_Mode to TRUE
function_return Retval
end_function


"Brendon" <brendono@sewgroup.com> wrote in message
news:P06WcWjwFHA.2212@dacmail.dataaccess.com...
> What is the command for accepting user input as hidden (asterisk) fields.
> I tried...
> ACCEPT CCPASSW {PASSWORD=TRUE} and
> ACCEPT CCPASSW {PASSWORD}
>
> but neither worked. Is there such a command available?
>
> Thanks in advance,
> Brendon O'Hanlon
>
>

Bill Clifford
29-Sep-2005, 11:40 AM
Brendon,
With OOP, this is how I do it:

Object log_on is a client log_on_img
set location to 6 29 relative
set scope_state to true
set object_color 112 120
on_key kcancel send cancel
on_key ksave_record send ok

Property String Password_Value public ''
Property Integer Access_rights public 0

Object userid_form is a form enter_user_img
item_list
on_item "" send next
end_item_list

End_object //userid_form

Object password_form is a form enter_password_img
item_list
on_item "" send next
end_item_list

Function Entry returns integer
local integer rVal
set kbd_input_mode to false
Forward get Entry to rVal //invoke ACCEPT
set kbd_input_mode to true
function_return TERMCHAR
end_function

Procedure entering
Set Password_Value to ''
Set Value item 0 to ''
End_Procedure

Procedure initialize
Set Password_Value to ''
Set Value item 0 to ''
End_Procedure

procedure supply_key integer ndx returns integer
Local String dd pval
set Kbd_Input_Mode to TRUE
inkey dd
set Kbd_Input_Mode to FALSE
if (termchar=kMouse) procedure_Return (character(0))
if (Termchar=kCancel OR Termchar=kEnter OR ;
Termchar=kExit_Application OR ;
TermChar=Knext_item OR TermChar=Kprevious_item)
Procedure_Return Termchar
Get Password_Value to pval
if (Termchar=kLeftArrow OR Termchar=kback_Space) begin
Set Password_Value to (lefT(pval,length(pval)-1))
Procedure_Return kBack_Space
End
Set Password_Value to (pval+dd)
Procedure_Return (Ascii("*"))
End_Procedure

End_object //password_form



Brendon wrote:
> What is the command for accepting user input as hidden (asterisk) fields.
> I tried...
> ACCEPT CCPASSW {PASSWORD=TRUE} and
> ACCEPT CCPASSW {PASSWORD}
>
> but neither worked. Is there such a command available?
>
> Thanks in advance,
> Brendon O'Hanlon
>
>

Brendon
29-Sep-2005, 09:13 PM
Thanks all.
I needed this for character-mode data entry on some dumb terminals so for
everyone who answered for VDF code thanks but no cigar (this time). Alot of
thanks though for all responses.

I ended up with a loop similar to Vincent's procedural example, although not
nearly as clean or efficient as Vincent's. For anyone else wanting to know
how, follow his example here - not mine. The example below is not for high
security, and I almost know all the responses (passwords) it is likely to
accept, so in my case it would work, but I wouldn't use it for uncontrolled
applications though.

FYI: Here is what I ended up with initially. After seeing some other
examples I can see the error checking is nowhere near foolproof, but after I
realised that the password_state command was available to VDF only (I
finally found the companies old dataflex language reference manual -
yeehah!) I found the DF INKEY command and built the loop from that.
After reading everyones examples I can see some much better modifications on
keystroke checking which I should put in.
Here's my lazy first attempt though. This one just counts the keystrokes and
moves that number of asterisks to the 'entry' field, which is CCPASSW. The
first move below activates this entry visually for the user. I only have the
return key as a check though....pretty bad. PASSL is the real password
variable which holds the string, and PASSW holds the keystroke.

MOVE "" TO CCPASSW
MOVE "" TO PASSL
MOVE "" TO PASSH
MOVE 0 TO IMAX
INDICATE KEY.RETURN FALSE

WHILE [NOT KEY.RETURN]
MOVE "" TO PASSW
KEYCHECK
INKEY PASSW
IF (TRIM(PASSW) GT " ") BEGIN
MOVE (APPEND(TRIM(PASSL),TRIM(PASSW))) TO PASSL
MOVE (LENGTH(TRIM(PASSL))) TO IMAX
MOVE (APPEND(PASSH,"*")) TO PASSH
MOVE PASSH TO CCPASSW
END
LOOP


Thanks to everyone again for their responses. Much appreciated.
Brendon O'Hanlon (password protected!)

"Brendon" <brendono@sewgroup.com> wrote in message
news:P06WcWjwFHA.2212@dacmail.dataaccess.com...
> What is the command for accepting user input as hidden (asterisk) fields.
> I tried...
> ACCEPT CCPASSW {PASSWORD=TRUE} and
> ACCEPT CCPASSW {PASSWORD}
>
> but neither worked. Is there such a command available?
>
> Thanks in advance,
> Brendon O'Hanlon
>