更新了BC_SM4,以支持安卓调用SM4

This commit is contained in:
free will committed 2021-07-28 13:39:09 +08:00
1 parent 78be6db12c
commit 8e33cb9894
2 files changed
+11 -3

No files matched your search

@@ -16,7 +16,15 @@ import java.security.*;
*/
public class BC_SM4 {
static {
Security.addProvider(new BouncyCastleProvider());
// 加载类的时候执行的静态代码块。只执行一次。
// 参考博文:https://www.cnblogs.com/cherrylv/p/10688487.html
// 这么做是为了解决安卓不能使用正确版本的BC的问题
System.out.println("run static code block");
Security.removeProvider(BouncyCastleProvider.PROVIDER_NAME);
if (Security.getProvider(BouncyCastleProvider.PROVIDER_NAME) == null) {
System.out.println("runtime has no BouncyCastleProvider");
Security.addProvider(new BouncyCastleProvider());
}
}
public static final String ALGORITHM_NAME = "SM4";
public static final String ALGORITHM_NAME_ECB_PADDING = "SM4/ECB/PKCS5Padding";
+2 -2
View File
@@ -34,8 +34,8 @@ public class TestAPI {
// System.out.println(res);
// }
public static void main(String[] args){
String username="/freexshka2";
String email="25fjsygqnshkhk3s@163.com";
String username="/frasgASJGXUa2";
String email="25SAUUKDsiahHk3s@163.com";
int userID=1;
// 模拟客户端生成自己的公钥私钥
BC_KeyManager bc_keyManager=new BC_KeyManager();