Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

password entry

Status
Not open for further replies.

misterboc

Programmer
Jan 29, 2002
1
US
Could someone tell me how I can program a password entry with tcl (not tk) ?

Here is my code:

puts -nonewline stdout "USER:"
flush stdout
gets stdin USER

puts -nonewline stdout "PASSWORD:"
flush stdout
gets stdin PASSWORD


But I would want to be able to enter the password without echo'ing the characters, and keep it secret/encrypted from the display. gets is not enough in this matter.

 
As far as killing the echo, I've looked at the matter for win32 and you will either need to roll your own wrapper
or research more thorughly than I did. I could not find
anything on it.
*nix can exec stty -echo
Depending on the complexity you want you can use
a simple transposition cipher

proc do_hash {targ} {
set m 0
if {[string length $targ] > 8} {
puts "Truncating password to eight characters."
set targ [string range $targ 0 8]
} else {
set targ $targ
}

set len [string length $targ]
for {set m 1} {$m <= [string length $targ]} {incr m} {
set char [string index $targ $m]
switch -exact $char a {
set targ [string replace $targ $m $m [format &quot;%x&quot; [expr 1 + $m]]]


} e {
set targ [string replace $targ $m $m [format &quot;%x&quot; [expr 2 + $m]]]


} i {
set targ [string replace $targ $m $m [format &quot;%x&quot; [expr 3 + $m]]]


} o {
set targ [string replace $targ $m $m [format &quot;%x&quot; [expr 4 + $m]]]


} u {
set targ [string replace $targ $m $m [format &quot;%x&quot; [expr 5 + $m]]]

} h {
set targ [string replace $targ $m $m [format &quot;%x&quot; [expr 6 + $m]]]
}
}
return $targ
}
and do_hash $PASSWORD, or use something like the
tls addon, or your own cipher to add encryption to your
application.

HTH.
M
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top