I’m working on a project where I have to create a sha1-hash of an object. Calculating the hash isn’t the problem, but I’m worried about the design of it.
The object itself is a
data class and I’m relying on the
toString() function to provide the input for the hash function. But is a
toString-function cut it stone or could you imagine the implementation changing. Because if the implementation of
toString() changes, the output of the hash would end up being different for the same object, using different
I’m wondering if there might be a better alternative?!? Should I just always override
toString and provide my own implementation or should I trust that the implementation of
toString will stay the same in regards to
data classes and avoid unnecessary boilerplate?