start with the K function
This commit is contained in:
parent
5d32735080
commit
2a35bbbfab
8
.idea/modules/kry-spn.test.iml
Normal file
8
.idea/modules/kry-spn.test.iml
Normal 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
6
.idea/vcs.xml
Normal 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>
|
@ -5,6 +5,9 @@ package ch.fhnw.kry;
|
|||||||
*/
|
*/
|
||||||
public class Main {
|
public class Main {
|
||||||
|
|
||||||
|
private static final String KEY = "00111010100101001101011000111111";
|
||||||
|
private static final String CHIFFRE = "00000100110100100000101110111000000000101000111110001110011111110110000001010001010000111010000000010011011001110010101110110000";
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
10
src/main/java/ch/fhnw/kry/SPN.java
Normal file
10
src/main/java/ch/fhnw/kry/SPN.java
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
18
src/test/java/ch/fhnw/kry/SPNTest.java
Normal file
18
src/test/java/ch/fhnw/kry/SPNTest.java
Normal 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));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user