Tag: bouncycastle sha512

如何使用充气城堡在Java中创建SHA512摘要字符串?

此unit testing失败: public void testDigest() throws NoSuchAlgorithmException { String hashExpected = “150a14ed5bea6cc731cf86c41566ac427a8db48ef1b9fd626664b3bfbb99071fa4c922f33dde38719b8c8354e2b7ab9d77e0e67fc12843920a712e73d558e197”; MessageDigest md = new MessageDigest(); String hashActual = new String(md.digest(“hi”)); Assert.assertEquals(hashExpected, hashActual); } 下面是我的MessageDigest类的实现: import java.io.IOException; import java.io.InputStream; import java.security.NoSuchAlgorithmException; import java.security.Security; import org.bouncycastle.crypto.Digest; import org.bouncycastle.crypto.digests.SHA512Digest; import org.bouncycastle.crypto.io.DigestInputStream; import org.bouncycastle.jce.provider.BouncyCastleProvider; 公共类MessageDigest {private Digest messageDigest; public MessageDigest() throws NoSuchAlgorithmException { Security.addProvider(new BouncyCastleProvider()); messageDigest = […]