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 15:30
Which of the following examples has four beats in each measure?
Answers: 2
question
Computers and Technology, 24.06.2019 12:30
Why does the pc send out a broadcast arp prior
Answers: 1
question
Computers and Technology, 24.06.2019 15:00
Universal windows platform is designed for which windows 10 version?
Answers: 1
question
Computers and Technology, 24.06.2019 16:00
Which type of cloud computing offers easily accessible software and applications on the machines
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, 20.12.2019 01:31