Commit d048f8a5 authored by yanzg's avatar yanzg

表结构修改

parent 10448834
...@@ -12,7 +12,7 @@ public class TestRsa { ...@@ -12,7 +12,7 @@ public class TestRsa {
} }
@Test @Test
public void testRsa() throws Exception { public void testRsa() {
RsaHelper.RsaInfo rsaInfo = RsaHelper.generatorRsa(); RsaHelper.RsaInfo rsaInfo = RsaHelper.generatorRsa();
testRsaPublicEncode(rsaInfo); testRsaPublicEncode(rsaInfo);
testRsaPrivateEncode(rsaInfo); testRsaPrivateEncode(rsaInfo);
...@@ -37,9 +37,15 @@ public class TestRsa { ...@@ -37,9 +37,15 @@ public class TestRsa {
String temp = RsaHelper.encryptionByPublicKey(from, rsaInfo.getPublicKey()); String temp = RsaHelper.encryptionByPublicKey(from, rsaInfo.getPublicKey());
String result = RsaHelper.decryptionByPrivateKey(temp, rsaInfo.getPrivateKey()); String result = RsaHelper.decryptionByPrivateKey(temp, rsaInfo.getPrivateKey());
System.out.println("原字段:" + from); System.out.println("原字段:" + from);
System.out.println("公钥加密后字段" + temp); System.out.println("公钥加密后字段:" + temp);
System.out.println("私钥解密后字段" + result); System.out.println("私钥解密后字段:" + result);
Assert.assertEquals(from, result); Assert.assertEquals(from, result);
String rsaTemp = RsaHelper.encodeRsaValueInfo(from, rsaInfo.getPublicKeyFrom());
String rsaResult = RsaHelper.decodeRsaValueInfo(rsaTemp, rsaInfo.getPrivateKeyFrom(), 10 * 1000);
System.out.println("Json时间公钥加密后字段:" + rsaTemp);
System.out.println("Json时间私钥解密后字段:" + rsaResult);
Assert.assertEquals(from, rsaResult);
} }
...@@ -53,8 +59,14 @@ public class TestRsa { ...@@ -53,8 +59,14 @@ public class TestRsa {
String temp = RsaHelper.encryptionByPrivateKey(from, rsaInfo.getPrivateKey()); String temp = RsaHelper.encryptionByPrivateKey(from, rsaInfo.getPrivateKey());
String result = RsaHelper.decryptionByPublicKey(temp, rsaInfo.getPublicKey()); String result = RsaHelper.decryptionByPublicKey(temp, rsaInfo.getPublicKey());
System.out.println("原字段:" + from); System.out.println("原字段:" + from);
System.out.println("公钥加密后字段" + temp); System.out.println("公钥加密后字段:" + temp);
System.out.println("私钥解密后字段" + result); System.out.println("私钥解密后字段:" + result);
Assert.assertEquals(from, result); Assert.assertEquals(from, result);
String rsaTemp = RsaHelper.encodeRsaValueInfo(from, rsaInfo.getPrivateKeyFrom());
String rsaResult = RsaHelper.decodeRsaValueInfo(rsaTemp, rsaInfo.getPublicKeyFrom(), 10 * 1000);
System.out.println("Json时间公钥加密后字段:" + rsaTemp);
System.out.println("Json时间私钥解密后字段:" + rsaResult);
Assert.assertEquals(from, rsaResult);
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment