求java加密源代码(MD5,base64)

来源:百度知道 编辑:UC知道 时间:2024/06/23 08:10:35
密文:zgv9FQWbaNZ2iIhNej0+jA==
明文:123456
我在网上找到了个加密方法,用到了chilkcat的东西,但是这个方法必须要调用一个dll,linux下没有办法用,而且这个东西过期就不能用了,要用的话必须缴费,所以现在求另一个加密源码,以下是我找的源码:
public class EncryptUtil
{
static
{
try
{
String path = PlatConfig.getConfigFilePath();
System.load(path + "chilkat.dll");
} catch (UnsatisfiedLinkError e)
{
System.err.println("Native code library failed to load.\n" + e);
System.exit(1);
}
}

/**
* 加密方法
*
* @param mingwen
* @return
*/
public static String encrypt(String mingwen)
{
CkCrypt2 ck = new CkCrypt2();
ck.UnlockComponent("test");
ck.put_HashAlgorithm("md5");
ck.put_EncodingMode("base64");
ck.put_Charset("Unicode");
return ck.hashStringENC(mingwen);
}
public static void main(String[] args)
{
System.o

加密什么加密字符串吗,我这里有md5的算法
public final static String MD5(String pwd) {
char hexDigits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'A', 'B', 'C', 'D', 'E', 'F' };
try {
byte[] strTemp = pwd.getBytes();
MessageDigest mdTemp = MessageDigest.getInstance("MD5");
mdTemp.update(strTemp);
byte[] md = mdTemp.digest();
int j = md.length;
char str[] = new char[j * 2];
int k = 0;
for (int i = 0; i < j; i++) {
byte byte0 = md[i];
str[k++] = hexDigits[byte0 >>> 4 & 0xf];
str[k++] = hexDigits[byte0 & 0xf];
}
return new String(str);
} catch (Exception e) {
return null;
}
}

晚上回去看看

在JAVA里,每一次运行MD5加密,加密的结果是不一样的,即使是用一个KEY,

后来改用了,别的加密方法,

我不敢说MD5加密后,用