diff --git a/Zadanie-03/.idea/vcs.xml b/Zadanie-03/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/Zadanie-03/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Zadanie-03/src/com/tylkowski/crc/CrcTask.java b/Zadanie-03/src/com/tylkowski/crc/CrcTask.java new file mode 100644 index 0000000..6791b26 --- /dev/null +++ b/Zadanie-03/src/com/tylkowski/crc/CrcTask.java @@ -0,0 +1,13 @@ +package com.tylkowski.crc; + +import java.util.Arrays; + +public class CrcTask { + private String message; + private String polyGenerator; + + public CrcTask(String message) { + this.message = message; + this.polyGenerator = "10001000000100001"; + } +} diff --git a/Zadanie-03/src/com/tylkowski/crc/Main.java b/Zadanie-03/src/com/tylkowski/crc/Main.java new file mode 100644 index 0000000..00dad62 --- /dev/null +++ b/Zadanie-03/src/com/tylkowski/crc/Main.java @@ -0,0 +1,21 @@ +package com.tylkowski.crc; + +public class Main { + + public static void main(String[] args) { + CrcTask crcTask = new CrcTask(toBinary(args[0])); + } + + private static String toBinary(String s) { + byte[] bytes = s.getBytes(); + StringBuilder binary = new StringBuilder(); + for (byte b : bytes) { + int val = b; + for (int i = 0; i < 8; i++) { + binary.append((val & 128) == 0 ? 0 : 1); + val <<= 1; + } + } + return binary.toString(); + } +}