Add checksum function

TODO: Use the checksum function properly.