From the course: Symmetric Cryptography Essential Training

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

Solution: Software-based LFSR

Solution: Software-based LFSR

(bright electronic music) - [Instructor] Let's take a look at what a software-based LFSR might look like. I declare an extra variable called newBit that I'll be using to calculate the value that goes into the leftmost bit of the LFSR. We have the meat of the program in this for loop, which runs 35 times. I start by printing the last position in the array for the value that falls out, followed by space, then I calculate the new bit, which is just the sequence of XOR as I described before. Then we shift all the bits to the right, and finally, we update the first bit with the new bit value we calculated earlier. It wasn't necessary to do this, but I'm also printing out the state of the LFSR if it were to keep generating output. Let's run it and see if you got the same output as I did. How'd you do? Hopefully yours matches. If it doesn't, go back and check your logic. Otherwise, congratulations. Let's move on.

Contents