How to encode byte[] in proto buffs

http://code.google.com/apis/protocolbuffers/docs/proto.html#scalar

bytes

If you are looking to store a single byte, however, I would suggest using the Int32. It is a 'variant' type variable that will change size depending on the data that is stored in it. So if you are storing a single byte, it will be the smallest structure. The byteS data type is actually quite large in comparison. This is because the bytes structure holds data such as index length and other properties.

On serialization, I noticed a size difference of about half when switching from a single byte stored in a byteS to an int32.

Note, however, that this does not apply to multiple bytes being stored in the byteS, which I suspect will be much smaller than storing individual Int32.