|
|
@@ -6,46 +6,35 @@ import org.junit.Test;
|
|
|
public class DesTest {
|
|
|
@Test
|
|
|
public void test(){
|
|
|
+ // 测试
|
|
|
+ prindHexString("jdbc:mysql://192.168.253.12:3306/mall_test_dev?characterEncoding=UTF-8&allowMultiQueries=true&rewriteBatchedStatements=true");
|
|
|
+ prindHexString("root");
|
|
|
+ prindHexString("select111***");
|
|
|
+
|
|
|
+ // 正式
|
|
|
+ prindHexString("jdbc:mysql://10.10.0.208:8066/mall_prod?characterEncoding=UTF-8&allowMultiQueries=true&rewriteBatchedStatements=true");
|
|
|
+ prindHexString("sa");
|
|
|
+ prindHexString("Select123!#%*(");
|
|
|
+
|
|
|
+ // 正式旧版
|
|
|
+ prindHexString("jdbc:mysql://10.10.100.18:3306/mall_prod?characterEncoding=UTF-8");
|
|
|
+ prindHexString("root");
|
|
|
+ prindHexString("select");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 打印加密后的字符串
|
|
|
+ * @param s 明文
|
|
|
+ */
|
|
|
+ public void prindHexString(String s) {
|
|
|
try {
|
|
|
Des des = new Des();
|
|
|
- byte b[] = des.encrypt("root", "10101010");
|
|
|
- System.out.println(des.toHexString(b));
|
|
|
-
|
|
|
- b = des.encrypt("jdbc:mysql://192.168.253.12:3306/mall_test_dev?characterEncoding=UTF-8&allowMultiQueries=true&rewriteBatchedStatements=true", "10101010");
|
|
|
- System.out.println(des.toHexString(b));
|
|
|
- //System.out.println(des.decrypt(des.toHexString(b), "10101010"));
|
|
|
-
|
|
|
- b = des.encrypt("select111***", "10101010");
|
|
|
- System.out.println(des.toHexString(b));
|
|
|
-
|
|
|
- //正式
|
|
|
- b = des.encrypt("sa", "10101010");
|
|
|
- System.out.println(des.toHexString(b));
|
|
|
-
|
|
|
- b = des.encrypt("jdbc:mysql://10.10.0.208:8066/mall_prod?characterEncoding=UTF-8&allowMultiQueries=true&rewriteBatchedStatements=true", "10101010");
|
|
|
- System.out.println(des.toHexString(b));
|
|
|
- //System.out.println(des.decrypt(des.toHexString(b), "10101010"));
|
|
|
-
|
|
|
- b = des.encrypt("Select123!#%*(", "10101010");
|
|
|
- System.out.println(des.toHexString(b));
|
|
|
-
|
|
|
- //旧版正式
|
|
|
- b = des.encrypt("root", "10101010");
|
|
|
+ String key = "10101010";
|
|
|
+ byte b[] = des.encrypt(s, key);
|
|
|
System.out.println(des.toHexString(b));
|
|
|
-
|
|
|
- b = des.encrypt("jdbc:mysql://10.10.100.18:3306/mall_prod?characterEncoding=UTF-8", "10101010");
|
|
|
- System.out.println(des.toHexString(b));
|
|
|
- //System.out.println(des.decrypt(des.toHexString(b), "10101010"));
|
|
|
-
|
|
|
- b = des.encrypt("select", "10101010");
|
|
|
- System.out.println(des.toHexString(b));
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- }catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
|