COMPSCI 210 Assignment
Assignment
项目类别:计算机

COMPSCI 210 Assignment


Part 1 (5 marks)


When the A2 program is run, apart from the name of the program, the program should take
two command line arguments:
1. The name of the file to be encrypted/decrypted using the XOR operation and
2. The password for encrypting/decrypting the file.

For example, if the name of the file to be encrypted/decrypted is "auckland.jpg" and the
password is "abcd1234", the command below is used to run the program ("$" is the command
window prompt):

$ ./A2 auckland.jpg abcd1234

The result of the encryption/decryption should be stored in a file. The name of the file is the
name of the original file with a "new-" prefix. For example, if the name of the original file is
"auckland.jpg", the name of the file containing the result of the encryption/decryption
operation should be "new-auckland.jpg". You can assume that the name of the file to be
encrypted/decrypted consists of at most 15 characters.

In this part of the program you will need to make sure that the program is passed two
command line arguments. If not, the following message should be displayed:

Usage: ./A2 filename password

This must be handled in the main() function of the program.

Part 2 (15 marks)

In this part of the program you will need to define two functions:
1. The make_new_name() function that takes two pointers to character arrays as its
parameters. The first parameter new_name, points to the character array that will be
used to store the new filename. In other words, the name of the file that will store the
result of the encryption/decryption operation. The second parameter
original_name, points to the character array that contains the characters of the
original filename. This function should populate the character array pointed to by
new_name so that it contains the characters "new-" followed by the original file name
as discussed above.
2. The length_of_password() function that takes one parameter, password,
which is a pointer to the character array that stores the password characters. This
function should return an integer value indicating the length of the password.

You can call these functions in the main() function and then print the values of both the
name of the new file and the length of the password in the format shown below. The output
of the program is highlighted in red. Please note that "auckland.jpg" is the exact name of the file.
That is, the file name does NOT have a ".txt" and any other suffix.



$ ./A2 auckland.jpg abcd1234
New filename = new-auckland.jpg
Password length = 8

Note: Markers will probably use a file with a different name and a different password.

Part 2 (30 marks)

In this part of the assignment, you will need to define the following 3 functions:
1. The is_alpha() function that takes a single parameter c of type char. The function
returns 1 if c is an alphabetical character and 0 otherwise. Both lowercase and
uppercase alphabetical characters should be considered.
2. The is_digit() function that takes a single parameter c of type char. The function
returns 1 if c is a numerical character between 0 and 9 inclusive, and 0 otherwise.
3. The is_valid_password() function that takes one parameter, password,
which is a pointer to the character array that stores the password characters. This
function will determine whether a password is valid. If a password is valid, the function
will return the value 1. If the password is invalid the function will print out one or more
messages indicating what is wrong with the password and then return the value 0. The
is_valid_password() function will need to use both the is_alpha() and
is_digit() functions to determine a password’s validity.


留学ICU™️ 留学生辅助指导品牌
在线客服 7*24 全天为您提供咨询服务
咨询电话(全球): +86 17530857517
客服QQ:2405269519
微信咨询:zz-x2580
关于我们
微信订阅号
© 2012-2021 ABC网站 站点地图:Google Sitemap | 服务条款 | 隐私政策
提示:ABC网站所开展服务及提供的文稿基于客户所提供资料,客户可用于研究目的等方面,本机构不鼓励、不提倡任何学术欺诈行为。