Question: For this homework assignment, you will write a python function to implement a checksum algorithm known as Alder-16. The following is a description of this
For this homework assignment, you will write a python function to implement a checksum algorithm known as Alder-16. The following is a description of this algorithm modified from the Wikipedia entry about Adler-32:
An Adler-16 checksum is obtained by calculating two 8-bit checksums A and B and concatenating their bits into a 16-bit integer. A is the sum of all bytes in the stream plus one, and B is the sum of the individual values of A from each step.
A few notes about the pseudocode above:
D1, D2, etc. are the decimal values of the characters in the input string. You will have to get the ASCII value of each character and convert it to decimal.
B is computed by accumulating the values of A
Write a function to compute the Alder-16 checksum for a given string. You can modify the 8-bit checksum algorithm that we developed in class to implement this Alder-16 algorithm. You can find the checksum8.py algorithm on the Sample Code page after class on Tuesday. Your output will look something like this:
At the beginning of an Adler-16 run, A is initialized to 1, B to 0. The sums are done modulo 251 (the largest prime number smaller than 28). The function may be expressed as:
A = 1 + D1 + D2 + ... + Dn (mod 251) B = (1 + D1) + (1 + D1 + D2) + ... + (1 + D1 + D2 + ... + Dn) (mod 251) Adler-16(D) = B 256 + A
Your output will look like this
Please write in Python IDLE and comment, thanks!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
