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.