- bcprov-jdk15on-1.52.jar,bcpkix-jdk15on-1.52.jar放入java_home\jre\lib\ext目录下
- java_home\jre\lib\security的java.security中 security.provider.11=org.bouncycastle.jce.provider.BouncyCastleProvider
Security.addProvider(new BouncyCastleProvider());
MessageDigest md = null;
try {
md = MessageDigest.getInstance("SM3", "BC");
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (NoSuchProviderException e) {
e.printStackTrace();
}
byte[] result = md.digest("abc".getBytes());
System.out.print(Hex.toHexString(result));