start with the K function

This commit is contained in:
Sebastian Hugentobler 2022-03-17 12:33:23 +01:00
parent 5d32735080
commit 2a35bbbfab
Signed by: shu
GPG Key ID: BB32CF3CA052C2F0
5 changed files with 45 additions and 0 deletions

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<module version="4">
<component name="CheckStyle-IDEA-Module">
<option name="configuration">
<map />
</option>
</component>
</module>

6
.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

View File

@ -5,6 +5,9 @@ package ch.fhnw.kry;
*/
public class Main {
private static final String KEY = "00111010100101001101011000111111";
private static final String CHIFFRE = "00000100110100100000101110111000000000101000111110001110011111110110000001010001010000111010000000010011011001110010101110110000";
public static void main(String[] args) {
}

View File

@ -0,0 +1,10 @@
package ch.fhnw.kry;
public class SPN {
public int k(int key, int i) {
i *= 4;
int mask = 0xFFFF >>> i;
return key & mask;
}
}

View File

@ -0,0 +1,18 @@
package ch.fhnw.kry;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class SPNTest {
@Test
void k() {
var spn = new SPN();
final int key = 0xFFFFFFFF;
assertEquals(0xFFFF, spn.k(key, 0));
assertEquals(0xFFFF, spn.k(key, 1));
assertEquals(0xFFFF, spn.k(key, 2));
}
}