md5::md5 (public)

 md5::md5 [ args... ]

Defined in packages/acs-tcl/tcl/tcllib-doc-procs.tcl

Compute an MD5 digest using the already-loaded Tcllib MD5 implementation. The default result is binary in MD5 2.x; -hex requests hexadecimal output.

Returns:
MD5 digest in the requested representation.

Partial Call Graph (max 5 caller/called nodes):
mime::md5 mime::md5 (private) md5::md5 md5::md5 mime::md5->md5::md5 md5::Hex md5::Hex md5::md5->md5::Hex md5::MD5Final md5::MD5Final md5::md5->md5::MD5Final md5::MD5Init md5::MD5Init md5::md5->md5::MD5Init md5::MD5Update md5::MD5Update md5::md5->md5::MD5Update md5::Pop md5::Pop md5::md5->md5::Pop

Testcases:
No testcase defined.
Source code:
    array set opts {-hex 0 -filename {} -channel {} -chunksize 4096}
    while {[string match -* [set option [lindex $args 0]]]} {
        switch -glob -- $option {
            -hex       { set opts(-hex) 1 }
            -file*     { set opts(-filename) [Pop args 1] }
            -channel   { set opts(-channel) [Pop args 1] }
            -chunksize { set opts(-chunksize) [Pop args 1] }
            default {
                if {[llength $args] == 1} { break }
                if {[string compare $option "--"] == 0} { Pop args; break }
                set err [join [lsort [array names opts]] ", "]
                return -code error "bad option $option: must be one of $err\nlen: [llength $args]"
            }
        }
        Pop args
    }

    if {$opts(-filename) != {}} {
        set opts(-channel) [open $opts(-filename) r]
        fconfigure $opts(-channel) -translation binary
    }

    if {$opts(-channel) == {}} {

        if {[llength $args] != 1} {
            return -code error "wrong # args: should be \"md5 ?-hex? -filename file | string\""
        }
        set tok [MD5Init]

        #puts md5_______________________________________________
        #parray ::${tok}

        #puts IN=(([lindex $args 0]))
        MD5Update $tok [lindex $args 0]

        #puts md5-final_________________________________________
        #parray ::${tok}

        set r [MD5Final $tok]

    } else {

        set tok [MD5Init]
        # FRINK: nocheck
        set [subst $tok](reading) 1
        fileevent $opts(-channel) readable  [list [namespace origin Chunk]  $tok $opts(-channel) $opts(-chunksize)]
        vwait [subst $tok](reading)
        set r [MD5Final $tok]

        # If we opened the channel - we should close it too.
        if {$opts(-filename) != {}} {
            close $opts(-channel)
        }
    }
    
    if {$opts(-hex)} {
        set r [Hex $r]
    }
    return $r
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: