style: format code (#4212)

close #4204
This commit is contained in:
acbin
2023-06-09 18:52:05 +08:00
committed by GitHub
parent ad03086f54
commit 00282efd8b
521 changed files with 5233 additions and 7309 deletions

View File

@@ -5,7 +5,7 @@ import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
//Test example taken from https://page.math.tu-berlin.de/~kant/teaching/hess/krypto-ws2006/des.htm
// Test example taken from https://page.math.tu-berlin.de/~kant/teaching/hess/krypto-ws2006/des.htm
public class DESTest {
DES des;
@@ -17,35 +17,40 @@ public class DESTest {
@Test
void testEncrypt() {
//given
// given
String plainText = "Your lips are smoother than vaseline\r\n";
//This is equal to c0999fdde378d7ed727da00bca5a84ee47f269a4d6438190d9d52f78f5358499828ac9b453e0e653 in hexadecimal
String expectedOutput = "11000000100110011001111111011101111000110111100011010111111" +
"011010111001001111101101000000000101111001010010110101000010011101110010001111111001" +
"001101001101001001101011001000011100000011001000011011001110101010010111101111000111" +
"101010011010110000100100110011000001010001010110010011011010001010011111000001110011001010011";
// This is equal to
// c0999fdde378d7ed727da00bca5a84ee47f269a4d6438190d9d52f78f5358499828ac9b453e0e653 in
// hexadecimal
String expectedOutput = "11000000100110011001111111011101111000110111100011010111111"
+ "011010111001001111101101000000000101111001010010110101000010011101110010001111111001"
+ "001101001101001001101011001000011100000011001000011011001110101010010111101111000111"
+ "101010011010110000100100110011000001010001010110010011011010001010011111000001110011001010011";
//when
// when
String cipherText = des.encrypt(plainText);
//then
// then
assertEquals(expectedOutput, cipherText);
}
@Test
void testDecrypt() {
//given
//This is equal to c0999fdde378d7ed727da00bca5a84ee47f269a4d6438190d9d52f78f5358499828ac9b453e0e653 in hexadecimal
String cipherText = "11000000100110011001111111011101111000110111100011010111111" +
"011010111001001111101101000000000101111001010010110101000010011101110010001111111001" +
"001101001101001001101011001000011100000011001000011011001110101010010111101111000111" +
"101010011010110000100100110011000001010001010110010011011010001010011111000001110011001010011";
String expectedOutput = "Your lips are smoother than vaseline\r\n";;
// given
// This is equal to
// c0999fdde378d7ed727da00bca5a84ee47f269a4d6438190d9d52f78f5358499828ac9b453e0e653 in
// hexadecimal
String cipherText = "11000000100110011001111111011101111000110111100011010111111"
+ "011010111001001111101101000000000101111001010010110101000010011101110010001111111001"
+ "001101001101001001101011001000011100000011001000011011001110101010010111101111000111"
+ "101010011010110000100100110011000001010001010110010011011010001010011111000001110011001010011";
String expectedOutput = "Your lips are smoother than vaseline\r\n";
;
//when
// when
String plainText = des.decrypt(cipherText);
//then
// then
assertEquals(expectedOutput, plainText);
}
}