MD5 in JAVA
Posted jwentest
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MD5 in JAVA相关的知识,希望对你有一定的参考价值。
using Apache Commons
需要引入org.apache.commons.codec.digest.DigestUtils这个包,pom.xml文件配置如下:
<!-- https://mvnrepository.com/artifact/commons-codec/commons-codec --> <dependency> <groupId>commons-codec</groupId> <artifactId>commons-codec</artifactId> <version>1.10</version> </dependency>
demo代码如下:
@Test public void givenPassword_whenHashingUsingCommons_thenVerifying() { String hash = "35454B055CC325EA1AF2126E27707052"; String password = "ILoveJava"; String md5Hex = DigestUtils .md5Hex(password).toUpperCase(); assertThat(md5Hex.equals(hash)).isTrue(); }
以上是关于MD5 in JAVA的主要内容,如果未能解决你的问题,请参考以下文章