简体   繁体   中英

Best hash function to hash xml string in Java

I have to generate the hash of an XML string in Java and afterwards store this information in a database table field (my DBMS is Postgres). Which is the best hash function to use? Thank you in advance

It rather depends on the purpose of the hash function. If your aim is to do fast equality matching between documents, then it depends on your criteria for considering two documents to be equal. For example, do you want them to be equal if they have different whitespace, or if they have the same attributes but in a different order? If that's part of the requirement, the best approach might be to first canonicalize the XML documents, then to apply a general-purpose string hash function to the canonicalized form.

The current best (most secure) general purpose hash functions to use are SHA256 or SHA512. Unless you want ultra-high security, SHA256 will do just fine.

For password hashing , the current standard is bcrypt.

There are lots of broken hash functions around, so don't just pick one out of the air...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM