Thanks for sharing! Very interesting.
In your code:
Table[Do[AppendTo[tabs,RandomSample[rows[[RandomInteger[{1,l}]]]]],{size}],{quan}];
You might be able to speed this up considerably by not repeatedly appending things to tabs, but rather using Sow and Reap like so (i did not test it, but should work):
tabs = Reap[Table[Do[Sow[RandomSample[rows[[RandomInteger[{1, l}]]]]],{size}],{quan}]][[2,1]];
Since you don't use 'Table' to store things, it might be faster to use a Do loop as well. And you can combine the two do loops for additional speed:
Do[......,{quan},{size}] (* the opposite order*)
and now since Mathematica 10 (I believe) you can even simplify that further:
Do[......,quan,size]
Also:
Mod[{gam,gam+1,gam+2,gam+3,gam+4,gam+5,gam+6,gam+7,gam+8},256]
If i understand correctly if gam just a number. In that case you can make it faster and neater doing this:
Mod[gam+Range[0,8],256]
Once again, thanks for sharing!