We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
String msg = "hello world! 我是 antherd."; String key = "0123456789abcdeffedcba9876543210"; // 16 进制字符串,要求为 128 比特
String encryptData1 = Sm4.encrypt(msg, key); // 加密,默认使用 pkcs#5 填充,输出16进制字符串 System.out.println(encryptData1); Sm4Options sm4Options2 = new Sm4Options(); sm4Options2.setPadding("none"); String encryptData2 = Sm4.encrypt(msg, key, sm4Options2); // 加密,不使用 padding,输出16进制字符串 System.out.println(encryptData2); Sm4Options sm4Options3 = new Sm4Options(); sm4Options3.setPadding("none"); byte[] encryptData3 = Sm4.hexToBytes(Sm4.encrypt(msg, key, sm4Options3)); // 加密,不使用 padding,输出转为字节数组 System.out.println(encryptData3); Sm4Options sm4Options4 = new Sm4Options(); sm4Options4.setMode("cbc"); sm4Options4.setIv("fedcba98765432100123456789abcdef"); String encryptData4 = Sm4.encrypt(msg, key, sm4Options4); // 加密,cbc 模式,输出16进制字符串 System.out.println(encryptData4);
四种加密结果都等于 0e395deb10f6e8a17e17823e1fd9bd98ba9d414a1328bb62fd1a83cdedd7e4dd
The text was updated successfully, but these errors were encountered:
@wqh331589996
哈哈哈
Sorry, something went wrong.
Update sm4.js
c732bbd
antherd#14 修复java script 引擎兼容
我也遇到了同样的问题,sm4Options4 不同的iv每次加密出来结果都一样
No branches or pull requests
String msg = "hello world! 我是 antherd.";
String key = "0123456789abcdeffedcba9876543210"; // 16 进制字符串,要求为 128 比特
四种加密结果都等于 0e395deb10f6e8a17e17823e1fd9bd98ba9d414a1328bb62fd1a83cdedd7e4dd
The text was updated successfully, but these errors were encountered: