Move ID*Hex functions to pkg/strutil

This is rebased on #1443