+;; Prepend with C onto S so as to fill width W, if it's a number.
+(define (pre-fill C S W)
+ (if (and (number? W) (> (setf W (- W (length S))))) (string (dup C W) S) S))
+(global 'pre-fill)
+
+;; Make a hex string from a data block pad with "0" to W if non-nil
+(define (char2hex STR W)
+ (pre-fill "0" (join (map (curry format "%2x") (map char (explode STR)))) W))