Depending on the type of data, you should decide how to hash it. You'll probably be fine with data being bytes, a string, or a collection of bytes or strings, since each of this can be handled efficiently in different ways. Also, you shouldn't convert digest back to a string.