Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
#script from http://readlist.com/lists/ruby-lang.org/ruby-talk/11/55390.html 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 hash = 'de9f2c7fd25e1b3afad3e85a0bd17d9b100db4b3' a = hash[-19..-1];b = hash[0..19] p a.xor(b) => "\\PXVP\a\x06Q\x00\vWT\x01RW\x03R\x03W\v"
This paste will be private.
From the Design Piracy series on my blog: