其实md5还是比较安全的,尤其是在做了两次md5,再加上辅助的加密字串,还是很难破译掉。
public class Md5Security {
private String sourceString;
public Md5Security(String srcString){
this.sourceString = srcString;
}
public String encoder() throws NoSuchAlgorithmException{
MessageDigest md = MessageDigest.getInstance("md5");
md.update(this.sourceString.getBytes());
byte[] digestByte = md.digest();
return toHexChar(digestByte);
}
public String toHexChar(byte[] digestByte){
StringBuilder sbf = new StringBuilder();
for (int i = 0; i < digestByte.length; i++) {
if (Integer.toHexString(0xFF & digestByte[i]).length() == 1) {
sbf.append("0").append(
Integer.toHexString(0