From the course: Symmetric Cryptography Essential Training

Binary representation

From the course: Symmetric Cryptography Essential Training

Start my 1-month free trial

Binary representation

- [Instructor] This section talks about how data is represented in binary numbers, and that's zeros and ones. So, for the most part, cryptographic algorithms operate on raw data and they don't care about the format of that underlying data. And it's important to understand that when we're using computers, we're not operating on the actual letters or numbers. Some of the historical cryptosystems that we will look at do actually operate on individual letters and numbers. Modern cryptosystems do not. A single binary digit is called a bit, and eight bits together is a byte. I'll use these terms throughout the discussions of different cryptosystems. First, we're gonna do something extremely familiar to you, and that's counting in decimals. In the decimal number system we're used to, which is base 10, let's use the number 493 with that subscript 10 as an example. That subscript 10 indicates that we're working in base 10, and if you see a different number there in the future, that means that we're working in a different base. The number three in that number is in the ones place. The number nine is in the tens place. The number four is in the hundreds place. This is all very elementary school-level stuff, but you'll see why this is important in a moment. And then the final values the following sum. We have three times one, three is in the ones place, nine times 10, nine is in the tens place, four times 100, four is in the 100s place, and that gives us 493 base 10. Not anything surprising there. Counting in binary, it's the same pattern, different base. So, in the binary number system, again this is base two, let's use the number 1101 with subscript two there, meaning this is base two, as an example. So, the last digit is in the ones place, just like in base 10. The zero is in the twos place, the one is in the fours place, and the first digit one is in the eights place. So as we go from right to left, they're in higher and higher places. So, the final value in base 10, if we're thinking about it in the number system we're most used to; we have one times one for the one that's in the ones place, we have zero times two for the zero in the twos place, we have one times four for the one in the fours place, and we have one times eight for the one in the eights place. If we add all these together, one plus four plus eight, that give us 13 in base 10. So 1101 base two is 13 in base 10. From another perspective, we can show this as a table with each digit having its own place, and we multiply the place times the digit down to the bottom value. So, in this case, we have one byte, that's eight bits, with the value 01000110 base two, and we can see that that equals 70 in base 10, 64 plus 4 plus 2. 'Cause we have one in the 64s place, one in fours place, and one in the twos place, and then when we add all those together, we get 70. So, what are the sorts of things that we can represent in binary? So far what we've seen are just whole number values. Integers, round numbers, but we will spend more time on representing other numbers very soon.

Contents