Tk Library Source Code

View Ticket
Login
Ticket UUID: 1824212
Title: add proc to generate salt
Type: RFE Version: None
Submitter: afaupell Created on: 2007-11-01 18:25:12
Subsystem: md5 Assigned To: patthoyts
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2008-01-27 06:57:07
Resolution: Closed By: patthoyts
    Closed on: 2008-01-26 23:57:07
Description:
this would be really handy to have included as part of the module, for generating passwords. here is my version:

proc salt {len {chars abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789/.}} {
    set salt {}
    set size [string length $chars]
    while {$len > 0} {
        append salt [string index $chars [expr {int(rand() * $size)}]]
        incr len -1
    }
    return $salt
}

set enc_pass [::md5crypt::aprcrypt [salt 8] $pass]
User Comments: patthoyts added on 2008-01-27 06:57:07:
Logged In: YES 
user_id=202636
Originator: NO

done.