国密算法 SM4 SM3 SM2,JS 版本、JAVA 版本。
var input = "待加密"; var key = "admin#$%^"; //加密 ec = SM4.encode({ input:input, key:key }); console.log('加密:'+ec); //解密 var dc = SM4.decode({ input:ec, key:key }); console.log('解密:'+dc); public static void main(String[] args) throws IOException { String s = new SM4().encode("待加密", "admin#$%^"); System.out.println(s); String j = new SM4().decode(s, "admin#$%^"); System.out.println(j); }