Write the following code in PYTHON IDLE 3.5 nothing else, be very descriptive an
ID: 3814850 • Letter: W
Question
Write the following code in PYTHON IDLE 3.5 nothing else, be very descriptive and label all parts. Thank you,
Eile Edit Yew Hbtory Bookmarks bols Help SakaieURI:CSC 110 Spri.. X Search https sakai. uriedu/p Most visited Getting started In class this week we developed 8-bit and 16-bit checksum algorithms, each of which had problems when considering them to be used for a digital signature in an investigation, For this homework assignment, you will write a Sample Code python function to implementa checksum algorithm known as Alder-32. The folowing is the description of this algorithm from Wikipedia: Forums An Adler-32 checksum is obtained by calculating two 16-bit checksums A and B and concatenating their bits into a 32-bit integer. A is the sum of all bytes in the stream plus one, and Bis the sum of the individual values of A from each step CSC Links At the beginning of an Adler-32 run, Ais initialized to 1 B to 0, The sums are done modulo 65521 (the largest prime number smaller than 2 6), Schedule The function may be expressed as: Gradebook E A 1 D1 D2 Dn (mod 6552 University Course Policies BE (1 D1) (1 D1 D2) (1 D1 D2 Dn) mod 6552 Adler-320D) B x 65536 -A Site Info Help You can read more about this algorithm and see anexample of how it is computed here: A few notes about the pseudocode above: 1. D1, D2, etc. are the decimal values of the characters in the input string. So, just as we did in the checksum algorithm we did in class, you will have to get the ASCII value of each character and convert it to decimal 2. Bis computed by accumulating the values of A Write a function to compute the Alder-32 checksum for a given string. You can modify the 8-bit checksum algorithm that we developed in class to implement this Alder-32 algorithm. You can find the checksuma.py algorithm on the Sample Code page after class on Tuesday. Your output will look something like this Python 3.5.2 Shel Python 3.5.2 (v3.5.2:4def2a2901aS, Jun 26 2016, 10:47:25) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3DJ on darwin Type copyright credits or license for more information. RESTART: /Users/idipippo/Documents/csc 110/homework/hw7-alder32.p checksumAlderC CHECKSUM') 169935444 checksumAlderC'DIGITALFORENSICS') 657523883 check sumAlderC'EVIDENCE') 173867588Explanation / Answer
def checksumAlder(str1):
'''Initialising A to 1 and B to 0'''
A = 1
B = 0
''' Looping over the length of the string to check the ascii value of each and every character in the string'''
for i in range(len(str1)):
''' Adding the ascii/numeric value of the character to A'''
A += ord(str1[i])
''' Adding the value of to B'''
B += A
'''Multiplying the value of B with 65536 and adding the value of A'''
output_val = B * 65536 + A
print(str1 + ' ' + str(output_val))
return output_val
'''When a program is executed the statements that are there in main will be executed first'''
if __name__ == '__main__':
checksumAlder('CHECKSUM')
checksumAlder('DIGITALFORENSICS')
checksumAlder('EVIDENCE')
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.