#!/usr/local/bin/tclsh8.4
#^-- this should point to your tclsh binary

## load my crypto.so module from http://tclcryptography.sourceforge.net
## make sure crypto is in the current dir, or change this path...
if {![string match *Crypto* [package names]]} {load ./crypto.so} 

## get and compare passwords for given user
proc check {file user pass} {
        foreach line [split [read [set fid [open $file r]]] \n] {
                switch -glob -- [lindex [split $line] 0] {
                        --PASS {set p [lindex [split $line] end]}
                        \#* - \:\:* - \&\&* - \$\$* - \-\-* {continue}
                        default {set u [string trim [lindex [split $line] 0]]}
                }                      
                if {[string equal -nocase $user $u] && [info exists p]} {
                        close $fid; return [string equal [bencpass $pass] $p]
                }
        }
        close $fid; return "NOT FOUND"
}

## run above proc and post output
puts [check [lindex $argv 0] [lindex $argv 1] [lindex $argv 2]]