Fix CTR decryption.
Off by one error in respect to the y blocks.
This commit is contained in:
parent
e04a341fc6
commit
e1c2d7df7d
7 changed files with 105 additions and 45 deletions
|
@ -2,9 +2,9 @@ package ch.fhnw.kry;
|
|||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static ch.fhnw.kry.Main.CHIFFRE;
|
||||
import static ch.fhnw.kry.Main.CIPHER;
|
||||
import static ch.fhnw.kry.Main.KEY;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
class DecryptTest {
|
||||
|
||||
|
@ -12,7 +12,8 @@ class DecryptTest {
|
|||
void strToArray() {
|
||||
var decrypt = new Decrypt();
|
||||
|
||||
String input = "00000100110100100000101110111000000000101000111110001110011111110110000001010001010000111010000000010011011001110010101110110000";
|
||||
String input =
|
||||
"00000100110100100000101110111000000000101000111110001110011111110110000001010001010000111010000000010011011001110010101110110000";
|
||||
int[] data = decrypt.strToArray(input);
|
||||
|
||||
assertEquals(8, data.length);
|
||||
|
@ -23,6 +24,6 @@ class DecryptTest {
|
|||
@Test
|
||||
void decrypt() {
|
||||
var decrypt = new Decrypt();
|
||||
String decrypted = decrypt.decrypt(KEY, CHIFFRE);
|
||||
assertEquals("Gut gemacht!", decrypt.decrypt(KEY, CIPHER));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue