XOR for String or pack/unpack for Bignum

Hello, I’m doing some en-/de-cryptions based on DES on String data.
For this, I everytime need 64-Bit blocks XOR’ed together.
But there is no XOR-operation on String data.
Before I start building a C-Extension for String here, I just want to
ask if there is any slightly effective possibility to do this better
than:
0.upto(7){|i| a[i] = (a[i].to_i ^ s[i+ofs].to_i).chr}

I’ve already considered converting int array of longs or into bignum,
but I’m looking for a more elegant solution.

Btw. Bignum is not to be seen in the list of directives for pack/unpack,
wouldn’t it be nice to have such an conversion?

Michael B.

Michael,

I just want to ask if there is any slightly effective
possibility to do this better than:
0.upto(7){|i| a[i] = (a[i].to_i ^ s[i+ofs].to_i).chr}

One trivial improvement: String#[](aFixnum) returns a Fixnum, not a

one-character String (String#= behaves similarly). So:

0.upto(7) {|i| a[i] ^= s[i+ofs] }

I realize this isn't what you were looking for, but every little bit

helps.

- Warren Brown