mirror of
https://gitee.com/dromara/hutool.git
synced 2025-12-05 03:17:49 +08:00
clean history
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
package cn.hutool.crypto.test;
|
||||
|
||||
import java.security.PrivateKey;
|
||||
import java.security.PublicKey;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import cn.hutool.core.io.resource.ResourceUtil;
|
||||
import cn.hutool.crypto.BCUtil;
|
||||
import cn.hutool.crypto.asymmetric.KeyType;
|
||||
import cn.hutool.crypto.asymmetric.RSA;
|
||||
|
||||
public class BCUtilTest {
|
||||
|
||||
@Test
|
||||
public void readPrivateKeyTest() {
|
||||
PrivateKey privateKey = BCUtil.readPrivateKey(ResourceUtil.getStream("test_private_key.pem"));
|
||||
Assert.assertNotNull(privateKey);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readPublicKeyTest() {
|
||||
PublicKey publicKey = BCUtil.readPublicKey(ResourceUtil.getStream("test_public_key.csr"));
|
||||
Assert.assertNotNull(publicKey);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void validateKey() {
|
||||
PrivateKey privateKey = BCUtil.readPrivateKey(ResourceUtil.getStream("test_private_key.pem"));
|
||||
PublicKey publicKey = BCUtil.readPublicKey(ResourceUtil.getStream("test_public_key.csr"));
|
||||
|
||||
RSA rsa = new RSA(privateKey, publicKey);
|
||||
String str = "你好,Hutool";//测试字符串
|
||||
|
||||
String encryptStr = rsa.encryptBase64(str, KeyType.PublicKey);
|
||||
String decryptStr = rsa.decryptStr(encryptStr, KeyType.PrivateKey);
|
||||
Assert.assertEquals(str, decryptStr);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package cn.hutool.crypto.test;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import cn.hutool.crypto.digest.HMac;
|
||||
import cn.hutool.crypto.digest.HmacAlgorithm;
|
||||
|
||||
/**
|
||||
* Hmac单元测试
|
||||
* @author Looly
|
||||
*
|
||||
*/
|
||||
public class HmacTest {
|
||||
|
||||
@Test
|
||||
public void hmacTest(){
|
||||
String testStr = "test中文";
|
||||
|
||||
byte[] key = "password".getBytes();
|
||||
HMac mac = new HMac(HmacAlgorithm.HmacMD5, key);
|
||||
|
||||
String macHex1 = mac.digestHex(testStr);
|
||||
Assert.assertEquals("b977f4b13f93f549e06140971bded384", macHex1);
|
||||
|
||||
String macHex2 = mac.digestHex(IoUtil.toStream(testStr, CharsetUtil.CHARSET_UTF_8));
|
||||
Assert.assertEquals("b977f4b13f93f549e06140971bded384", macHex2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hmacMd5Test(){
|
||||
String testStr = "test中文";
|
||||
|
||||
HMac mac = SecureUtil.hmacMd5("password");
|
||||
|
||||
String macHex1 = mac.digestHex(testStr);
|
||||
Assert.assertEquals("b977f4b13f93f549e06140971bded384", macHex1);
|
||||
|
||||
String macHex2 = mac.digestHex(IoUtil.toStream(testStr, CharsetUtil.CHARSET_UTF_8));
|
||||
Assert.assertEquals("b977f4b13f93f549e06140971bded384", macHex2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hmacSha1Test(){
|
||||
String testStr = "test中文";
|
||||
|
||||
HMac mac = SecureUtil.hmacSha1("password");
|
||||
|
||||
String macHex1 = mac.digestHex(testStr);
|
||||
Assert.assertEquals("1dd68d2f119d5640f0d416e99d3f42408b88d511", macHex1);
|
||||
|
||||
String macHex2 = mac.digestHex(IoUtil.toStream(testStr, CharsetUtil.CHARSET_UTF_8));
|
||||
Assert.assertEquals("1dd68d2f119d5640f0d416e99d3f42408b88d511", macHex2);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package cn.hutool.crypto.test;
|
||||
|
||||
import java.security.KeyPair;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import cn.hutool.crypto.CryptoException;
|
||||
import cn.hutool.crypto.GlobalBouncyCastleProvider;
|
||||
import cn.hutool.crypto.KeyUtil;
|
||||
|
||||
public class KeyUtilTest {
|
||||
|
||||
/**
|
||||
* 测试关闭BouncyCastle支持时是否会正常抛出异常,即关闭是否有效
|
||||
*/
|
||||
@Test(expected = CryptoException.class)
|
||||
@Ignore
|
||||
public void generateKeyPairTest() {
|
||||
GlobalBouncyCastleProvider.setUseBouncyCastle(false);
|
||||
KeyPair pair = KeyUtil.generateKeyPair("SM2");
|
||||
Assert.assertNotNull(pair);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package cn.hutool.crypto.test;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import cn.hutool.crypto.symmetric.RC4;
|
||||
|
||||
public class RC4Test {
|
||||
|
||||
@Test
|
||||
public void testCryptMessage() {
|
||||
String key = "This is pretty long key";
|
||||
RC4 rc4 = new RC4(key);
|
||||
String message = "Hello, World!";
|
||||
byte[] crypt = rc4.encrypt(message);
|
||||
String msg = rc4.decrypt(crypt);
|
||||
Assert.assertEquals(message, msg);
|
||||
|
||||
String message2 = "Hello, World, this is megssage 2";
|
||||
byte[] crypt2 = rc4.encrypt(message2);
|
||||
String msg2 = rc4.decrypt(crypt2);
|
||||
Assert.assertEquals(message2, msg2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCryptWithChineseCharacters() {
|
||||
String message = "这是一个中文消息!";
|
||||
String key = "我是一个文件密钥";
|
||||
RC4 rc4 = new RC4(key);
|
||||
byte[] crypt = rc4.encrypt(message);
|
||||
String msg = rc4.decrypt(crypt);
|
||||
Assert.assertEquals(message, msg);
|
||||
|
||||
String message2 = "这是第二个中文消息!";
|
||||
byte[] crypt2 = rc4.encrypt(message2);
|
||||
String msg2 = rc4.decrypt(crypt2);
|
||||
Assert.assertEquals(message2, msg2);
|
||||
}
|
||||
}
|
||||
155
hutool-crypto/src/test/java/cn/hutool/crypto/test/RSATest.java
Normal file
155
hutool-crypto/src/test/java/cn/hutool/crypto/test/RSATest.java
Normal file
@@ -0,0 +1,155 @@
|
||||
package cn.hutool.crypto.test;
|
||||
|
||||
import java.security.KeyPair;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.HexUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.crypto.KeyUtil;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import cn.hutool.crypto.asymmetric.KeyType;
|
||||
import cn.hutool.crypto.asymmetric.RSA;
|
||||
|
||||
/**
|
||||
* RSA算法单元测试
|
||||
*
|
||||
* @author Looly
|
||||
*
|
||||
*/
|
||||
public class RSATest {
|
||||
|
||||
@Test
|
||||
public void generateKeyPairTest() {
|
||||
KeyPair pair = KeyUtil.generateKeyPair("RSA");
|
||||
Assert.assertNotNull(pair.getPrivate());
|
||||
Assert.assertNotNull(pair.getPublic());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rsaCustomKeyTest() {
|
||||
KeyPair pair = KeyUtil.generateKeyPair("RSA");
|
||||
byte[] privateKey = pair.getPrivate().getEncoded();
|
||||
byte[] publicKey = pair.getPublic().getEncoded();
|
||||
|
||||
RSA rsa = SecureUtil.rsa(privateKey, publicKey);
|
||||
|
||||
// 公钥加密,私钥解密
|
||||
byte[] encrypt = rsa.encrypt(StrUtil.bytes("我是一段测试aaaa", CharsetUtil.CHARSET_UTF_8), KeyType.PublicKey);
|
||||
byte[] decrypt = rsa.decrypt(encrypt, KeyType.PrivateKey);
|
||||
Assert.assertEquals("我是一段测试aaaa", StrUtil.str(decrypt, CharsetUtil.CHARSET_UTF_8));
|
||||
|
||||
// 私钥加密,公钥解密
|
||||
byte[] encrypt2 = rsa.encrypt(StrUtil.bytes("我是一段测试aaaa", CharsetUtil.CHARSET_UTF_8), KeyType.PrivateKey);
|
||||
byte[] decrypt2 = rsa.decrypt(encrypt2, KeyType.PublicKey);
|
||||
Assert.assertEquals("我是一段测试aaaa", StrUtil.str(decrypt2, CharsetUtil.CHARSET_UTF_8));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rsaTest() {
|
||||
final RSA rsa = new RSA();
|
||||
|
||||
// 获取私钥和公钥
|
||||
Assert.assertNotNull(rsa.getPrivateKey());
|
||||
Assert.assertNotNull(rsa.getPrivateKeyBase64());
|
||||
Assert.assertNotNull(rsa.getPublicKey());
|
||||
Assert.assertNotNull(rsa.getPrivateKeyBase64());
|
||||
|
||||
// 公钥加密,私钥解密
|
||||
byte[] encrypt = rsa.encrypt(StrUtil.bytes("我是一段测试aaaa", CharsetUtil.CHARSET_UTF_8), KeyType.PublicKey);
|
||||
byte[] decrypt = rsa.decrypt(encrypt, KeyType.PrivateKey);
|
||||
Assert.assertEquals("我是一段测试aaaa", StrUtil.str(decrypt, CharsetUtil.CHARSET_UTF_8));
|
||||
|
||||
// 私钥加密,公钥解密
|
||||
byte[] encrypt2 = rsa.encrypt(StrUtil.bytes("我是一段测试aaaa", CharsetUtil.CHARSET_UTF_8), KeyType.PrivateKey);
|
||||
byte[] decrypt2 = rsa.decrypt(encrypt2, KeyType.PublicKey);
|
||||
Assert.assertEquals("我是一段测试aaaa", StrUtil.str(decrypt2, CharsetUtil.CHARSET_UTF_8));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rsaWithBlockTest2() {
|
||||
final RSA rsa = new RSA();
|
||||
rsa.setEncryptBlockSize(3);
|
||||
|
||||
// 获取私钥和公钥
|
||||
Assert.assertNotNull(rsa.getPrivateKey());
|
||||
Assert.assertNotNull(rsa.getPrivateKeyBase64());
|
||||
Assert.assertNotNull(rsa.getPublicKey());
|
||||
Assert.assertNotNull(rsa.getPrivateKeyBase64());
|
||||
|
||||
// 公钥加密,私钥解密
|
||||
byte[] encrypt = rsa.encrypt(StrUtil.bytes("我是一段测试aaaa", CharsetUtil.CHARSET_UTF_8), KeyType.PublicKey);
|
||||
byte[] decrypt = rsa.decrypt(encrypt, KeyType.PrivateKey);
|
||||
Assert.assertEquals("我是一段测试aaaa", StrUtil.str(decrypt, CharsetUtil.CHARSET_UTF_8));
|
||||
|
||||
// 私钥加密,公钥解密
|
||||
byte[] encrypt2 = rsa.encrypt(StrUtil.bytes("我是一段测试aaaa", CharsetUtil.CHARSET_UTF_8), KeyType.PrivateKey);
|
||||
byte[] decrypt2 = rsa.decrypt(encrypt2, KeyType.PublicKey);
|
||||
Assert.assertEquals("我是一段测试aaaa", StrUtil.str(decrypt2, CharsetUtil.CHARSET_UTF_8));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rsaBcdTest() {
|
||||
String text = "我是一段测试aaaa";
|
||||
|
||||
final RSA rsa = new RSA();
|
||||
|
||||
// 公钥加密,私钥解密
|
||||
String encryptStr = rsa.encryptBcd(text, KeyType.PublicKey);
|
||||
String decryptStr = StrUtil.utf8Str(rsa.decryptFromBcd(encryptStr, KeyType.PrivateKey));
|
||||
Assert.assertEquals(text, decryptStr);
|
||||
|
||||
// 私钥加密,公钥解密
|
||||
String encrypt2 = rsa.encryptBcd(text, KeyType.PrivateKey);
|
||||
String decrypt2 = StrUtil.utf8Str(rsa.decryptFromBcd(encrypt2, KeyType.PublicKey));
|
||||
Assert.assertEquals(text, decrypt2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rsaBase64Test() {
|
||||
String textBase = "我是一段特别长的测试";
|
||||
String text = "";
|
||||
for (int i = 0; i < 10; i++) {
|
||||
text += textBase;
|
||||
}
|
||||
|
||||
final RSA rsa = new RSA();
|
||||
|
||||
// 公钥加密,私钥解密
|
||||
String encryptStr = rsa.encryptBase64(text, KeyType.PublicKey);
|
||||
String decryptStr = StrUtil.utf8Str(rsa.decrypt(encryptStr, KeyType.PrivateKey));
|
||||
Assert.assertEquals(text, decryptStr);
|
||||
|
||||
// 私钥加密,公钥解密
|
||||
String encrypt2 = rsa.encryptBase64(text, KeyType.PrivateKey);
|
||||
String decrypt2 = StrUtil.utf8Str(rsa.decrypt(encrypt2, KeyType.PublicKey));
|
||||
Assert.assertEquals(text, decrypt2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rsaDecodeTest() {
|
||||
String PRIVATE_KEY = "MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAIL7pbQ+5KKGYRhw7jE31hmA" //
|
||||
+ "f8Q60ybd+xZuRmuO5kOFBRqXGxKTQ9TfQI+aMW+0lw/kibKzaD/EKV91107xE384qOy6IcuBfaR5lv39OcoqNZ"//
|
||||
+ "5l+Dah5ABGnVkBP9fKOFhPgghBknTRo0/rZFGI6Q1UHXb+4atP++LNFlDymJcPAgMBAAECgYBammGb1alndta" //
|
||||
+ "xBmTtLLdveoBmp14p04D8mhkiC33iFKBcLUvvxGg2Vpuc+cbagyu/NZG+R/WDrlgEDUp6861M5BeFN0L9O4hz"//
|
||||
+ "GAEn8xyTE96f8sh4VlRmBOvVdwZqRO+ilkOM96+KL88A9RKdp8V2tna7TM6oI3LHDyf/JBoXaQJBAMcVN7fKlYP" //
|
||||
+ "Skzfh/yZzW2fmC0ZNg/qaW8Oa/wfDxlWjgnS0p/EKWZ8BxjR/d199L3i/KMaGdfpaWbYZLvYENqUCQQCobjsuCW"//
|
||||
+ "nlZhcWajjzpsSuy8/bICVEpUax1fUZ58Mq69CQXfaZemD9Ar4omzuEAAs2/uee3kt3AvCBaeq05NyjAkBme8SwB0iK"//
|
||||
+ "kLcaeGuJlq7CQIkjSrobIqUEf+CzVZPe+AorG+isS+Cw2w/2bHu+G0p5xSYvdH59P0+ZT0N+f9LFAkA6v3Ae56OrI"//
|
||||
+ "wfMhrJksfeKbIaMjNLS9b8JynIaXg9iCiyOHmgkMl5gAbPoH/ULXqSKwzBw5mJ2GW1gBlyaSfV3AkA/RJC+adIjsRGg"//
|
||||
+ "JOkiRjSmPpGv3FOhl9fsBPjupZBEIuoMWOC8GXK/73DHxwmfNmN7C9+sIi4RBcjEeQ5F5FHZ";
|
||||
|
||||
RSA rsa = new RSA(PRIVATE_KEY, null);
|
||||
|
||||
String a = "2707F9FD4288CEF302C972058712F24A5F3EC62C5A14AD2FC59DAB93503AA0FA17113A020EE4EA35EB53F" //
|
||||
+ "75F36564BA1DABAA20F3B90FD39315C30E68FE8A1803B36C29029B23EB612C06ACF3A34BE815074F5EB5AA3A"//
|
||||
+ "C0C8832EC42DA725B4E1C38EF4EA1B85904F8B10B2D62EA782B813229F9090E6F7394E42E6F44494BB8";
|
||||
|
||||
byte[] aByte = HexUtil.decodeHex(a);
|
||||
byte[] decrypt = rsa.decrypt(aByte, KeyType.PrivateKey);
|
||||
|
||||
Assert.assertEquals("虎头闯杭州,多抬头看天,切勿只管种地", StrUtil.str(decrypt, CharsetUtil.CHARSET_UTF_8));
|
||||
}
|
||||
}
|
||||
142
hutool-crypto/src/test/java/cn/hutool/crypto/test/SM2Test.java
Normal file
142
hutool-crypto/src/test/java/cn/hutool/crypto/test/SM2Test.java
Normal file
@@ -0,0 +1,142 @@
|
||||
package cn.hutool.crypto.test;
|
||||
|
||||
import java.security.KeyPair;
|
||||
import java.security.PublicKey;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.HexUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.crypto.KeyUtil;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import cn.hutool.crypto.SmUtil;
|
||||
import cn.hutool.crypto.asymmetric.KeyType;
|
||||
import cn.hutool.crypto.asymmetric.SM2;
|
||||
import cn.hutool.crypto.asymmetric.SM2Engine.SM2Mode;
|
||||
|
||||
/**
|
||||
* SM2算法单元测试
|
||||
*
|
||||
* @author Looly, Gsealy
|
||||
*
|
||||
*/
|
||||
public class SM2Test {
|
||||
|
||||
@Test
|
||||
public void generateKeyPairTest() {
|
||||
KeyPair pair = SecureUtil.generateKeyPair("SM2");
|
||||
Assert.assertNotNull(pair.getPrivate());
|
||||
Assert.assertNotNull(pair.getPublic());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void KeyPairOIDTest() {
|
||||
// OBJECT IDENTIFIER 1.2.156.10197.1.301
|
||||
String OID = "06082A811CCF5501822D";
|
||||
KeyPair pair = SecureUtil.generateKeyPair("SM2");
|
||||
Assert.assertTrue(HexUtil.encodeHexStr(pair.getPrivate().getEncoded()).toUpperCase().contains(OID));
|
||||
Assert.assertTrue(HexUtil.encodeHexStr(pair.getPublic().getEncoded()).toUpperCase().contains(OID));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sm2CustomKeyTest() {
|
||||
KeyPair pair = SecureUtil.generateKeyPair("SM2");
|
||||
byte[] privateKey = pair.getPrivate().getEncoded();
|
||||
byte[] publicKey = pair.getPublic().getEncoded();
|
||||
|
||||
SM2 sm2 = SmUtil.sm2(privateKey, publicKey);
|
||||
sm2.setMode(SM2Mode.C1C3C2);
|
||||
|
||||
// 公钥加密,私钥解密
|
||||
byte[] encrypt = sm2.encrypt(StrUtil.bytes("我是一段测试aaaa", CharsetUtil.CHARSET_UTF_8), KeyType.PublicKey);
|
||||
byte[] decrypt = sm2.decrypt(encrypt, KeyType.PrivateKey);
|
||||
Assert.assertEquals("我是一段测试aaaa", StrUtil.str(decrypt, CharsetUtil.CHARSET_UTF_8));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sm2Test() {
|
||||
final SM2 sm2 = SmUtil.sm2();
|
||||
|
||||
// 获取私钥和公钥
|
||||
Assert.assertNotNull(sm2.getPrivateKey());
|
||||
Assert.assertNotNull(sm2.getPrivateKeyBase64());
|
||||
Assert.assertNotNull(sm2.getPublicKey());
|
||||
Assert.assertNotNull(sm2.getPrivateKeyBase64());
|
||||
|
||||
// 公钥加密,私钥解密
|
||||
byte[] encrypt = sm2.encrypt(StrUtil.bytes("我是一段测试aaaa", CharsetUtil.CHARSET_UTF_8), KeyType.PublicKey);
|
||||
byte[] decrypt = sm2.decrypt(encrypt, KeyType.PrivateKey);
|
||||
Assert.assertEquals("我是一段测试aaaa", StrUtil.str(decrypt, CharsetUtil.CHARSET_UTF_8));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sm2BcdTest() {
|
||||
String text = "我是一段测试aaaa";
|
||||
|
||||
final SM2 sm2 = SmUtil.sm2();
|
||||
|
||||
// 公钥加密,私钥解密
|
||||
String encryptStr = sm2.encryptBcd(text, KeyType.PublicKey);
|
||||
String decryptStr = StrUtil.utf8Str(sm2.decryptFromBcd(encryptStr, KeyType.PrivateKey));
|
||||
Assert.assertEquals(text, decryptStr);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sm2Base64Test() {
|
||||
String textBase = "我是一段特别长的测试";
|
||||
String text = "";
|
||||
for (int i = 0; i < 100; i++) {
|
||||
text += textBase;
|
||||
}
|
||||
|
||||
final SM2 sm2 = new SM2();
|
||||
|
||||
// 公钥加密,私钥解密
|
||||
String encryptStr = sm2.encryptBase64(text, KeyType.PublicKey);
|
||||
String decryptStr = StrUtil.utf8Str(sm2.decrypt(encryptStr, KeyType.PrivateKey));
|
||||
Assert.assertEquals(text, decryptStr);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sm2SignAndVerifyTest() {
|
||||
String content = "我是Hanley.";
|
||||
|
||||
final SM2 sm2 = SmUtil.sm2();
|
||||
|
||||
byte[] sign = sm2.sign(content.getBytes());
|
||||
boolean verify = sm2.verify(content.getBytes(), sign);
|
||||
Assert.assertTrue(verify);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sm2SignAndVerifyUseKeyTest() {
|
||||
String content = "我是Hanley.";
|
||||
|
||||
KeyPair pair = SecureUtil.generateKeyPair("SM2");
|
||||
|
||||
final SM2 sm2 = new SM2(//
|
||||
HexUtil.encodeHexStr(pair.getPrivate().getEncoded()), //
|
||||
HexUtil.encodeHexStr(pair.getPublic().getEncoded())//
|
||||
);
|
||||
|
||||
byte[] sign = sm2.sign(content.getBytes());
|
||||
boolean verify = sm2.verify(content.getBytes(), sign);
|
||||
Assert.assertTrue(verify);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sm2PublicKeyEncodeDecodeTest() {
|
||||
KeyPair pair = SecureUtil.generateKeyPair("SM2");
|
||||
PublicKey publicKey = pair.getPublic();
|
||||
byte[] data = KeyUtil.encodeECPublicKey(publicKey);
|
||||
String encodeHex = HexUtil.encodeHexStr(data);
|
||||
String encodeB64 = Base64.encode(data);
|
||||
PublicKey Hexdecode = KeyUtil.decodeECPoint(encodeHex, KeyUtil.SM2_DEFAULT_CURVE);
|
||||
PublicKey B64decode = KeyUtil.decodeECPoint(encodeB64, KeyUtil.SM2_DEFAULT_CURVE);
|
||||
Assert.assertEquals(HexUtil.encodeHexStr(publicKey.getEncoded()), HexUtil.encodeHexStr(Hexdecode.getEncoded()));
|
||||
Assert.assertEquals(HexUtil.encodeHexStr(publicKey.getEncoded()), HexUtil.encodeHexStr(B64decode.getEncoded()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package cn.hutool.crypto.test;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import cn.hutool.crypto.asymmetric.Sign;
|
||||
import cn.hutool.crypto.asymmetric.SignAlgorithm;
|
||||
|
||||
/**
|
||||
* 签名单元测试
|
||||
*
|
||||
* @author looly
|
||||
*
|
||||
*/
|
||||
public class SignTest {
|
||||
|
||||
@Test
|
||||
public void signAndVerifyUseKeyTest() {
|
||||
String content = "我是Hanley.";
|
||||
|
||||
String privateKey = "MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAJ4fG8vJ0tzu7tjXMSJhyNjlE5B7GkTKMKEQlR6LY3IhIhMFVjuA6W+DqH1VMxl9h3GIM4yCKG2VRZEYEPazgVxa5/ifO8W0pfmrzWCPrddUq4t0Slz5u2lLKymLpPjCzboHoDb8VlF+1HOxjKQckAXq9q7U7dV5VxOzJDuZXlz3AgMBAAECgYABo2LfVqT3owYYewpIR+kTzjPIsG3SPqIIWSqiWWFbYlp/BfQhw7EndZ6+Ra602ecYVwfpscOHdx90ZGJwm+WAMkKT4HiWYwyb0ZqQzRBGYDHFjPpfCBxrzSIJ3QL+B8c8YHq4HaLKRKmq7VUF1gtyWaek87rETWAmQoGjt8DyAQJBAOG4OxsT901zjfxrgKwCv6fV8wGXrNfDSViP1t9r3u6tRPsE6Gli0dfMyzxwENDTI75sOEAfyu6xBlemQGmNsfcCQQCzVWQkl9YUoVDWEitvI5MpkvVKYsFLRXKvLfyxLcY3LxpLKBcEeJ/n5wLxjH0GorhJMmM2Rw3hkjUTJCoqqe0BAkATt8FKC0N2O5ryqv1xiUfuxGzW/cX2jzOwDdiqacTuuqok93fKBPzpyhUS8YM2iss7jj6Xs29JzKMOMxK7ZcpfAkAf21lwzrAu9gEgJhYlJhKsXfjJAAYKUwnuaKLs7o65mtp242ZDWxI85eK1+hjzptBJ4HOTXsfufESFY/VBovIBAkAltO886qQRoNSc0OsVlCi4X1DGo6x2RqQ9EsWPrxWEZGYuyEdODrc54b8L+zaUJLfMJdsCIHEUbM7WXxvFVXNv";
|
||||
Sign sign = SecureUtil.sign(SignAlgorithm.SHA1withRSA, privateKey, null);
|
||||
Assert.assertNull(sign.getPublicKeyBase64());
|
||||
// 签名
|
||||
byte[] signed = sign.sign(content.getBytes());
|
||||
|
||||
String publicKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCeHxvLydLc7u7Y1zEiYcjY5ROQexpEyjChEJUei2NyISITBVY7gOlvg6h9VTMZfYdxiDOMgihtlUWRGBD2s4FcWuf4nzvFtKX5q81gj63XVKuLdEpc+btpSyspi6T4ws26B6A2/FZRftRzsYykHJAF6vau1O3VeVcTsyQ7mV5c9wIDAQAB";
|
||||
sign = SecureUtil.sign(SignAlgorithm.SHA1withRSA, null, publicKey);
|
||||
// 验证签名
|
||||
boolean verify = sign.verify(content.getBytes(), signed);
|
||||
Assert.assertTrue(verify);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void signAndVerifyTest() {
|
||||
signAndVerify(SignAlgorithm.NONEwithRSA);
|
||||
signAndVerify(SignAlgorithm.MD2withRSA);
|
||||
signAndVerify(SignAlgorithm.MD5withRSA);
|
||||
|
||||
signAndVerify(SignAlgorithm.SHA1withRSA);
|
||||
signAndVerify(SignAlgorithm.SHA256withRSA);
|
||||
signAndVerify(SignAlgorithm.SHA384withRSA);
|
||||
signAndVerify(SignAlgorithm.SHA512withRSA);
|
||||
|
||||
signAndVerify(SignAlgorithm.NONEwithDSA);
|
||||
signAndVerify(SignAlgorithm.SHA1withDSA);
|
||||
|
||||
signAndVerify(SignAlgorithm.NONEwithECDSA);
|
||||
signAndVerify(SignAlgorithm.SHA1withECDSA);
|
||||
signAndVerify(SignAlgorithm.SHA1withECDSA);
|
||||
signAndVerify(SignAlgorithm.SHA256withECDSA);
|
||||
signAndVerify(SignAlgorithm.SHA384withECDSA);
|
||||
signAndVerify(SignAlgorithm.SHA512withECDSA);
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试各种算法的签名和验证签名
|
||||
*
|
||||
* @param signAlgorithm 算法
|
||||
*/
|
||||
private void signAndVerify(SignAlgorithm signAlgorithm) {
|
||||
byte[] data = StrUtil.utf8Bytes("我是一段测试ab");
|
||||
Sign sign = SecureUtil.sign(signAlgorithm);
|
||||
|
||||
// 签名
|
||||
byte[] signed = sign.sign(data);
|
||||
|
||||
// 验证签名
|
||||
boolean verify = sign.verify(data, signed);
|
||||
Assert.assertTrue(verify);
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试MD5withRSA算法的签名和验证签名
|
||||
*/
|
||||
@Test
|
||||
public void signAndVerify2() {
|
||||
String str = "wx2421b1c4370ec43b 支付测试 JSAPI支付测试 10000100 1add1a30ac87aa2db72f57a2375d8fec http://wxpay.wxutil.com/pub_v2/pay/notify.v2.php oUpF8uMuAJO_M2pxb1Q9zNjWeS6o 1415659990 14.23.150.211 1 JSAPI 0CB01533B8C1EF103065174F50BCA001";
|
||||
byte[] data = StrUtil.utf8Bytes(str);
|
||||
Sign sign = SecureUtil.sign(SignAlgorithm.MD5withRSA);
|
||||
|
||||
// 签名
|
||||
byte[] signed = sign.sign(data);
|
||||
|
||||
// 验证签名
|
||||
boolean verify = sign.verify(data, signed);
|
||||
Assert.assertTrue(verify);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package cn.hutool.crypto.test;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.crypto.SmUtil;
|
||||
import cn.hutool.crypto.digest.HMac;
|
||||
import cn.hutool.crypto.symmetric.SymmetricCrypto;
|
||||
|
||||
/**
|
||||
* SM单元测试
|
||||
*
|
||||
* @author looly
|
||||
*
|
||||
*/
|
||||
public class SmTest {
|
||||
|
||||
@Test
|
||||
public void sm3Test() {
|
||||
String digestHex = SmUtil.sm3("aaaaa");
|
||||
Assert.assertEquals("136ce3c86e4ed909b76082055a61586af20b4dab674732ebd4b599eef080c9be", digestHex);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sm4Test() {
|
||||
String content = "test中文";
|
||||
SymmetricCrypto sm4 = SmUtil.sm4();
|
||||
|
||||
String encryptHex = sm4.encryptHex(content);
|
||||
String decryptStr = sm4.decryptStr(encryptHex, CharsetUtil.CHARSET_UTF_8);
|
||||
Assert.assertEquals(content, decryptStr);
|
||||
}
|
||||
@Test
|
||||
public void sm4Test2() {
|
||||
String content = "test中文";
|
||||
SymmetricCrypto sm4 = new SymmetricCrypto("SM4/ECB/PKCS5Padding");
|
||||
|
||||
String encryptHex = sm4.encryptHex(content);
|
||||
String decryptStr = sm4.decryptStr(encryptHex, CharsetUtil.CHARSET_UTF_8);
|
||||
Assert.assertEquals(content, decryptStr);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hmacSm3Test() {
|
||||
String content = "test中文";
|
||||
HMac hMac = SmUtil.hmacSm3("password".getBytes());
|
||||
String digest = hMac.digestHex(content);
|
||||
Assert.assertEquals("493e3f9a1896b43075fbe54658076727960d69632ac6b6ed932195857a6840c6", digest);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,210 @@
|
||||
package cn.hutool.crypto.test;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.crypto.KeyUtil;
|
||||
import cn.hutool.crypto.Mode;
|
||||
import cn.hutool.crypto.Padding;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import cn.hutool.crypto.symmetric.AES;
|
||||
import cn.hutool.crypto.symmetric.DES;
|
||||
import cn.hutool.crypto.symmetric.DESede;
|
||||
import cn.hutool.crypto.symmetric.SymmetricAlgorithm;
|
||||
import cn.hutool.crypto.symmetric.SymmetricCrypto;
|
||||
import cn.hutool.crypto.symmetric.Vigenere;
|
||||
|
||||
/**
|
||||
* 对称加密算法单元测试
|
||||
*
|
||||
* @author Looly
|
||||
*
|
||||
*/
|
||||
public class SymmetricTest {
|
||||
|
||||
@Test
|
||||
public void aesTest() {
|
||||
String content = "test中文";
|
||||
|
||||
// 随机生成密钥
|
||||
byte[] key = KeyUtil.generateKey(SymmetricAlgorithm.AES.getValue()).getEncoded();
|
||||
|
||||
// 构建
|
||||
SymmetricCrypto aes = new SymmetricCrypto(SymmetricAlgorithm.AES, key);
|
||||
|
||||
// 加密
|
||||
byte[] encrypt = aes.encrypt(content);
|
||||
// 解密
|
||||
byte[] decrypt = aes.decrypt(encrypt);
|
||||
|
||||
Assert.assertEquals(content, StrUtil.str(decrypt, CharsetUtil.CHARSET_UTF_8));
|
||||
|
||||
// 加密为16进制表示
|
||||
String encryptHex = aes.encryptHex(content);
|
||||
// 解密为字符串
|
||||
String decryptStr = aes.decryptStr(encryptHex, CharsetUtil.CHARSET_UTF_8);
|
||||
|
||||
Assert.assertEquals(content, decryptStr);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aesTest2() {
|
||||
String content = "test中文";
|
||||
|
||||
// 随机生成密钥
|
||||
byte[] key = KeyUtil.generateKey(SymmetricAlgorithm.AES.getValue()).getEncoded();
|
||||
|
||||
// 构建
|
||||
AES aes = SecureUtil.aes(key);
|
||||
|
||||
// 加密
|
||||
byte[] encrypt = aes.encrypt(content);
|
||||
// 解密
|
||||
byte[] decrypt = aes.decrypt(encrypt);
|
||||
|
||||
Assert.assertEquals(content, StrUtil.utf8Str(decrypt));
|
||||
|
||||
// 加密为16进制表示
|
||||
String encryptHex = aes.encryptHex(content);
|
||||
// 解密为字符串
|
||||
String decryptStr = aes.decryptStr(encryptHex, CharsetUtil.CHARSET_UTF_8);
|
||||
|
||||
Assert.assertEquals(content, decryptStr);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aesTest3() {
|
||||
String content = "test中文aaaaaaaaaaaaaaaaaaaaa";
|
||||
|
||||
AES aes = new AES(Mode.CTS, Padding.PKCS5Padding, "0CoJUm6Qyw8W8jud".getBytes(), "0102030405060708".getBytes());
|
||||
|
||||
// 加密
|
||||
byte[] encrypt = aes.encrypt(content);
|
||||
// 解密
|
||||
byte[] decrypt = aes.decrypt(encrypt);
|
||||
|
||||
Assert.assertEquals(content, StrUtil.utf8Str(decrypt));
|
||||
|
||||
// 加密为16进制表示
|
||||
String encryptHex = aes.encryptHex(content);
|
||||
// 解密为字符串
|
||||
String decryptStr = aes.decryptStr(encryptHex, CharsetUtil.CHARSET_UTF_8);
|
||||
|
||||
Assert.assertEquals(content, decryptStr);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aesTest4() {
|
||||
String content = "4321c9a2db2e6b08987c3b903d8d11ff";
|
||||
AES aes = new AES(Mode.CBC, Padding.PKCS5Padding, "0123456789ABHAEQ".getBytes(), "DYgjCEIMVrj2W9xN".getBytes());
|
||||
|
||||
// 加密为16进制表示
|
||||
String encryptHex = aes.encryptHex(content);
|
||||
|
||||
Assert.assertEquals("cd0e3a249eaf0ed80c330338508898c4bddcfd665a1b414622164a273ca5daf7b4ebd2c00aaa66b84dd0a237708dac8e", encryptHex);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void desTest() {
|
||||
String content = "test中文";
|
||||
|
||||
byte[] key = SecureUtil.generateKey(SymmetricAlgorithm.DES.getValue()).getEncoded();
|
||||
|
||||
SymmetricCrypto des = new SymmetricCrypto(SymmetricAlgorithm.DES, key);
|
||||
byte[] encrypt = des.encrypt(content);
|
||||
byte[] decrypt = des.decrypt(encrypt);
|
||||
|
||||
Assert.assertEquals(content, StrUtil.utf8Str(decrypt));
|
||||
|
||||
String encryptHex = des.encryptHex(content);
|
||||
String decryptStr = des.decryptStr(encryptHex);
|
||||
|
||||
Assert.assertEquals(content, decryptStr);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void desTest2() {
|
||||
String content = "test中文";
|
||||
|
||||
byte[] key = SecureUtil.generateKey(SymmetricAlgorithm.DES.getValue()).getEncoded();
|
||||
|
||||
DES des = SecureUtil.des(key);
|
||||
byte[] encrypt = des.encrypt(content);
|
||||
byte[] decrypt = des.decrypt(encrypt);
|
||||
|
||||
Assert.assertEquals(content, StrUtil.utf8Str(decrypt));
|
||||
|
||||
String encryptHex = des.encryptHex(content);
|
||||
String decryptStr = des.decryptStr(encryptHex);
|
||||
|
||||
Assert.assertEquals(content, decryptStr);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void desTest3() {
|
||||
String content = "test中文";
|
||||
|
||||
DES des = new DES(Mode.CTS, Padding.PKCS5Padding, "0CoJUm6Qyw8W8jud".getBytes(), "01020304".getBytes());
|
||||
|
||||
byte[] encrypt = des.encrypt(content);
|
||||
byte[] decrypt = des.decrypt(encrypt);
|
||||
|
||||
Assert.assertEquals(content, StrUtil.utf8Str(decrypt));
|
||||
|
||||
String encryptHex = des.encryptHex(content);
|
||||
String decryptStr = des.decryptStr(encryptHex);
|
||||
|
||||
Assert.assertEquals(content, decryptStr);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void desdeTest() {
|
||||
String content = "test中文";
|
||||
|
||||
byte[] key = SecureUtil.generateKey(SymmetricAlgorithm.DESede.getValue()).getEncoded();
|
||||
|
||||
DESede des = SecureUtil.desede(key);
|
||||
|
||||
byte[] encrypt = des.encrypt(content);
|
||||
byte[] decrypt = des.decrypt(encrypt);
|
||||
|
||||
Assert.assertEquals(content, StrUtil.utf8Str(decrypt));
|
||||
|
||||
String encryptHex = des.encryptHex(content);
|
||||
String decryptStr = des.decryptStr(encryptHex);
|
||||
|
||||
Assert.assertEquals(content, decryptStr);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void desdeTest2() {
|
||||
String content = "test中文";
|
||||
|
||||
byte[] key = SecureUtil.generateKey(SymmetricAlgorithm.DESede.getValue()).getEncoded();
|
||||
|
||||
DESede des = new DESede(Mode.CBC, Padding.PKCS5Padding, key, "12345678".getBytes());
|
||||
|
||||
byte[] encrypt = des.encrypt(content);
|
||||
byte[] decrypt = des.decrypt(encrypt);
|
||||
|
||||
Assert.assertEquals(content, StrUtil.utf8Str(decrypt));
|
||||
|
||||
String encryptHex = des.encryptHex(content);
|
||||
String decryptStr = des.decryptStr(encryptHex);
|
||||
|
||||
Assert.assertEquals(content, decryptStr);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void vigenereTest() {
|
||||
String content = "Wherethereisawillthereisaway";
|
||||
String key = "CompleteVictory";
|
||||
|
||||
String encrypt = Vigenere.encrypt(content, key);
|
||||
Assert.assertEquals("zXScRZ]KIOMhQjc0\\bYRXZOJK[Vi", encrypt);
|
||||
String decrypt = Vigenere.decrypt(encrypt, key);
|
||||
Assert.assertEquals(content, decrypt);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package cn.hutool.crypto.test.digest;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.crypto.digest.DigestAlgorithm;
|
||||
import cn.hutool.crypto.digest.DigestUtil;
|
||||
import cn.hutool.crypto.digest.Digester;
|
||||
|
||||
/**
|
||||
* 摘要算法单元测试
|
||||
* @author Looly
|
||||
*
|
||||
*/
|
||||
public class DigestTest {
|
||||
|
||||
@Test
|
||||
public void digesterTest(){
|
||||
String testStr = "test中文";
|
||||
|
||||
Digester md5 = new Digester(DigestAlgorithm.MD5);
|
||||
String digestHex = md5.digestHex(testStr);
|
||||
Assert.assertEquals("5393554e94bf0eb6436f240a4fd71282", digestHex);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void md5Test(){
|
||||
String testStr = "test中文";
|
||||
|
||||
String md5Hex1 = DigestUtil.md5Hex(testStr);
|
||||
Assert.assertEquals("5393554e94bf0eb6436f240a4fd71282", md5Hex1);
|
||||
|
||||
String md5Hex2 = DigestUtil.md5Hex(IoUtil.toStream(testStr, CharsetUtil.CHARSET_UTF_8));
|
||||
Assert.assertEquals("5393554e94bf0eb6436f240a4fd71282", md5Hex2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void md5WithSaltTest(){
|
||||
String testStr = "test中文";
|
||||
|
||||
Digester md5 = new Digester(DigestAlgorithm.MD5);
|
||||
|
||||
//加盐
|
||||
md5.setSalt("saltTest".getBytes());
|
||||
String md5Hex1 = md5.digestHex(testStr);
|
||||
Assert.assertEquals("762f7335200299dfa09bebbb601a5bc6", md5Hex1);
|
||||
String md5Hex2 = md5.digestHex(IoUtil.toUtf8Stream(testStr));
|
||||
Assert.assertEquals("762f7335200299dfa09bebbb601a5bc6", md5Hex2);
|
||||
|
||||
//重复2次
|
||||
md5.setDigestCount(2);
|
||||
String md5Hex3 = md5.digestHex(testStr);
|
||||
Assert.assertEquals("2b0616296f6755d25efc07f90afe9684", md5Hex3);
|
||||
String md5Hex4 = md5.digestHex(IoUtil.toUtf8Stream(testStr));
|
||||
Assert.assertEquals("2b0616296f6755d25efc07f90afe9684", md5Hex4);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sha1Test(){
|
||||
String testStr = "test中文";
|
||||
|
||||
String sha1Hex1 = DigestUtil.sha1Hex(testStr);
|
||||
Assert.assertEquals("ecabf586cef0d3b11c56549433ad50b81110a836", sha1Hex1);
|
||||
|
||||
String sha1Hex2 = DigestUtil.sha1Hex(IoUtil.toStream(testStr, CharsetUtil.CHARSET_UTF_8));
|
||||
Assert.assertEquals("ecabf586cef0d3b11c56549433ad50b81110a836", sha1Hex2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hash256Test() {
|
||||
String testStr = "Test中文";
|
||||
String hex = DigestUtil.sha256Hex(testStr);
|
||||
Assert.assertEquals(64, hex.length());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package cn.hutool.crypto.test.digest;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import cn.hutool.crypto.digest.MD5;
|
||||
|
||||
/**
|
||||
* MD5 单元测试
|
||||
*
|
||||
* @author Looly
|
||||
*
|
||||
*/
|
||||
public class Md5Test {
|
||||
|
||||
@Test
|
||||
public void md5To16Test() {
|
||||
String hex16 = new MD5().digestHex16("中国");
|
||||
Assert.assertEquals(16, hex16.length());
|
||||
Assert.assertEquals("cb143acd6c929826", hex16);
|
||||
}
|
||||
}
|
||||
15
hutool-crypto/src/test/resources/test_private_key.pem
Normal file
15
hutool-crypto/src/test/resources/test_private_key.pem
Normal file
@@ -0,0 +1,15 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIICXgIBAAKBgQC3G09zGCmlMetvNaWiHbp9d8jItkj5ik0wKcn7jBy/eOdlno5m
|
||||
y+eijTP/KX8D2QNj2vlF+31/AThYoxI80qUZ3imw8vDVc0cBeGLxEDLVweCQEy7C
|
||||
ivpkmEWCeyoqThenrwONoIjajG7ZJggFTrsXHL6HsbkGxYrABG2PmQ/w0QIDAQAB
|
||||
AoGBAIxvTcggSBCC8OciZh6oXlfMfxoxdFavU/QUmO1s0L+pow+1Q9JjoQxy7+ZL
|
||||
lTcGQitbzsN11xKJhQW2TE6J4EVimJZQSAE4DDmYpMOrkjnBQhkUlaZkkukvDSRS
|
||||
JqwBI/04G7se+RouHyXjRS9U76HnPM8+/IS2h+T6CbXLOpYBAkEA2j0JmyGVs+WV
|
||||
I9sG5glamJqTBa4CfTORrdFW4EULoGkUc24ZFFqn9W4e5yfl/pCkPptCenvIrAWp
|
||||
/ymnHeLn6QJBANbKGO9uBizAt4+o+kHYdANcbU/Cs3PLj8yOOtjkuMbH4tPNQmB6
|
||||
/u3npiVk7/Txfkg0BjRzDDZib109eKbvGKkCQBgMneBghRS7+gFng40Z/sfOUOFR
|
||||
WajeY/FZnk88jJlyuvQ1b8IUc2nSZslmViwFWHQlu9+vgF+kiCU8O9RJSvECQQCl
|
||||
Vkx7giYerPqgC2MY7JXhQHSkwSuCJ2A6BgImk2npGlTw1UATJJq4Z2jtwBU2Z+7d
|
||||
ha6BEU6FTqCLFZaaadKBAkEAxko4hrgBsX9BKpFJE3aUIUcMTJfJQdiAhq0k4DV8
|
||||
5GVrcp8zl6mUTPZDaOmDhuAjGdAQJqj0Xo0PZ0fOZPtR+w==
|
||||
-----END RSA PRIVATE KEY-----
|
||||
15
hutool-crypto/src/test/resources/test_public_key.csr
Normal file
15
hutool-crypto/src/test/resources/test_public_key.csr
Normal file
@@ -0,0 +1,15 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIICYTCCAcoCCQCs45mePIbzRTANBgkqhkiG9w0BAQUFADB1MQswCQYDVQQGEwJV
|
||||
UzENMAsGA1UECAwETWFyczETMBEGA1UEBwwKaVRyYW5zd2FycDETMBEGA1UECgwK
|
||||
aVRyYW5zd2FycDETMBEGA1UECwwKaVRyYW5zd2FycDEYMBYGA1UEAwwPd3d3LjU5
|
||||
MXdpZmkuY29tMB4XDTE4MTAxNzAyMTA0OFoXDTI4MTAxNDAyMTA0OFowdTELMAkG
|
||||
A1UEBhMCVVMxDTALBgNVBAgMBE1hcnMxEzARBgNVBAcMCmlUcmFuc3dhcnAxEzAR
|
||||
BgNVBAoMCmlUcmFuc3dhcnAxEzARBgNVBAsMCmlUcmFuc3dhcnAxGDAWBgNVBAMM
|
||||
D3d3dy41OTF3aWZpLmNvbTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAtxtP
|
||||
cxgppTHrbzWloh26fXfIyLZI+YpNMCnJ+4wcv3jnZZ6OZsvnoo0z/yl/A9kDY9r5
|
||||
Rft9fwE4WKMSPNKlGd4psPLw1XNHAXhi8RAy1cHgkBMuwor6ZJhFgnsqKk4Xp68D
|
||||
jaCI2oxu2SYIBU67Fxy+h7G5BsWKwARtj5kP8NECAwEAATANBgkqhkiG9w0BAQUF
|
||||
AAOBgQC2Pko8q1NicJ0oPuhFTPm7n03LtPhCaV/aDf3mqtGxraYifg8iFTxVyZ1c
|
||||
ol0eEJFsibrQrPEwdSuSVqzwif5Tab9dV92PPFm+Sq0D1Uc0xI4ziXQ+a55K9wrV
|
||||
TKXxS48TOpnTA8fVFNkUkFNB54Lhh9AwKsx123kJmyaWccbt9Q==
|
||||
-----END CERTIFICATE-----
|
||||
Reference in New Issue
Block a user