哪位大神知道国密sm3算法,想在登录时对密码进行sm3算法加密,但是在网上找了好久,都没有找到js版的算法包。哪位朋友能提供下,谢谢。
http://download.csdn.net/download/qq_31579845/9481748
public class SM3Util {
public SM3Util() {
}
public static String doHashData(String data) {
try {
return data != null && !data.equals("") ? toHexString(SM3.hash(data.getBytes())) : "";
} catch (Exception e) {
return e.getMessage();
}
}
public static String doHashFile(String filePath) throws IOException {
if(filePath != null && !filePath.equals("")) {
byte[] encrypt = null;
try {
FileInputStream e = new FileInputStream(filePath);
encrypt = new byte[e.available()];
e.read(encrypt);
e.close();
} catch (FileNotFoundException var3) {
var3.printStackTrace();
} catch (IOException var4) {
var4.printStackTrace();
}
return toHexString(SM3.hash(encrypt));
} else {
return "";
}
}
private static String toHexString(byte[] b) {
String hexChar = "0123456789abcdef";
StringBuilder sb = new StringBuilder();
for(int i = 0; i < b.length; ++i) {
sb.append("0123456789abcdef".charAt(b[i] >> 4 & 15));
sb.append("0123456789abcdef".charAt(b[i] & 15));
}
return sb.toString();
}
}
你看看这是Java实现 包我也没有找到 55555555555555555