Converting from hex to bytes (must be an even number of hex digits):

> '0xaa14'.sub('0x', '').scan(/.{2}/).map{ |x| x.hex.chr }.join
"\252\024" 

Converting from bytes to hex:

> "\252\024".unpack('H*').join
"aa14" 

I suspect that there’s an easier way to convert from hex to bytes that I have missed.

Sorry, comments are closed for this article.