Pure Programmer
Blue Matrix


Cluster Map

Project: Simple 8-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 an 8-bit checksum of the data. The checksum is computed taking the input bytes one at a time. 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 two hexidecimal digits.

Output
$ swiftc SimpleChecksum1.swift -I . -L . -lUtils error: link command failed with exit code 1 (use -v to see invocation) ld: library not found for -lUtils clang: error: linker command failed with exit code 1 (use -v to see invocation) $ swiftc SimpleChecksum1.swift -I . -L . -lUtils error: link command failed with exit code 1 (use -v to see invocation) ld: library not found for -lUtils clang: error: linker command failed with exit code 1 (use -v to see invocation) $ swiftc SimpleChecksum1.swift -I . -L . -lUtils error: link command failed with exit code 1 (use -v to see invocation) ld: library not found for -lUtils clang: error: linker command failed with exit code 1 (use -v to see invocation)

Solution