C语言代写

MTRX1702 - C Programming
Assignment 2
This assignment requires you to design and build a program that hides the contents of
a data le inside a bitmap le. The original data le may subsequently be recovered
from the modi ed bitmap le.
This assignment should take an average student 12 hours to complete.
Submission Deadline: 23:59 pm on the Sunday, 27th of October.
Late submissions will be penalised.
The proportion of the overall marks allocated to each component of the assignment
is indicated after the title enclosed in square brackets.
1 Background
Steganography (which means \concealed writing") is the art of writing hidden mes-
sages, disguised as a clearly visible but innocuous cover message.1 Historically, hidden
messages have taken many forms including the use of invisible ink, or marking selected
letters with pin-pricks, or using cut-out grilles to cover most of a message except the
relevant letters. In ancient times, Histiaeus shaved the head of a trusted slave, tattooed
a message on it, and hid it by waiting for the slave's hair to regrow. In the period fol-
lowing the rst World War, covert messages were photographically reduced to the size
of a full-stop and printed as microdots in ordinary letters and sent via regular post.
The purpose of steganography is to send a message without attracting the attention
of unwary third parties. This is di erent to encryption, where others may be aware
of and possibly intercept encoded messages, but are unable to interpret them. Even
with unbreakable encryption, an encoded message is likely to arouse suspicion, which
is problematic for a covert or under-cover operative. Steganography on the other hand
permits subterfuge in plain sight of the enemy, allowing the obscured message to pass
by unnoticed.
The current digital age facilitates a form of steganography wherein the low-order
bits of an image or audio le are replaced with the message bits. These bits typically
have insigni cant in
uence on the appearance or sound of the original le, and so they
can be modi ed without noticeable e ect. This assignment is concerned with image-
based steganography. You are to hide the contents of a data le in the low-order bits
of a bitmap image le, and later retrieve the original data from a modi ed image.
2 Windows Bitmap Files
Your program is to operate on uncompressed Windows Bitmap les with 24-bit colour
encoding. This is one of the simplest available le-formats and is composed of a \header
block" followed by colour data for each image pixel.
[header info] [pixel 1] ... [pixel N]
1For more information on Steganography, see http://en.wikipedia.org/wiki/Steganography.
1
The contents of the header is not relevant to this project. All you need to know is how
many bytes are in the header so as to skip over them to get to the pixel data. Each
pixel is represented by three bytes; one each for the red, green and blue components of
its colour. Thus, the intensity for a component (eg., red) of a single pixel is given by
an 8-bit value (ie., 0 to 255 unsigned char). It is therefore clear that the low-order
pixel information is simply the least-signi cant bits of each byte.2
Your program shall copy the header block of the bitmap to the output le directly
and without change. The hidden message is to be stored in the low order bits of the
pixel data. You will be provided with code that analyses the bitmap le and tells you
the number of bytes in the header and the number of bytes of pixel data, so that the
separate treatment of header and pixel data is trivial.
3 Basic Speci cation [60%]
Interface. The program is to have a command-line interface. This means using the
alternative form of main() that takes command-line arguments (see Section 13.4 of the
course text).
int main(int argc, char **argv)
The interface for encoding a data le inside a bitmap le takes three lenames as
arguments.3
steg <bmpfile> <datafile> <outputfile>
In this case, <bmpfile> is a Windows bitmap le, <datafile> is the data le, and
<outputfile> is the modi ed bitmap that contains the hidden message. The interface
for decoding a modi ed bitmap and recovering the data le takes only two arguments.
steg <bmpfile> <outputfile>
Here <bmpfile> is a modi ed bitmap and <outputfile> is the recovered data le.
Encoding algorithm. To store the data le inside the bitmap le, the following
steps are carried out.
The BitmapO set eld of the le header is read to identify the start of the pixel
data.
The header block is written to output verbatim.
The rst 32 bytes of pixel data are reserved to store the size of the input data
le. The size is to be stored in the least-signi cant bit of these 32 bytes.
2Compare this to the 8-bit Windows Bitmap le-format, where each pixel is represented by a single
byte, and colour is determined by a colour-map lookup table. In this case the low-order information is
not necessarily the least-signi cant bits of the byte.
3Here the executable is named steg. You may give your executable a di erent name, if you wish.
It does not matter since you will only submit your source code les.
2
Compute the amount of space required to store the input data. From this, com-
pute the number of bits in each pixel byte that will have to be modi ed so as
to store the data. For example, a small data le of N bytes might t into the
least-signi cant bit of the rst 8N pixel bytes. A larger le might need to modify
the two lowest bits of some bytes. In the worst case, the data le will modify all
8 bits of some or all of the pixel bytes, (in which case the data will not be well
hidden).
Store the bits of the data le in the low-order positions of the pixel bytes.
The last step requires the use of bitwise operations. You will read in a byte from the
data le and spread its bits across several pixel bytes.
Decoding algorithm. To extract the data le from the modi ed bitmap involves
the following steps.
Skip over the bitmap header block.
Get the number of bytes of the data le from the rst 32 bytes of the pixel data.
Compute the number of bits from each pixel that store the hidden data.
Extract the relevant bits and reconstruct the data le.
Messages. The program shall provide feedback to the user by printing messages to
the screen. There are three non-error messages.
Usage message. If the program is run with no additional arguments, or the wrong
number of arguments, it is to print the following message and terminate.
Usage: (encode or decode, respectively)
steg <bmpfile> <datafile> <outputfile>
steg <bmpfile> <outputfile>
Overwrite output le. If the output le already exists, query whether to overwrite,
terminating the program if the user doesn't type 'y'.
Output file <filename> already exists. Overwrite (y/n)?
Maximum number of bits modi ed. The ratio of the data le size to the number
of pixel bytes will determine the maximum number of low-order bits per byte that
are overwritten. The program shall print this number.
There was a maximum of <N> bits modified per byte.
3
Errors. If the program encounters an error, it is to print an error message to the
screen and terminate. In particular, the program shall include the following error
messages.
Unable to open a le.
Error: Could not open file <filename>.
Encoding error, where the bitmap is not big enough to store the entire data- le.
Error: Bitmap too small to store data file.
Decoding error, where the 32-bit value that denotes the size of the hidden data
is larger than the available space in the bitmap.
Error: Expected data size is larger than available space in bitmap.
3.1 Compiling
Your submission will be compiled using the following command in the Visual Studio
2010 Command Prompt:
cl *.c
If your program does not compile when this command is run, it cannot
be assessed for compliance with the speci cation and you will receive 0%
for this component of the assignment.
4 Extensions [20%]
If the basic speci cation as described above is implemented, the maximum possible
mark for the assignment shall be 80%. In order to gain a mark of greater than 80%,
one or more extensions must be implemented. These extensions should extend the
functionality of the above program in a useful and appropriate way, given the speci ed
goals of the program. Some suggested extensions are:
Include an interactive user interface in addition to the command-line interface.
Calculate a checksum and include that checksum within the hidden message to
validate the successful decoding of a message.
Calculate an indication of the overall level of le corruption caused by the stegano-
graphic process.
Implement compression by identifying whether the input le uses only ASCII
characters. (This would require additional 'header' information beyond the size
of the output le to be included in the hidden data.)
Parse the header to verify that the le is actually a supported bitmap.
4
Implement Doxygen-style commenting to enhance the quality of the project doc-
umentation.
Create a make le so that the program can be compiled by gcc using the single
command make.
Other possible extensions will also be considered. The suitability of any other
extensions should be discussed by e-mail with the Lecturer (j.ward@acfr.usyd.edu.au).
5 Documentation [20%]
The documentation for this assignment shall comprise two components. In-source doc-
umentation, and a separate short report.
Appropriate commenting and descriptive variable names should be used in all source
code to maximise readability. This will be marked based on the ability of the reader
to understand the operation of the code without reference to the accompanying re-
port. This in-code documentation should NOT discuss design decisions, but simply
the implementation of the program. Each function must have a comment header block
describing the inputs, outputs and a one-sentence description of the operation of the
function.
The short report shall contain a discussion of each module within the program, the
functionality of the module, and the data-
ows between each of the modules. Do not
discuss each individual function within the program. Simply discuss the functionality
of each module as a whole, their dependencies, and list the component functions. If a
multi- le approach to the project has been implemented, ensure the le boundaries are
indicated within the modular discussion. Use diagrams where appropriate. This report
is expected to ll 2-3 pages.
The report shall also include a \Statement of Compliance", which describes how
well the implemented programme complies with the speci cation in the assignment
sheet. It must identify all points of non-compliance, and may provide a justi cation
for this non-compliance. The Statement of Compliance must also clearly and brie
y
describe the additional functionality provided by any extensions.
5

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值