EzCrypto crypts to string or binary?

Hi,

I’m using EzCrypto to encrypt a string, this way:

  key = EzCrypto::Key.with_password("aKey","salted hash")
  encrypted = key.encrypt("a string")

Now, it seems that when I run this on IRB I get a string:
“M\244X\215\322M\262\022\324\2269\243`\034\212T”

But, when I run this on the server I get binary characters. Why is that?
I need it to be string (like on IRB). What am I missing?

Thanks…!

On 12/13/2010 02:56 PM, Tal Shrestha wrote:

But, when I run this on the server I get binary characters. Why is that?
I need it to be string (like on IRB). What am I missing?

It appears that you’re getting binary data in irb as well. It’s just
that irb is showing the string using its inspect method. String#inspect
will produce a representation of the string that could be used as a
literal, so all of the non-printable characters without any other
representation such as \n, \t, etc. are replaced with \nnn sequences
where nnn is a number representing the binary value of the byte.

-Jeremy

Thanks, that’s helpful.