String Manipulation Problems (decoding hex)

O

Oreo Shake

First, I'm a java guy. I have a file that contains hex (e.g.
890dfbcb...) and I'm trying to pass that to an OpenSSL::Cipher object as
the key/iv.

For the sake of the question, I'm going to cut the key down in size


In Java I'd do the following (using apache commons codec library)

Hex hex = new Hex() // why these methods aren't static, i'll never know
key = "890dfbcb";
hex.decode(key.getBytes());


(Trying to include as much as possible due to my n00b status)

The value of key.getBytes is
[56, 57, 48, 100, 102, 98, 99, 98]
The value of hex.decode(key.getBytes()) is
[-119, 13, -5, -53]

In ruby:

key.unpack("H*")[0] = 3839306466626362
key.hex = 2299395019



When I call
cipher = OpenSSL::Cipher::Cipher.new
key = cipher.random_key

key is a bunch of unicode/binary data.

I'm definitely losing something in the translation here.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,765
Messages
2,569,568
Members
45,042
Latest member
icassiem

Latest Threads

Top