Converting hex or dec to ascii?

Hi,
I have a variable like:

test = 0x65 0x78

and I wanna have this converted or outputet to-----> ex

which is the ascii code of 0x65 (=e) and 0x78 (=x) . But how can I do
this ?

test = 0x65 doesn’t, test = “0x65” doesn’t test = String(0x65) also
doesn’t…

can someone please help me with this?

greets

On 4/13/07, mrpink [email protected] wrote:

test = 0x65 doesn’t, test = “0x65” doesn’t test = String(0x65) also
doesn’t…

If you have this in an array, you can use Array#pack

eg.

a = [0x65, 0x78].
a.pack(“U*”)

This will work for multibyte unicode strings as well.

Hth.

अभिजीत

[written in http://www.paahijen.com/scratchpad]

[http://www.paahijen.com]

On 13.04.2007 17:47, mrpink wrote:

Hi,
I have a variable like:

test = 0x65 0x78

What exactly is this supposed to mean? This is not valid Ruby:

$ ruby -ce ‘test = 0x65 0x78’
-e:1: parse error, unexpected tINTEGER, expecting $

and I wanna have this converted or outputet to-----> ex

which is the ascii code of 0x65 (=e) and 0x78 (=x) . But how can I do
this ?

test = 0x65 doesn’t, test = “0x65” doesn’t test = String(0x65) also
doesn’t…

can someone please help me with this?

Very likely, if we know what your input is.

robert

yeah this was wrong varibale too… but I got it out:

shellcode = “\x65\x61”

puts(shellcode)

does what I needed :smiley: