I have a way that converts ulongs to bytes using binary shifts in a for statement but it's not very time efficient. Is there a way to cast a ulong array of size 64 directly into a byte array of size 512? This is a section of code that runs thousands of times and I need to shave every millisecond so I can in turn save seconds.
Edit: Right now this is what I'm doing:
for (int k = 0; k < ulongs.Length; k++) {
bytes[(k << 3)] = (byte)(ulongs[k] >> 56);
bytes[(k << 3) + 1] = (byte)(ulongs[k] >> 48);
bytes[(k << 3) + 2] = (byte)(ulongs[k] >> 40);
bytes[(k << 3) + 3] = (byte)(ulongs[k] >> 32);
bytes[(k << 3) + 4] = (byte)(ulongs[k] >> 24);
bytes[(k << 3) + 5] = (byte)(ulongs[k] >> 16);
bytes[(k << 3) + 6] = (byte)(ulongs[k] >> 8);
bytes[(k << 3) + 7] = (byte)(ulongs[k]);
}