package com.hdu.utils;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
/**
*
* @author dengsilinming
* @date 2012-12-27 上午10:49:16
*
*/
public class MD5Utils {
private static final String MD5_SUFFIX = "_dengsilinming";
/**
* 字符加密
* @param str 明文
* @return 返回加了后缀的加密字符
*/
public static String encryptByMD5(String str) {
try {
if (str == null || str.length() < 1 || "0".equals(str))
str = "0";
String tmp = md5(str + MD5_SUFFIX, "UTF-8");
if (null != tmp) {
return replace(tmp, ":", "", -1).toLowerCase();
}
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return "";
}
/**
* md5加密方法,不可逆转
* @param str 明文
* @param charset 字符编码
* @return
* @throws NoSuchAlgorithmException
* @throws UnsupportedEncodingException
*/
public static String md5(String str, String charset)
throws NoSuchAlgorithmException, UnsupportedEncodingException {
byte[] tmpInput = null;
if (null != str) {
if (null != charset) {
tmpInput = str.getBytes(charset);
} else {
tmpInput = str.getBytes();
}
} else {
return null;
}
MessageDigest alg = MessageDigest.getInstance("MD5"); // or "SHA-1"
alg.update(tmpInput);
return byte1hex(alg.digest());
}
/**
* 字节码转换成16进制字符串
*
* @param inputByte
* @return
*/
public static String byte1hex(byte[] inputByte) {
if (null == inputByte) {
return null;
}
String resultStr = "";
String tmpStr = "";
for (int n = 0; n < inputByte.length; n++) {
tmpStr = (Integer.toHexString(inputByte[n] & 0XFF));
if (tmpStr.length() == 1)
resultStr = resultStr + "0" + tmpStr;
else
resultStr = resultStr + tmpStr;
if (n < inputByte.length - 1)
resultStr = resultStr + ":";
}
return resultStr.toUpperCase();
}
public static String replace(String text, String repl, String with, int max) {
if (isEmpty(text) || isEmpty(repl) || with == null || max == 0) {
return text;
}
int start = 0;
int end = text.indexOf(repl, start);
if (end == -1) {
return text;
}
int replLength = repl.length();
int increase = with.length() - replLength;
increase = (increase < 0 ? 0 : increase);
increase *= (max < 0 ? 16 : (max > 64 ? 64 : max));
StringBuffer buf = new StringBuffer(text.length() + increase);
while (end != -1) {
buf.append(text.substring(start, end)).append(with);
start = end + replLength;
if (--max == 0) {
break;
}
end = text.indexOf(repl, start);
}
buf.append(text.substring(start));
return buf.toString();
}
public static boolean isEmpty(String str) {
return str == null || str.length() == 0;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
ssh(struts2+spring4+hibernate4)简单整合
共87个文件
jar:35个
class:13个
java:12个
需积分: 9 23 下载量 89 浏览量
2016-12-03
11:28:43
上传
评论 1
收藏 10.54MB RAR 举报
温馨提示
ssh(struts2+spring4+hibernate4)整合,整合完整注释齐全,适合初学者上手容易,mysql数据库,只需建student表,属性为String username,String passowrd,int age,date birthday。然后在application.xml里填写自己的数据库用户名和密码即可。
资源推荐
资源详情
资源评论
收起资源包目录
JAVAEE.rar (87个子文件)
JAVAEE
.springBeans 458B
.myhibernatedata 394B
.settings
com.genuitec.runtime.libraries.xml 108B
org.eclipse.wst.jsdt.ui.superType.name 6B
org.eclipse.wst.common.project.facet.core.xml 513B
org.eclipse.wst.common.component 477B
org.eclipse.wst.common.project.facet.core.prefs.xml 618B
org.eclipse.wst.jsdt.ui.superType.container 49B
.jsdtscope 522B
org.eclipse.jdt.core.prefs 364B
src
HibernateSessionFactory.java 3KB
com
hdu
jTest
dao
StudentDao.java 360B
impl
StudentDaoImpl.java 2KB
action
LoginAction.java 1KB
ListAction.java 893B
RegisterAction-validation.xml 1KB
RegisterAction.java 1KB
model
Student.java 1KB
service
impl
StudentServiceImpl.java 1KB
StudentService.java 507B
utils
EncodingFilter.java 645B
SendEmail.java 2KB
MD5Utils.java 4KB
struts.xml 772B
applicationContext.xml 3KB
.project 1KB
WebRoot
Register.jsp 1KB
META-INF
MANIFEST.MF 39B
WEB-INF
web.xml 1KB
classes
com
hdu
jTest
dao
StudentDao.class 275B
impl
StudentDaoImpl.class 1KB
action
LoginAction.class 984B
RegisterAction-validation.xml 1KB
ListAction.class 1KB
RegisterAction.class 2KB
model
Student.class 1KB
service
StudentService.class 380B
impl
StudentServiceImpl.class 1KB
utils
SendEmail.class 2KB
MD5Utils.class 3KB
EncodingFilter.class 1KB
SendEmail$1.class 696B
struts.xml 772B
HibernateSessionFactory.class 3KB
applicationContext.xml 3KB
lib
commons-dbcp2-2.1.1.jar 170KB
org.springframework.instrument-sources-3.1.2.RELEASE.jar 2KB
commons-fileupload-1.3.2.jar 69KB
org.springframework.oxm-sources-3.1.2.RELEASE.jar 56KB
org.springframework.expression-sources-3.1.2.RELEASE.jar 150KB
org.springframework.jdbc-sources-3.1.2.RELEASE.jar 411KB
org.springframework.orm-sources-3.1.2.RELEASE.jar 323KB
org.springframework.web.portlet-sources-3.1.2.RELEASE.jar 190KB
javassist-3.11.0.GA.jar 600KB
mysql-connector-java-5.1.39-bin.jar 966KB
org.springframework.transaction-sources-3.1.2.RELEASE.jar 272KB
struts2-spring-plugin-2.0.11.1.jar 9KB
org.springframework.test-sources-3.1.2.RELEASE.jar 224KB
org.springframework.core-sources-3.1.2.RELEASE.jar 438KB
org.springframework.web-sources-3.1.2.RELEASE.jar 539KB
org.springframework.web.servlet-sources-3.1.2.RELEASE.jar 592KB
struts2-core-2.3.31.jar 854KB
freemarker-2.3.22.jar 1.24MB
org.springframework.beans-sources-3.1.2.RELEASE.jar 530KB
commons-logging-1.1.3.jar 61KB
mail-1.4.7.jar 509KB
javax.mail-1.5.5.jar 589KB
org.springframework.aspects-sources-3.1.2.RELEASE.jar 30KB
xwork-core-2.3.31.jar 663KB
ognl-3.0.19.jar 225KB
org.springframework.aop-sources-3.1.2.RELEASE.jar 317KB
org.springframework.context.support-sources-3.1.2.RELEASE.jar 117KB
org.springframework.asm-sources-3.1.2.RELEASE.jar 543B
org.springframework.web.struts-sources-3.1.2.RELEASE.jar 40KB
commons-io-2.2.jar 170KB
org.springframework.jms-sources-3.1.2.RELEASE.jar 174KB
commons-lang3-3.2.jar 376KB
org.springframework.context-sources-3.1.2.RELEASE.jar 829KB
org.springframework.instrument.tomcat-sources-3.1.2.RELEASE.jar 6KB
commons-pool2-2.4.2.jar 109KB
spring.tld 18KB
spring-form.tld 74KB
List.jsp 3KB
Login.jsp 786B
Actionfailer.jsp 1KB
.classpath 5KB
.tern-project 66B
共 87 条
- 1
资源评论
shawnMMM
- 粉丝: 29
- 资源: 10
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于 Java的班级管理系统课程设计
- 深入探索Suno AI:教程、元标签与案例分析.pdf
- 超市会员积分管理系统主要用于实现了企业管理数据统计等
- 基于 Java的班级管理系统
- MyBatis 动态 SQL:灵活而强大的查询构建器.pdf
- com.accordion.prettyo.apk
- 毕业设计:基于SSM的mysql-ssm软件bug管理系统(源码 + 数据库 + 说明文档)
- MTSQL8.0.35windows(64bit)-mysql-installer-community-8.0.35.0
- 人工智能引领音乐创作新时代之Suno AI
- Public-bicycle-usage-forecast-master.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功