使用Spring自带的DigestUtils ,Spring已经给我们封装好了。 String md5Str = DigestUtils.md5DigestAsHex("原串".getBytes());