Evaluated proc str2hex {str {sep {\x}}} {set out {}; foreach char [split $str ""] {append out "$sep[format %.2x [scan $char %c]]"}; trim $out }