suve

awful: function: md2-file

Available since rev.36 (v.0.5.0).

Declaration

ascii :md2-file ( string $FILENAME , bool $RAW )
ascii :md2-file ( string $FILENAME )

Summary

Returns the MD2 checksum of given file.
If RAW is provided and true, result will be raw binary data; otherwise, a hex-encoded representation is returned.

Note that, if the file is not found (or cannot be read), the returned value will match the hash of an empty string.

Example

# :md2-file example.
!if :gt i2 :param-cnt
    :writeln s'Usage: md2chk file sum'
    :exit
!fi

:hex-case s'lower'
!if :eq (:param-str i1|:md2-file :param-str i1)
    :writeln s'File matches the checksum.'
!else
    :writeln s"Oh noes, the file doesn't match the checksum!"
!fi

wikipage modified on 2014/0601/2317