From: bob hope Date: 2012-08-01T13:41:37+09:00 Subject: Re: working with large binary strings? Because I have no clue what I am doing :). Thanks. Do you know if there is a better way to do this? It seems to be working but I bet there is a better way. The goal is, with 4 random strings, to make a 4th random string that xors to 0 for each row with the other strings. I don't know how to concatenate with a number so that is why I make it a string here. require "securerandom" require "openssl" a = SecureRandom.random_bytes(1_000_000).unpack("B*")[0] b = SecureRandom.random_bytes(1_000_000).unpack("B*")[0] c = SecureRandom.random_bytes(1_000_000).unpack("B*")[0] d = SecureRandom.random_bytes(1_000_000).unpack("B*")[0] vsb = "" 100_000.times do |x| puts x column = a[x].to_i ^ b[x].to_i ^ c[x].to_i ^ d[x].to_i ^ 0 case column when 0 vsb << 0.to_s else vsb << 1.to_s end end puts vsb.to_i -- Posted via http://www.ruby-forum.com/.