mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
add configTool
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
package com.alibaba.druid.bvt.filter.config;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.druid.filter.config.ConfigTool;
|
||||
|
||||
public class ConfigToolTest extends TestCase {
|
||||
|
||||
public void test_configTool() throws Exception {
|
||||
Map<String, String> result = ConfigTool.gen(1024);
|
||||
|
||||
String publicKey = result.get("publicKey");
|
||||
String privateKey = result.get("privateKey");
|
||||
|
||||
System.out.println("publicKey : " + publicKey);
|
||||
System.out.println("privateKey : " + privateKey);
|
||||
|
||||
String cipher = ConfigTool.encrypt(privateKey, "abcdef").get("result");
|
||||
System.out.println("cipher : " + cipher);
|
||||
|
||||
String plain = ConfigTool.decrypt(publicKey, cipher).get("result");
|
||||
System.out.println("plain : " + plain);
|
||||
|
||||
Assert.assertEquals("abcdef", plain);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user