通过spring对hibernate/ibatis的配置文件加密
由于本人优盘丢了,积累的东西都没了 #。#! 所以懒人也得写博客记录些东西
本文参考过网上的例子,具体出处已经不详...
对信息的加密是用的DES(具体加密方法的选用,可自行选择)
public class MyConfigurer extends PropertyPlaceholderConfigurer{ @Override protected void processProperties( ConfigurableListableBeanFactory beanFactory, Properties props) throws BeansException { System.out.println("MyConfigurer!"); String UserName = props.getProperty("jdbc.UserName"); if (UserName != null ) { props.setProperty("jdbc.UserName", DESUtil.getDesString(UserName)); } String password = props.getProperty("jdbc.PassWord"); if (password != null ) { props.setProperty("jdbc.PassWord", DESUtil.getDesString(password)); } super.processProperties(beanFactory, props); }}
以上方法是对数据库用户名和密码进行解密。
记性不好,还是写在不容易丢的地方吧。呵呵
当然可能还有其他更好的方法,仅供参考 1 楼 haigui.chen 2010-12-22 这个只是对用户名和密码加密,如何对iBatis的xml加密并解密? 2 楼 85600367 2010-12-23 haigui.chen 写道这个只是对用户名和密码加密,如何对iBatis的xml加密并解密?
你需要对整个XML加密吗?
对整个发布包混淆就行了