Posted to tcl by miguel at Wed May 06 15:50:12 GMT 2009view raw

  1. package require md5 2
  2. set digits {0 1 2 3 4 5 6 7 8 9 A B C D E F}
  3.  
  4. # any init will do
  5. set hx [::md5::md5 -hex {}]
  6.  
  7. while {$hx ne [::md5::md5 -hex $hx]} {
  8. # bernoulli-like shift with random last hex
  9. set idx [expr {int(floor(16*rand()))}]
  10. set hx [string range $hx 1 end][lindex $digits $idx]
  11. }
  12.  
  13. puts "Found it! It is '$hx'"