Why can't you just draw a few black lines on a barcode and spoof the scanner?
Well, the last digit in a barcode is actually there to do some clever error checking.
Barcodes have a few more tricks up their sleeve.
They use these guard patterns to separate the digits into a right and left side.
There need to be 6 digits on either side but the left and right digits are encoded differently.
Interestingly, the encoding on the right is the inverse of the left.
Each digit on the left has an odd number of black lines whereas on the right each digit has an even number of black lines.
If any of those rules are broken, the barcode won't scan.
I should point out, this is all for UPC-A barcodes.
If you like this sort of detail, you should read the book Code by Charles Petzold which was the inspiration for the tweet (and my QR code one).
charlespetzold.com/blog/2022/06/Announcing-Code-2nd-Edition.html