Need thread safe MessageDigest in Java

前端 未结 3 2053
清酒与你
清酒与你 2020-12-23 20:45

I need to hash multiple keys from multiple threads using MessageDigest in a performance critical environment. I came to know that MessageDigest is not thread safe as it stor

3条回答
  •  执笔经年
    2020-12-23 21:43

    As an alternative, use DigestUtils, Apache Commons' thread-safe wrapper for MessageDigest.

    sha1() does what you need:

    byte[] bytes = sha1(key)

提交回复
热议问题