From: Erik Veenstra Date: 2007-01-30T06:19:26+09:00 Subject: Re: "a string".xor("another string") I've found a little bug in your version: long = "this is a very long string" short = "a short one" p long.xor(short) # ==> OK p short.xor(long) # ==> Array size mismatch: 11 != 26 See this fix. gegroet, Erik V. - http://www.erikveen.dds.nl/ ---------------------------------------------------------------- require "narray" class String def xor(other) if other.empty? self else s1 = self s2 = other if s1.length < s2.length n, r = s2.length.divmod(s1.length) s1 = s1 * n + s1[0, r] elsif s2.length < s1.length n, r = s1.length.divmod(s2.length) s2 = s2 * n + s2[0, r] end a1 = NArray.to_na(s1, "byte") a2 = NArray.to_na(s2, "byte") (a1 ^ a2).to_s end end end ----------------------------------------------------------------