BEST代写-线上编程学术专家

Best代写-最专业靠谱代写IT | CS | 留学生作业 | 编程代写Java | Python |C/C++ | PHP | Matlab | Assignment Project Homework代写

C语言代写 | COMPUTING SCIENCE 201 CMPUT 201 Lab 7

C语言代写 | COMPUTING SCIENCE 201 CMPUT 201 Lab 7

这是一篇来自加拿大的C语言代写作业案例分享

 

COMPUTING SCIENCE 201 CMPUT 201 – Practical programming methodology Lab Exercise 7 – Special topics in C
Weight: 2% of the final mark
Type: Electronic submit your files using eSubmit
Demo to be presented to the lab instructor before the end of your lab session Work: Individual
OBJECTIVES:
• To extend your experience with C structures
• To become familiar using low level and input/output operations in C
• To explore hash functions and timestamps in C
NOTES:
 Properly acknowledge (add a note and/or hyperlink and/or comment) any help or resource you used.
 Programs without ID boxes will have marks deducted
INSTRUCTIONS:
Create a new directory named lab7. Within this directory do the following exercises:
1) For this exercise, you will write a couple of compare functions to use with qsort on an array (of struct game).
You will use the following structure:
typedef struct {
double price;
char title[60];
} game;
In a file named lab7Eexercise1.c write the functions compGamesByTitle, compGamesByPrice,and main().
The two compare functions will allow qsort to sort a non‐dynamic array with elements of type game by ascending alphabetical order of the title field, and respectively by ascending order of the price field.
Your main function should create an array of at 7 game elements as indicated, and then print it out after each call to qsort to demonstrate that it is working.
Position
Price
Title
1
22.79
Opus Magnum
2
0.01
Minecraft
3
7.79
TIS-100
4
14.99
Trainz
5
0
Code Combat
6
7.79
Lemmings Revolution
7
64.96
Warcraft
2)
In a file named lab7Exercise2.c write the following functions:
 unsigned int rotate_right(unsigned int i, int n), which should return the result of
shifting the bits of i to the right by n places, with the bits that were “shifted” off moved to the left end of i. For example, the call rotate_right(0X12345678, 4)should return 0x81234567

 intparityTest(unsignedintx)thatreturns1ifxhasevenparity(xhasaneven numberof bits set to 1), and 0 if it has odd parity(x has an odd number of bits set to 1). For example parityTest(8) would return 0, and parityTest(15) would return 1.
 add a main function to calculate rotate_right(0X12345678, 4), rotate_right(0X12345678, 7), parityTest(15), parityTest(21).
3)
DEMO This part is to be demo-ed to your lab instructor
“A hash function is any function that can be used to map data of arbitrary size to data of a fixed size. … A cryptographic hash function allows one to easily verify that some input data maps to a given hash value, but if the input data is unknown, it is deliberately difficult to reconstruct it (or any equivalent alternatives) by knowing the stored hash value. This is used for assuring integrity of transmitted data.” [Wikipedia]
For this exercise you will extend the purpose of a cryptographic hash by including a timestamp, trying to certify the content of a file at a given time.
You will use the OpenSSl evp library (only the message digest related functions). Here you can find the man pages for the EVP Message Digest functions. This link is an example of using EVP Message Digest library.
For the demo you must write a program which takes the name of a file as a command line argument and then produces the SHA256 digest of the content of the file concatenated with the current timestamp (in seconds).
Hints:
 You may want to research the time function
 Once a message digest context is created you can use EVP_DigestUpdate() to add more data to be
hashed.
SUBMISSION:
Create a new tarball of your directory named lab7.tar.gz that contains the files: lab7Exercise1.c
lab7Exercise2.c
Marks will be deducted for any .o files or executables in your submission.
All submissions should be through eSubmit.
If files are not named as specified, you risk receiving a mark of zero.
MARKING SCHEME
Items:
Mark
Question 1
2
Question 2
2
Question 3 – Demo
2
TOTAL
6

bestdaixie

评论已关闭。