Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

C++ help needed! Required function: void unzip_file(const std::string& filename) You get to work on your program to obfuscate a file and write a function named

image text in transcribedimage text in transcribedC++ help needed!

Required function: void unzip_file(const std::string& filename) You get to work on your program to obfuscate a file and write a function named "unzip file." Your idea is to treat a file as blocks of 4 bytes of data and reorder these blocks so that to the world, this looks like nothing more than random data. To do this, you should open the file in binary mode and move every even positioned "block" to the end of the file, maintaining their order and leaving no space between each block. At the end, all odd positioned blocks are in increasing order, and all even positioned blocks should be in increasing order, where all even positions follow all odd positions. This output should be stored in a new file with the same name as the original file, but with the added suffix "-unzipped EXAMPLE: Suppose you have a 32-byte file named "test"' as follows (in hex); 0102030405060708091011121314151617181920212223242526272829303132 If we treat everything in the file groups of 4 bytes, we can view the file as the following 8 blocks: [ 1 2 3 4 5 6 7 8 0102030405060708091011121314151617181920212223242526272829303132 After running your function unzip file on this file "test", the blocks should be reordered as follows and the resulting data should be written to a file named "test-unzipped": [ 1 3 5 1 7 1 2 ] 4 ] 6 1 8] 0102030409101112171819202526272805060708131415162122232429303132 To accomplish this: Open the file with the given filename for input in binary mode. he entire file contents (you may want to compute the file size as well). Manipulate the data. write the output data to a file with the same name as the input file, but with the added suffix "-unzipped

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image
Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction To Constraint Databases

Authors: Peter Revesz

1st Edition

1441931554, 978-1441931559

More Books

Students explore these related Databases questions