mvn test -Dmaven.test.failure.ignore=true -Dapp.properties.path=conf/area/sz -P profile-A
public class EncryptedPropertyPlaceholderConfigurer extends PropertyPlaceholderConfigurer {
private List<String> encryptPropertyNames;
@Override
protected String convertProperty(String propertyName, String propertyValue) {
String propertyValueDecrypt = propertyValue;
if (containsProperty(propertyName)) {
propertyValueDecrypt = PropertyDecryptor.decrypt(propertyValue);
}
return convertPropertyValue(propertyValueDecrypt);
}
private boolean containsProperty(String propertyName) {
return encryptPropertyNames != null && encryptPropertyNames.contains(propertyName);
}
public void setEncryptPropertyNames(List<String> encryptPropertyNames) {
this.encryptPropertyNames = encryptPropertyNames;
}
}
public class PropertyDecryptor {
private static void checkForHex(char c) {
if (c == '0' || c == '1' || c == '2' || c == '3' || c == '4' || c == '5' || c == '6' || c == '7' || c == '8' || c == '9' || c == 'A' || c == 'B' ||
c == 'C' || c == 'D' || c == 'E' || c == 'F') {
return;
}
throw new IllegalArgumentException("Expected hex character for " + Character.toString(c));
}
/**
* @param encryptedText in the form AA[11BB3344 ..] -- All hex numbers Where AA is the key that is XOR'ed againt the
* other numbers to decrypt.
* @return Encrypted string
*/
public static String decrypt(String encryptedText) {
char[] encodedText = encryptedText.toUpperCase().toCharArray();
// First Get the Key.
int key = theConv(encodedText);
char[] textString = new char[encodedText.length / 2 - 1]; // ' - 1'
// since the
// first hex
// is the key
for (int pos = 2; pos < encodedText.length; pos += 2) {
char[] hexNum = {encryptedText.charAt(pos), encryptedText.charAt(pos + 1)};
int x = (theConv(hexNum) ^ key);
char theChar = (char) x;
textString[pos / 2 - 1] = theChar;
}
return new String(textString);
}
private static int theConv(char[] c) {
// Check its Hex
checkForHex(c[0]);
checkForHex(c[1]);
Character hexStr0 = Character.toLowerCase(c[0]);
Character hexStr1 = Character.toLowerCase(c[1]);
int MSB;
int LSB;
// 48 is ASCII value of 0
// 97 is ASCII value of a
if (Character.isDigit(hexStr0)) {
MSB = (hexStr0 - 48);
}
else {
int asciiVal = hexStr0;
MSB = (asciiVal - 97 + 10);
}
if (Character.isDigit(hexStr1)) {
LSB = (hexStr1 - 48);
}
else {
int asciiVal = hexStr1;
LSB = (asciiVal - 97 + 10);
}
return (MSB * 16 + LSB);
}
public static void main(String args[]) {
System.out.println(decrypt(args[0]));
}
}
分享到:
相关推荐
hibernate+maven demo项目工程, 通过maven 动态加载类库 注释写法,xml写法都有
学习搭建 springmvc环境,第一个搭建成功的小DEMO。由于是第一次搭建,就免费送资源把。
structs2 + maven demo项目 开发小例子 实现了简单的xml映射
jacoco单元测试覆盖率+maven DEMO
mybatis maven demo 测试示例 mybatis maven demo 测试示例
这是一个sparingMVC的demo框架+maven,开箱即用。欢迎下载。
这是一个maven分模块的小demo,希望对大家有所帮助。如果有什么问题欢迎加关注私信。
Windowss 下 Spring + ActiveMq + maven 集成配置分为两章,环境搭建之前参考了网上的博客以及同事的配置。
使用spring jmstemplate写的activemq小demo,浅显易懂。工程下载导入可用(maven 工程) activemq 可直接apache官网下载 传送门http://activemq.apache.org/download.html
基于的maven框架ssm demo导入就能运行 自己修改mysql maven java springmvc mybatis spring ssm
网上的例子 都不整洁, 自己写了一个 结构非常清晰,非常利于开发人员 学习 或 搭建, 项目下载下来 ,本地启动号zookeeper 就可运行
用maven搭建的springMVC demo,不错的入门例子,欢迎大家下载使用
Spring MVC + Maven + Mybatis 框架例子,带前台框架,包括登录java写好程序,只需修改配置文件
框架搭建 maven+springmvc+mybatis 第一版:mavendemo 详细技术请见博客http://blog.csdn.net/zcjfzcjf
Spring+SpringMVC+Mybatis+Velocity+Maven整合
spring mvc demo 全注解。 自定义jpa查询封闭类。最大简化开发人员重复代码类,提高开发效率 maven已配置好,自己下jar包就可以跑起来 有不明白的可以联系我。
简单的Spring Boot 基于 Maven 的 Demo;简单至极 包含指定端口的配置文件
mavendem,在eclipse搭建mavenjava环境源码,mybats+spring+maven
spring+mvc+maven开发的springmvcdemo例子,简单实用。
ssh整合demo ,structs hibernate spring 整合到一起的开发基础demo 使用了maven 开发 动态链接jar包