1. How does a barcode work?

A barcode essentially is a way to encode information in a visual pattern that a machine can read. The combination of black and white bars represents different text characters that follow a set algorithm for that barcode type. Also, if you change the succession of elements you will get a different text. A barcode scanner can read this pattern which is then turned into a line of text you can understand.