简单问题求助。。。 就是按照一定的编码规则,将password的值加密... 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用MD5加密吧!几种加密的方法,仅供参考:)public static byte[] encrypt(byte[] source, String algorithm) throws NoSuchAlgorithmException { MessageDigest md = MessageDigest.getInstance(algorithm); md.reset(); md.update(source); return md.digest(); } public static String encrypt(String source, String algorithm) throws NoSuchAlgorithmException { byte[] resByteArray = encrypt(source.getBytes(), algorithm); return toHexString(resByteArray); } public static String encryptMD5(String source) { if (source == null) { source = ""; } String result = ""; try { result = encrypt(source, "MD5"); } catch(NoSuchAlgorithmException ex) { ex.printStackTrace(); } return result; } java网络编程题 推荐一本书下?? 关于线程优先级的小问题,谢谢 请教:怎样在jsp或servlet中执行sql文件 大家帮忙介绍下java Bean java读取文件系统的文件和目录列表时,怎样才能得到文件的所有者? 如何实现应用程序自动将主数据库切换到备库? 大家好,给点建设性意见。。。。。。 java制作安装程序? jdbc与odbc桥连接Access的问题 jbuilder中说找不到路径,该怎么配置啊 怎样得到当前日期的前两天??(在线等待)
几种加密的方法,仅供参考:)
public static byte[] encrypt(byte[] source, String algorithm) throws NoSuchAlgorithmException {
MessageDigest md = MessageDigest.getInstance(algorithm);
md.reset();
md.update(source);
return md.digest();
}
public static String encrypt(String source, String algorithm) throws NoSuchAlgorithmException {
byte[] resByteArray = encrypt(source.getBytes(), algorithm);
return toHexString(resByteArray);
} public static String encryptMD5(String source) {
if (source == null) {
source = "";
} String result = "";
try {
result = encrypt(source, "MD5");
}
catch(NoSuchAlgorithmException ex) {
ex.printStackTrace();
}
return result;
}