Image hexcode

Hello,

how can I display an image as hexcode? I want to have the same Hex-Code,
that I get when I open the image in a Hex-Editor…

Regards

Adriana

On Sat, Nov 3, 2012 at 10:16 PM, Adriana Mikolaskova
[email protected] wrote:

Hello,

how can I display an image as hexcode? I want to have the same Hex-Code,
that I get when I open the image in a Hex-Editor…

If you can read the file as strings, you can show each byte of the
string as hex like this:

1.9.2p290 :005 > " abc".each_byte {|x| puts x.to_s(16)}
20
61
62
63

Jesus.

thank you very much!

Adriana Mikolaskova wrote in post #1082665:

Hello,

how can I display an image as hexcode? I want to have the same Hex-Code,
that I get when I open the image in a Hex-Editor…

bin = File.read(“foo.jpg”)
hex = bin.unpack(“H*”).first
puts hex

Thank you very much too…this seems to be even easier.