REM:
1. 修改单测用例错误问题
This commit is contained in:
HuangXin 2020-09-27 18:36:57 +08:00
parent 17329dfe02
commit dc5a3ce852
1 changed files with 17 additions and 20 deletions

View File

@ -8,10 +8,7 @@ import org.junit.Test;
import javax.crypto.BadPaddingException; import javax.crypto.BadPaddingException;
import javax.crypto.IllegalBlockSizeException; import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException; import javax.crypto.NoSuchPaddingException;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigInteger; import java.math.BigInteger;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.security.InvalidKeyException; import java.security.InvalidKeyException;
@ -99,30 +96,30 @@ public class CryptoHelperTest {
} }
@Test @Test
public void t5_aes256EncryptionTest() throws IOException, IllegalBlockSizeException, InvalidKeyException, BadPaddingException, NoSuchAlgorithmException, NoSuchPaddingException { public void t5_aes256EncryptionTest() throws IllegalBlockSizeException, InvalidKeyException, BadPaddingException, NoSuchAlgorithmException, NoSuchPaddingException {
InputStream is = ClassLoader.getSystemResourceAsStream("git.properties"); InputStream is = ClassLoader.getSystemResourceAsStream("git.properties");
assert is != null; assert is != null;
String password = ""; String password;
String testEncValue = "hkoUV5ZWh0q1jSxMnpjovVn19Qg99HY6DD40"; String testEncValue = "hkoUV5ZWh0q1jSxMnpjovVn19Qg99HY6DD40";
String testEncValue1 = "P3mq9iSIvQcvfyfdWR8sAnfAadO"; String testEncValue1 = "P3mq9iSIvQcvfyfdWR8sAnfAadO";
String testEncValue2 = "h0K0_8u"; String testEncValue2 = "h0K0_8u";
BufferedReader reader = new BufferedReader(new InputStreamReader(is)); // BufferedReader reader = new BufferedReader(new InputStreamReader(is));
log.info("Version Information:"); // log.info("Version Information:");
while (true) { // while (true) {
String val = reader.readLine(); // String val = reader.readLine();
log.info("{}", val); // log.info("{}", val);
//
// if (val == null) {
// break;
// }
//
// if (val.startsWith("git.commit.id=")) {
// password = val.substring("git.commit.id=".length());
// }
// }
if (val == null) { password = "63debfca1d2dc72af38014a7bb6f567202cc1345" + "cmcc@10086!";
break;
}
if (val.startsWith("git.commit.id=")) {
password = val.substring("git.commit.id=".length());
}
}
password = password + "cmcc@10086!";
byte[] encode = CryptoHelper.aes256Encryption(testEncValue.getBytes(StandardCharsets.UTF_8), password); byte[] encode = CryptoHelper.aes256Encryption(testEncValue.getBytes(StandardCharsets.UTF_8), password);
Assert.assertEquals(CryptoHelper.base64Encryption(encode), "Trf2LEETes3oKnY1CF7LINcm2KlJbJxHIyvERz2174CTzQEhJtuo+PnO+fR3eDf+"); Assert.assertEquals(CryptoHelper.base64Encryption(encode), "Trf2LEETes3oKnY1CF7LINcm2KlJbJxHIyvERz2174CTzQEhJtuo+PnO+fR3eDf+");