下载此文档

MD5加密解密类(Java).doc


文档分类:IT计算机 | 页数:约9页 举报非法文档有奖
1/9
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/9 下载此文档
文档列表 文档介绍
MD5加密解密类(Java).docpackage ;
import ;
import ;
import ;
import ;
import ;
public class MyMD5Util {
private static final String HEX_NUMS_STR="0123456789ABCDEF"; private static final Integer SALT_LENGTH = 12;
/*/
public static String byteToHexString(byte[] b) { StringBuffer hexString = new StringBuffer(); for (int i = 0; i < ; i++) {
String hex = (b[i] & 0xFF); if (() == 1) {
* 将 16 进制字符串转换成字节数组
* ***@param hex
* ***@return
*/
public static byte[] hexStringToByte(String hex) {
int len = (() / 2);
byte[] result = new byte[len];
char[] hexChars = ();
for (int i = 0; i < len; i++) {
int pos = i 将指定 byte 数组转换成 16 进制字符串
* ***@param b
* ***@return
2;
result[i] = (byte) ((hexChars[pos]) << 4
| (hexChars[pos +
1]));
}
return result;
}
hex = '0' + hex;
} (());
}
return ();
}
/**
* 验证口令是否合法
* ***@param password
* ***@param passwordInDb
* ***@return
* ***@throws NoSuchAlgorithmException
* ***@throws UnsupportedEncodingException
*/
public static boolean validPassword(String password, String passwordInDb)
throws NoSuchAlgorithmException, UnsupportedEncodingException {
// 将 16 进制字

MD5加密解密类(Java) 来自淘豆网www.taodocs.com转载请标明出处.

相关文档 更多>>
非法内容举报中心
文档信息
  • 页数9
  • 收藏数0 收藏
  • 顶次数0
  • 上传人小s
  • 文件大小100 KB
  • 时间2021-12-07