Категории заданий

Implement function in C

Петр Исполнитель: Петр 
Оценка: +1
Отзыв: 
Стоимость: 300
Категория: Другое
Время выполнения: 40 мин
Поиск кандидата: 0 сек


Подробное описание:

One of the most simple possible ways to "encrypt" data is to apply "XOR cipher", i.e., modify the bits in the data using XOR bitwise operation. In this exercise you will operate on 32-bit data units, that you will modify using XOR operation based on a 32-bit key. The encrypted data is encrypted <= data XOR key. Therefore decrypting content is done by similar function, data <= encrypted XOR key. The same key is used in both operations. Exercise 5.2.a implements the encrypt function that takes two file names: srcfile is the file from which data to be encrypted is read. dstfile is the encrypted file that will be written. key is used for the XOR operation. Note that for correct result, you'll need to operate on 32-bit units, as also the key has 32 bits. On the other hand, it is possible that file length is not divisible by four bytes. Therefore the last data unit may be less than 32 bits (four bytes). XOR algorithm should be applied to it nevertheless. The encrypted file length should always be equal to the original data length. The function should return the number of bytes processed. For Exercise 5.2.b you will implement the decrypt function, with same parameters as the encrypt function. If you call 'decrypt' for a file created by 'encrypt' function, you should get exactly the original file. Functions: int encrypt(const char *dstfile, const char *srcfile, uint32_t key) int decrypt(const char *dstfile, const char *srcfile, uint32_t key)

Рассказать друзьям

Подпишитесь на полезные статьи

Примеры заданий и практические советы по аутсорсингу задач

   



На дайджест уже подписалось 555214 читателей!

Присоединяйтесь к нам в соцсетях!