Implement hashing and add tests.