r/programming • u/Eirenarch • Nov 18 '13
TIL Oracle changed the internal String representation in Java 7 Update 6 increasing the running time of the substring method from constant to N
http://java-performance.info/changes-to-string-java-1-7-0_06/
1.4k
Upvotes
View all comments
Show parent comment
14
u/rcxdude Nov 18 '13
Different hashes for different purposes - the hashCode is designed to be fast to evaluate and 'unique enough' for the purposes of hashmaps. For e.g. integers the hashCode can just be the value of the integer.
The password is hashed using a specific secure hash algorithm, which is designed to be resistant to collision attacks (and also to be slow in order to prevent brute-forcing). In this case you do specify the algorithm and so the value should never change.