subject

A common technique for obfuscating data is to use exclusive-or (XOR) with some key; it is inexpensive and symmetric. A problem occurs when this is used on file formats like portable executable where there are many null bytes, since XORing nulls with the key ends up writing the key out. A slightly more complex algorithm uses a Linear Feedback Shift Register (LFSR) to produce a key stream, which will be XORed with the data. A generic LFSR is:
If F is the value which represents the LFSR feedback and S is the current state of the LFSR, the next state of the LFSR is computed as follows:
if the lowest bit of Sis 0: S=S>>1
if the lowest bit of Sis 1: S=(S>>1)^F
For this challenge, you'll be using an LFSR with the feedback value 0x87654321. The LFSR is initialized with a value and stepped to produce the key stream. The next key value is read from the LFSR after eight steps, with the actual key being the lowest byte of the current LFSR value.
For example, if the initial value of the LFSR is 0x, then next value after stepping it eight times will be 0x9243F425, meaning that the first key byte is 0x25. If the first byte of the input is 0x41, the first byte of output will be 0x64.
Your task is to implement this algorithm (both LFSR and the XOR). We're only interested in algorithm implementation; other code will be discarded.
The function should adhere to one of following signatures:
C/C++
unsigned char *Crypt(unsigned char *data, int dataLength, unsigned int initialValue)
C#
static byte[] Crypt(byte[] data, uint initialValue)
Python
Crypt(data, initialValue) # returns byte string
Java
static byte[] Crypt(byte[] data, long initialValue)
Example Tests: data "apple"
dataLength 5
initialValue 0x12345678
result "\xCD\x01\xEF\xD7\x30"
data "\xCD\x01\xEF\xD7\x30"
dataLength 5
initialValue 0x12345678
result "apple"
Submit: Source code containing your implementation of the LFSR based encoding routine.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 10:50
Using least squares fitting, you are to fit the data sets to the following models and solve for the parameters ai , where i is the index of the parameter. the input/output data for the systems are linked in the bblearn site. for each of the systems use matlab to plot the supplied data vs. the model fit on one plot. include your code in the solutions. (a) linear fit "lineardata.mat" y=a1x^3 + a2x^2 + a3x + a4 (b) plant fit "plantdata.mat g(s) = a1/(s + a2)
Answers: 1
question
Computers and Technology, 22.06.2019 14:00
What are procedures that keep a data base current
Answers: 1
question
Computers and Technology, 22.06.2019 18:30
Which of these options are the correct sequence of actions for content to be copied and pasted? select content, click the copy button, click the paste button, and move the insertion point to where the content needs to be inserted. click the copy button, select the content, move the insertion point to where the content needs to be inserted, and click the paste button. select the content, click the copy button, move the insertion point to where the content needs to be inserted, and click the paste button. select the content, move the insertion point to where the content needs to be inserted, click the copy button, and click the paste button.
Answers: 3
question
Computers and Technology, 23.06.2019 04:31
Q14 what is most important for you to choose before you build a network? a. private network b. nos c. network media d. network protocol e. directory service
Answers: 1
You know the right answer?
A common technique for obfuscating data is to use exclusive-or (XOR) with some key; it is inexpensiv...
Questions
question
Mathematics, 31.12.2020 21:50
question
Mathematics, 31.12.2020 22:00
question
Mathematics, 31.12.2020 22:00
question
Computers and Technology, 31.12.2020 22:00
question
Mathematics, 31.12.2020 22:00
Questions on the website: 13722360