Pure Programmer
Blue Matrix


Cluster Map

Project: Simple 32-Bit Checksum

Write a program that computes a simple checksum. Checksums are a way to convert a large amount of data down to one number. If we compute the checksum before we transmit a file over the network then compute the checksum of the received file we will hopefully notice a change in the checksum value if the data was corrupted during transmission.

The program should take input on the standard input and compute a 32-bit checksum of the data. The checksum is computed taking the input bytes four at a time to form a 32-bit value (network byte order or big endian). This value is XORed with the current value of the checksum. The checksum should start with 0. Once the input is exhausted the program should print out the checksum as eight hexidecimal digits.

Output
$ rustc SimpleChecksum2.rs error[E0425]: cannot find value `cin` in this scope --> SimpleChecksum2.rs:10:10 | 10 | binmode(cin); | ^^^ not found in this scope error[E0425]: cannot find function `binmode` in this scope --> SimpleChecksum2.rs:10:2 | 10 | binmode(cin); | ^^^^^^^ not found in this scope error[E0425]: cannot find function `getbyte` in this scope --> SimpleChecksum2.rs:15:8 | 15 | while getbyte(c) { | ^^^^^^^ not found in this scope error[E0425]: cannot find function `suffix` in this scope --> SimpleChecksum2.rs:22:17 | 22 | println!("{}", suffix(result,8)); | ^^^^^^ not found in this scope error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0425`. $ rustc SimpleChecksum2.rs error[E0425]: cannot find value `cin` in this scope --> SimpleChecksum2.rs:10:10 | 10 | binmode(cin); | ^^^ not found in this scope error[E0425]: cannot find function `binmode` in this scope --> SimpleChecksum2.rs:10:2 | 10 | binmode(cin); | ^^^^^^^ not found in this scope error[E0425]: cannot find function `getbyte` in this scope --> SimpleChecksum2.rs:15:8 | 15 | while getbyte(c) { | ^^^^^^^ not found in this scope error[E0425]: cannot find function `suffix` in this scope --> SimpleChecksum2.rs:22:17 | 22 | println!("{}", suffix(result,8)); | ^^^^^^ not found in this scope error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0425`. $ rustc SimpleChecksum2.rs error[E0425]: cannot find value `cin` in this scope --> SimpleChecksum2.rs:10:10 | 10 | binmode(cin); | ^^^ not found in this scope error[E0425]: cannot find function `binmode` in this scope --> SimpleChecksum2.rs:10:2 | 10 | binmode(cin); | ^^^^^^^ not found in this scope error[E0425]: cannot find function `getbyte` in this scope --> SimpleChecksum2.rs:15:8 | 15 | while getbyte(c) { | ^^^^^^^ not found in this scope error[E0425]: cannot find function `suffix` in this scope --> SimpleChecksum2.rs:22:17 | 22 | println!("{}", suffix(result,8)); | ^^^^^^ not found in this scope error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0425`.

Solution