tags:

views:

60

answers:

1

I am attempting to decrypt a number encrypted by another program that uses the BouncyCastle library for Java.

In Java, the sets the key like this: key = Hex.decode("5F3B603AFCE22359");

I am trying to figure out how to represent that same step in Ruby.

+3  A: 

To get Integer — just str.hex. You may get byte array in several ways:

str.scan(/../).map(&:hex)
[str].pack('H*').unpack('C*')
[str].pack('H*').bytes.to_a

See another options for pack/unpack here: http://ruby-doc.org/core/classes/String.html#M000760

And examples: http://www.codeweblog.com/ruby-string-pack-unpack-detailed-usage/

Nakilon