 
 loop_limit = 5000
 loop_skip = 29
+
+first_different_byte = (buf1, buf2) ->
+  limit = if buf1.length < buf2.length then buf1.length else buf2.length
+  for i in [0...limit]
+    if buf1[i] != buf2[i]
+      return i
+  return -1
 
 stream_random_data = (strm, len) ->
   data = prng(len)

  for i in [1...loop_limit] by loop_skip
    test_bx_output(T, 64, i, b64stock.encode)
  cb()


  T.equal(stock, encoded_data, "bad output found: base=#{base} len=#{len}")

test_bx_streaming_correctness = (T, base, len) ->
  encoding = encoding_for_base(base)
  encoder = new stream.StreamEncoder(encoding)
  block_encoder = new stream.StreamEncoder(encoding)
