MD5 is a message-digest algorithm.
Anyone with some tips for the novice as to common uses for md5 and sha1?
DL: Here are some common uses for md5:
md5 is older and more commonly used than sha1 but sha1 is considered more secure. However, for most purposes, md5 is good enough.
PT - SHA and MD5 are both enhanced digests based upon the MD4 algorithm. Although MD4 has not been broken - attacks have been demonstrated against the first two rounds and separately against the final round. The publication of these cryptanalytic attacks lead to a strengthened algorithm - MD5. See the sha1 page for details of how that has been strengthened. For MD5, the enhancements involve adding another round, adding a unique constant into each step, changing the round 2 function G to be less symmetrical. Each step now also includes the result of the previous step to speed up the avalanche effect. See [BOOK: Applied Cryptography pp 436].
RS 2006-10-20: Here's a little command line utility that returns the MD5 digest for one file, and, if specified, compares it with a second one:
#!/usr/bin/env tclsh set usage { usage: md5.tcl filename ?filename2? prints the MD5 digest of the given file in hexadecimal to stdout. If filename2 is given, and its md5 digest differs from the first, this is reported on stdout, and return code is 1. (If equal, 0). } if {[llength $argv] < 1} {puts stderr $usage; exit} package require md5 set md1 [md5::md5 -hex -file [lindex $argv 0]] puts $md1 if {[lindex $argv 1] ne {}} { set md2 [md5::md5 -hex -file [lindex $argv 1]] if {$md1 ne $md2} {puts "*** unequal: $md2"; exit 1} }
DcK 2010-10-14: Here how to get an hexadecimal MD5 command on several platforms:
#Gets MD5 hash proc md5 {string} { #tcllib way: package require md5 string tolower [::md5::md5 -hex $string] #BSD way: #exec -- md5 -q -s $string #Linux way: #exec -- echo -n $string | md5sum | sed "s/\ *-/\ \ /" #Solaris way: #lindex [exec -- echo -n $string | md5sum] 0 #OpenSSL way: #exec -- echo -n $string | openssl md5 }
MJ - See [L1 ] for a version of md5 implemented using tcc4tcl.