Computers and Technology

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.

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 21:30, dpazmembreno
Ajeweler designing a pin has decided to use five stones chosen from diamonds, rubies, and emeralds. in how many ways can the stones be selected?
Answers: 3
image
Computers and Technology, 22.06.2019 13:30, baeethtsadia
Asoftware company hired ray, a college graduate to work in their development team. ray is assigned to work in the coding phase of a project. what happens during the coding phase of a software development project? a. the customer receives a working model of the software. b. developers convert the program design into code. c. developers gather requirements directly from the stakeholders. d. testing teams check the product for quality.
Answers: 1
image
Computers and Technology, 22.06.2019 14:40, Kathryn014
You are working with a professional edition organization. they wish to install the expense tracker which requires the use of 4 custom tabs, 3 custom objects, and one custom app. if the company is already using 4 applications, 36 custom objects, and 7 custom tabs, what will happen when they try to install expense tracker?
Answers: 1
image
Computers and Technology, 22.06.2019 15:00, taylorsamodell3217
Who is the first president to use social media as part of his campaign strategy
Answers: 1
Do you know the correct answer?
A common technique for obfuscating data is to use exclusive-or (XOR) with some key; it is inexpensiv...

Questions in other subjects: