Password problem

0 views
Skip to first unread message

Henk-Jan Kooiman

unread,
Apr 24, 1999, 3:00:00 AM4/24/99
to
Perhaps I missed something, but when I read the documentation of TK
the next example should work:

entry .pw -width 20 -show *
pack .pw

Well, it works fine. I see *'s, but when I copy the *'s
and paste it into an editor I get: "This was my password :-)".
According to the documentation I should see: "************************"

What's wrong:
a. the documentation
or
b. tcl/tk 8.05 (mac and win)

If a., does anyone know how to secure a password on the screen?

Thanks,

Henk-Jan Kooiman
h...@cable.a2000.nl

Csaba Nemethi

unread,
Apr 25, 1999, 3:00:00 AM4/25/99
to
Henk-Jan Kooiman wrote:

The -show option works as expected in an X11 environment, but not on
Windows (and Mac?). This bug was reported some weeks ago to Scriptics
(I saw the posting in this newsgroup), but I have no idea when it gets
fixed.

There is, however, a workaround based on the widget callback package
Wcb, which you can download from the URL http://www.nemethi.de. Install
the package as described in the file README.txt and proceed as follows:

package require Wcb

#
# Visible entry with before-insert and before-delete callbacks
#
entry .pw -width 20
pack .pw
wcb::callback .pw before insert {wcb::checkEntryLen 20} insertCb
wcb::callback .pw before delete deleteCb

#
# Invisible entry holding the password
#
entry .shadow -textvar passwd

#
# Before-insert callback insertCb
#
proc insertCb {w idx str} {
#
# In the visible entry, replace the string with * characters
#
set len [string length $str]
for {set i 0} {$i < $len} {incr i} {
append stars *
}
wcb::replace 1 1 $stars

#
# Insert the original string into the invisible entry
#
.shadow insert [$w index $idx] $str
}

#
# Before-delete callback deleteCb
# The parameter args stands for "first ?last?"
#
proc deleteCb {w args} {
#
# Delete the given text area from the invisible entry
#
foreach idx $args {
lappend indices [$w index $idx]
}
eval .shadow delete $indices
}

The above code works on every platform. The wcb::checkEntryLen callback
is optional but useful: it prevents the user from inserting more than 20
characters. The entry .pw will contain pure * characters; the password
will be inserted into the invisible entry .shadow and also held in the
variable passwd.

--
Csaba Nemethi http://www.nemethi.de mailto:csaba....@t-online.de

Andreas Kupries

unread,
Apr 25, 1999, 3:00:00 AM4/25/99
to

h...@cable.a2000.nl (Henk-Jan Kooiman) writes:

>Perhaps I missed something, but when I read the documentation of TK
>the next example should work:
>
>entry .pw -width 20 -show *
>pack .pw
>
>Well, it works fine. I see *'s, but when I copy the *'s
>and paste it into an editor I get: "This was my password :-)".
>According to the documentation I should see: "************************"
>
>What's wrong:
>a. the documentation
> or
>b. tcl/tk 8.05 (mac and win)
>
>If a., does anyone know how to secure a password on the screen?

(b.)

This was already reported, for 8.1b2, on Windows, see below (*).
I recommend to send this in, as another bug report, via

http://www.scriptics.com/support/bugForm.html

(*) Sorry, had no dejanews reference at hand, so I included the whole
thing.

-------- Included posting ----------------

Message-ID: <37039c85$0$2...@nntp1.ba.best.com>

Tk 8.1b2 Bug: Generated by Scriptics' bug entry form at
http://www.scriptics.com/support/bugForm.html
Responses to this post are encouraged.
------

Submitted by: Christian Krone
OperatingSystem: Linux (SuSE 5.3+ on Intel)
OperatingSystemVersion: SuSE6.0
Synopsis: Windows: entry with -show option copies visible text

ReproducibleScript:
# This script should display in *both* entries five stars.
# Instead it displays in the second entry the magic word...

pack [entry .e -show *]
pack [entry .e2]
tkwait visibility .e

.e insert 0 magic
.e selection range 0 end
event generate .e <<Copy>>
event generate .e2 <<Paste>>

ObservedBehavior:
On Windows (exactly on systems, where the <<Cut>>, <<Copy>> and
<<Paste>>
events are active) the user can make hidden (by means of the -show
option)
text visible. She has simple copy (or cut) it into the clipboard and
then
paste it into any application (another Tk entry or maybe the Notepad.

-------- Included posting ----------------

--
Sincerely,
Andreas Kupries <a.ku...@westend.com>
<http://www.westend.com/~kupries/>
-------------------------------------------------------------------------------

Reply all
Reply to author
Forward
0 new messages