From 4c976710f92a9596da9de906bd6e76f96c909127 Mon Sep 17 00:00:00 2001 From: Hubert Tylkowski Date: Sat, 9 Jun 2018 14:04:27 +0200 Subject: [PATCH 01/14] Zadanie 02 --- 02-Wielomiany/src/DivisionErrorException.java | 5 + 02-Wielomiany/src/Main.java | 17 +++ .../src/MultiplierNotFoundException.java | 5 + 02-Wielomiany/src/PolynomialTask.java | 134 ++++++++++++++++++ 4 files changed, 161 insertions(+) create mode 100644 02-Wielomiany/src/DivisionErrorException.java create mode 100644 02-Wielomiany/src/Main.java create mode 100644 02-Wielomiany/src/MultiplierNotFoundException.java create mode 100644 02-Wielomiany/src/PolynomialTask.java diff --git a/02-Wielomiany/src/DivisionErrorException.java b/02-Wielomiany/src/DivisionErrorException.java new file mode 100644 index 0000000..7560c50 --- /dev/null +++ b/02-Wielomiany/src/DivisionErrorException.java @@ -0,0 +1,5 @@ +public class DivisionErrorException extends Throwable { + public DivisionErrorException() { + System.out.println("Division error!"); + } +} diff --git a/02-Wielomiany/src/Main.java b/02-Wielomiany/src/Main.java new file mode 100644 index 0000000..364a9b4 --- /dev/null +++ b/02-Wielomiany/src/Main.java @@ -0,0 +1,17 @@ +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class Main { + + public static void main(String[] args) throws DivisionErrorException, MultiplierNotFoundException { + //ex input in run console : 2 "1 1 1 0 1" "0 1 1" + int n = Integer.parseInt(args[0]); + List firstPolynomial = new ArrayList<>(); + Arrays.asList(args[1].split("\\s* \\s*")).forEach(factor -> firstPolynomial.add(Integer.valueOf(factor))); + List secondPolynomial = new ArrayList<>(); + Arrays.asList(args[2].split("\\s* \\s*")).forEach(factor -> secondPolynomial.add(Integer.valueOf(factor))); + PolynomialTask polynomialTask = new PolynomialTask(n, firstPolynomial, secondPolynomial); + polynomialTask.printAllValuesToStandardOutput(); + } +} diff --git a/02-Wielomiany/src/MultiplierNotFoundException.java b/02-Wielomiany/src/MultiplierNotFoundException.java new file mode 100644 index 0000000..3a9d83b --- /dev/null +++ b/02-Wielomiany/src/MultiplierNotFoundException.java @@ -0,0 +1,5 @@ +public class MultiplierNotFoundException extends Throwable { + public MultiplierNotFoundException() { + System.out.println("DivisionError"); + } +} diff --git a/02-Wielomiany/src/PolynomialTask.java b/02-Wielomiany/src/PolynomialTask.java new file mode 100644 index 0000000..1370891 --- /dev/null +++ b/02-Wielomiany/src/PolynomialTask.java @@ -0,0 +1,134 @@ +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +public class PolynomialTask { + private int n; + + private List firstPolynomial; + private List secondPolynomial; + + public PolynomialTask(int n, List firstPoly, List secondPoly) { + this.n = n; + this.firstPolynomial = firstPoly; + this.secondPolynomial = secondPoly; + } + + public Integer[] multiplyPolynomials(List firstPolynomial, List secondPolynomial) { + int[] multiplied = new int[firstPolynomial.size() + secondPolynomial.size() - 1]; + int sizeOfFirstPoly = firstPolynomial.size(); + int sizeOfSecondPoly = secondPolynomial.size(); + for (int i = 0; i < sizeOfFirstPoly; i++) { + for (int j = 0; j < sizeOfSecondPoly; j++) + multiplied[i + j] = (multiplied[i + j] + (firstPolynomial.get(i) * secondPolynomial.get(j))) % n; + } + return Arrays.stream(multiplied).boxed().toArray(Integer[]::new); + } + + public int[] moduloDividePolynomialsReturnQuotient(List firstPoly, List secondPoly) throws MultiplierNotFoundException, DivisionErrorException { + int[] quotient = new int[firstPoly.size() + secondPoly.size()]; + int firstPolyDegree = firstPoly.size() - 1; + int secondPolyDegree = secondPoly.size() - 1; + List polynomialAfterSubtract = firstPoly; + + + while (firstPolyDegree >= secondPolyDegree) { + polynomialAfterSubtract = calcQuotient(polynomialAfterSubtract, secondPoly, quotient); + firstPolyDegree = polynomialAfterSubtract.size() - 1; + } + + int[] remainder = new int[polynomialAfterSubtract.size()]; + for (int i = 0; i < polynomialAfterSubtract.size(); i++) { + remainder[i] = polynomialAfterSubtract.get(i); + } + return remainder; + } + + private List calcQuotient(List firstPoly, List secondPoly, int[] quotient) throws MultiplierNotFoundException, DivisionErrorException { + int firstPolyDegree = firstPoly.size() - 1; + int secondPolyDegree = secondPoly.size() - 1; + if (firstPolyDegree < secondPolyDegree) { + throw new DivisionErrorException(); + } + int quotientCoefficient; + if ((((float) firstPoly.get(firstPolyDegree) / (float) secondPoly.get(secondPolyDegree))) == Math.round(firstPoly.get(firstPolyDegree) / secondPoly.get(secondPolyDegree))) { + quotientCoefficient = firstPoly.get(firstPolyDegree) / secondPoly.get(secondPolyDegree); + } else { + quotientCoefficient = invElem(firstPoly.get(firstPolyDegree), secondPoly.get(secondPolyDegree)); + } + quotient[firstPolyDegree - secondPolyDegree] += quotientCoefficient; + List newPoly = generatePolyFromIndexAndValue(firstPolyDegree - secondPolyDegree, quotientCoefficient); + Integer[] multipliedPolynomials = multiplyPolynomials(newPoly, secondPoly); + List polynomialAfterFirstDivide = new ArrayList<>(Arrays.asList(multipliedPolynomials)); + + return removeUnnecessaryZeros(subtractTwoPolynomials(firstPoly, polynomialAfterFirstDivide)); + } + + private List removeUnnecessaryZeros(List polynomialAfterSubtract) { + int amountOfZeros = 0; + for (int i = polynomialAfterSubtract.size() - 1; i >= 0; i--) { + if (polynomialAfterSubtract.get(i) == 0) { + amountOfZeros++; + } else { + break; + } + } + + polynomialAfterSubtract = polynomialAfterSubtract.subList(0, polynomialAfterSubtract.size() - amountOfZeros); + return polynomialAfterSubtract; + } + + private List subtractTwoPolynomials(List firstPoly, List secondPoly) { + List subtractedPolynomial = new ArrayList<>(Collections.nCopies(firstPoly.size() + secondPoly.size(), 0)); + for (int index = firstPoly.size(); index >= 0; index--) { + if (index < secondPoly.size()) { + subtractedPolynomial.set(index, firstPoly.get(index) - secondPoly.get(index)); + parseNegativeElement(subtractedPolynomial, index); + } + } + return subtractedPolynomial; + } + + private void parseNegativeElement(List subtractedPolynomial, int index) { + while (subtractedPolynomial.get(index) < 0) + subtractedPolynomial.set(index, (subtractedPolynomial.get(index) * subtractedPolynomial.get(index)) % n); + } + + private List generatePolyFromIndexAndValue(int size, int quotientCoefficient) { + List poly = new ArrayList<>(Collections.nCopies(size + 1, 0)); + poly.set(size, quotientCoefficient); + return poly; + } + + private int invElem(int a, int b) throws MultiplierNotFoundException { + + for (int i = 0; i < n; i++) { + if (a == (b * i) % n) { + return i; + } + } + + throw new MultiplierNotFoundException(); + } + + public void printAllValuesToStandardOutput() throws DivisionErrorException, MultiplierNotFoundException { + List> values = new ArrayList<>(); + values.add(Arrays.asList(multiplyPolynomials(firstPolynomial, secondPolynomial))); + values.add(Arrays.stream(moduloDividePolynomialsReturnQuotient(firstPolynomial, secondPolynomial)).boxed().collect(Collectors.toList())); + try { + values.add(gcd(firstPolynomial, secondPolynomial)); + } catch (MultiplierNotFoundException e) { + } + System.out.println(values); + } + + private List gcd(List polyOne, List polyTwo) throws MultiplierNotFoundException, DivisionErrorException { + if (polyTwo.isEmpty()) return polyOne; + List poly = Arrays.stream(moduloDividePolynomialsReturnQuotient(polyOne, polyTwo)).boxed().collect(Collectors.toList()); + return gcd(polyTwo, poly); + + } + +} -- 2.20.1 From 966b225ba88e6b591400584a81baf9cae549988b Mon Sep 17 00:00:00 2001 From: Hubert Tylkowski Date: Tue, 19 Jun 2018 00:04:34 +0200 Subject: [PATCH 02/14] project started --- Zadanie-03/.idea/vcs.xml | 6 ++++++ Zadanie-03/src/com/tylkowski/crc/CrcTask.java | 13 ++++++++++++ Zadanie-03/src/com/tylkowski/crc/Main.java | 21 +++++++++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 Zadanie-03/.idea/vcs.xml create mode 100644 Zadanie-03/src/com/tylkowski/crc/CrcTask.java create mode 100644 Zadanie-03/src/com/tylkowski/crc/Main.java 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(); + } +} -- 2.20.1 From 59cc5a61df3b050a982cfa7f9713d2615b2cad2e Mon Sep 17 00:00:00 2001 From: Hubert Tylkowski Date: Tue, 19 Jun 2018 00:45:51 +0200 Subject: [PATCH 03/14] poly generating & swapping --- Zadanie-03/Zadanie-03.iml | 12 +++++++ Zadanie-03/src/com/tylkowski/crc/CrcTask.java | 35 ++++++++++++++++--- 2 files changed, 42 insertions(+), 5 deletions(-) create mode 100644 Zadanie-03/Zadanie-03.iml diff --git a/Zadanie-03/Zadanie-03.iml b/Zadanie-03/Zadanie-03.iml new file mode 100644 index 0000000..d5c0743 --- /dev/null +++ b/Zadanie-03/Zadanie-03.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/Zadanie-03/src/com/tylkowski/crc/CrcTask.java b/Zadanie-03/src/com/tylkowski/crc/CrcTask.java index 6791b26..cf67b17 100644 --- a/Zadanie-03/src/com/tylkowski/crc/CrcTask.java +++ b/Zadanie-03/src/com/tylkowski/crc/CrcTask.java @@ -1,13 +1,38 @@ package com.tylkowski.crc; -import java.util.Arrays; - public class CrcTask { private String message; - private String polyGenerator; + private short[] messageAsShortArray; + private short[] polyGenerator; public CrcTask(String message) { - this.message = message; - this.polyGenerator = "10001000000100001"; + this.message = message + "0000000000000000"; + convertMessageToBinaryShortArray(); + createGeneratingPoly(); + swapPolyValues(); + } + + private void convertMessageToBinaryShortArray() { + messageAsShortArray = new short[message.length()]; + for (int i = 0; i < message.length(); i++) { + if (message.charAt(i) == 48) { + messageAsShortArray[i] = 0; + } else { + messageAsShortArray[i] = 1; + } + } + } + + private void createGeneratingPoly() { + polyGenerator = new short[16]; + for (int i = 0; i < 16; i++) { + polyGenerator[i] = 0; + } + } + + private void swapPolyValues() { + for (int i = 0; i < polyGenerator.length; i++) { + messageAsShortArray[i] = (short) ((messageAsShortArray[i] + 1) % 2); + } } } -- 2.20.1 From 84c7c81153749bd03864cac7947af6447bc770cd Mon Sep 17 00:00:00 2001 From: Hubert Tylkowski Date: Wed, 20 Jun 2018 00:30:21 +0200 Subject: [PATCH 04/14] encode added! --- Zadanie-03/src/com/tylkowski/crc/CrcTask.java | 155 ++++++++++++++++-- Zadanie-03/src/com/tylkowski/crc/Main.java | 3 +- 2 files changed, 143 insertions(+), 15 deletions(-) diff --git a/Zadanie-03/src/com/tylkowski/crc/CrcTask.java b/Zadanie-03/src/com/tylkowski/crc/CrcTask.java index cf67b17..57d2e59 100644 --- a/Zadanie-03/src/com/tylkowski/crc/CrcTask.java +++ b/Zadanie-03/src/com/tylkowski/crc/CrcTask.java @@ -1,20 +1,125 @@ package com.tylkowski.crc; -public class CrcTask { +import java.util.Arrays; + +class CrcTask { private String message; private short[] messageAsShortArray; private short[] polyGenerator; + private String rawMessage; - public CrcTask(String message) { - this.message = message + "0000000000000000"; - convertMessageToBinaryShortArray(); - createGeneratingPoly(); - swapPolyValues(); + CrcTask(String message, String rawMessage) { + this.message = formatMessage(message) + "0000000000000000"; + this.rawMessage = rawMessage; + createGeneratingPolynomial(); + } + + private String formatMessage(String message) { + int firstNonZeroVal = 0; + boolean found = false; + StringBuilder validString = new StringBuilder(); + while (!found && firstNonZeroVal < message.length()) { + if (message.charAt(firstNonZeroVal) == 48) { + firstNonZeroVal++; + } else { + found = true; + } + } + + for (int i = firstNonZeroVal; i < message.length(); i++) { + if (message.charAt(i) == 48) { + validString.append(0); + } else { + validString.append(1); + } + } + StringBuilder msg = new StringBuilder(validString.toString()); + while (msg.length() % 8 != 0) { + msg.insert(0, "0"); + } + + return msg.toString(); + } + + private String generateFCS() { + while (true) { + if (messageAsShortArray[0] == 0) { + messageAsShortArray = Arrays.copyOfRange(messageAsShortArray, 1, messageAsShortArray.length); + } else { + short[] piece = Arrays.copyOfRange(messageAsShortArray, 0, Math.min(polyGenerator.length, messageAsShortArray.length)); + if (piece.length < polyGenerator.length) { + fillPolynomial(piece); + return "" + getCharFromShortArray(piece, 0, 8) + getCharFromShortArray(piece, piece.length - 8, piece.length); + } + short[] remainder = calcXOR(piece, polyGenerator); + remainder = removeUnecessaryZeros(remainder); + createMessageFromRemainderAndPartFromOldMessage(remainder, remainder.length); + } + + + } + + } + + private void createMessageFromRemainderAndPartFromOldMessage(short[] remainder, int length) { + short[] tempArr = new short[remainder.length + messageAsShortArray.length - polyGenerator.length]; + System.arraycopy(remainder, 0, tempArr, 0, length); + int diff = polyGenerator.length - remainder.length; + System.arraycopy(messageAsShortArray, length + diff, tempArr, length, messageAsShortArray.length - diff - length); + messageAsShortArray = tempArr; + } + + private short[] removeUnecessaryZeros(short[] remainder) { + int firstNonZeroVal = 0; + boolean found = false; + while (!found && firstNonZeroVal < remainder.length) { + if (remainder[firstNonZeroVal] == 0) { + firstNonZeroVal++; + } else { + found = true; + } + } + return Arrays.copyOfRange(remainder, firstNonZeroVal, remainder.length); + } + + private short[] calcXOR(short[] chunk, short[] polyGenerator) { + int a = Integer.parseInt(shortArrayToBinaryString(chunk), 2); + int b = Integer.parseInt(shortArrayToBinaryString(polyGenerator), 2); + String binaryString = Integer.toBinaryString(a ^ b); + return convertBinaryStringToShortArray(binaryString); + } + + private String shortArrayToBinaryString(short[] value) { + StringBuilder binaryString = new StringBuilder(); + for (Short a : value) { + binaryString.append(a); + } + return binaryString.toString(); + } + + private char getCharFromShortArray(short[] chunk, int from, int to) { + short[] sign = Arrays.copyOfRange(chunk, from, to); + int character = Integer.parseInt(shortArrayToBinaryString(sign), 2); +// System.out.println(character); + return (char) character; + } + + private void fillPolynomial(short[] chunk) { + while (chunk.length % 8 != 0) { + chunk = addZeroAtBeginningOfArray(chunk); + } + } + + private short[] addZeroAtBeginningOfArray(short[] chunk) { + short[] letterTemp = new short[chunk.length + 1]; + letterTemp[0] = 0; + System.arraycopy(chunk, 0, letterTemp, 1, chunk.length); + return letterTemp; } private void convertMessageToBinaryShortArray() { messageAsShortArray = new short[message.length()]; - for (int i = 0; i < message.length(); i++) { + for (int i = 0; i < polyGenerator.length; i++) { if (message.charAt(i) == 48) { messageAsShortArray[i] = 0; } else { @@ -23,16 +128,38 @@ public class CrcTask { } } - private void createGeneratingPoly() { - polyGenerator = new short[16]; - for (int i = 0; i < 16; i++) { + private short[] convertBinaryStringToShortArray(String binaryString) { + short[] shortArray = new short[binaryString.length()]; + for (int i = 0; i < binaryString.length(); i++) { + if (binaryString.charAt(i) == 48) { + shortArray[i] = 0; + } else { + shortArray[i] = 1; + } + } + return shortArray; + } + + private void createGeneratingPolynomial() { + polyGenerator = new short[17]; + for (int i = 0; i < 17; i++) { polyGenerator[i] = 0; } + polyGenerator[0] = 1; + polyGenerator[4] = 1; + polyGenerator[11] = 1; + polyGenerator[16] = 1; + } + + private void swapPolynomialValues() { + for (int i = 0; i < polyGenerator.length - 1; i++) { + messageAsShortArray[i] = (short) ((messageAsShortArray[i] + 1) % 2); + } } - private void swapPolyValues() { - for (int i = 0; i < polyGenerator.length; i++) { - messageAsShortArray[i] = (short) ((messageAsShortArray[i] + 1) % 2); - } + String encode() { + convertMessageToBinaryShortArray(); + swapPolynomialValues(); + return rawMessage + generateFCS(); } } diff --git a/Zadanie-03/src/com/tylkowski/crc/Main.java b/Zadanie-03/src/com/tylkowski/crc/Main.java index 00dad62..3cc07b8 100644 --- a/Zadanie-03/src/com/tylkowski/crc/Main.java +++ b/Zadanie-03/src/com/tylkowski/crc/Main.java @@ -3,7 +3,8 @@ package com.tylkowski.crc; public class Main { public static void main(String[] args) { - CrcTask crcTask = new CrcTask(toBinary(args[0])); + CrcTask crcTask = new CrcTask(toBinary(args[0]), args[0]); + System.out.println(crcTask.encode()); } private static String toBinary(String s) { -- 2.20.1 From 446d5f23062dd965c0b0409819c0d274a570fa79 Mon Sep 17 00:00:00 2001 From: Hubert Tylkowski Date: Wed, 20 Jun 2018 01:06:07 +0200 Subject: [PATCH 05/14] decode added! --- Zadanie-03/src/com/tylkowski/crc/CrcTask.java | 61 ++++++++++++++++--- Zadanie-03/src/com/tylkowski/crc/Main.java | 1 + 2 files changed, 53 insertions(+), 9 deletions(-) diff --git a/Zadanie-03/src/com/tylkowski/crc/CrcTask.java b/Zadanie-03/src/com/tylkowski/crc/CrcTask.java index 57d2e59..b6c9df4 100644 --- a/Zadanie-03/src/com/tylkowski/crc/CrcTask.java +++ b/Zadanie-03/src/com/tylkowski/crc/CrcTask.java @@ -53,7 +53,7 @@ class CrcTask { } short[] remainder = calcXOR(piece, polyGenerator); remainder = removeUnecessaryZeros(remainder); - createMessageFromRemainderAndPartFromOldMessage(remainder, remainder.length); + messageAsShortArray = createMessageFromRemainderAndPartFromOldMessage(remainder, messageAsShortArray); } @@ -61,12 +61,13 @@ class CrcTask { } - private void createMessageFromRemainderAndPartFromOldMessage(short[] remainder, int length) { - short[] tempArr = new short[remainder.length + messageAsShortArray.length - polyGenerator.length]; - System.arraycopy(remainder, 0, tempArr, 0, length); + private short[] createMessageFromRemainderAndPartFromOldMessage(short[] remainder, short[] msg) { + short[] tempArr = new short[remainder.length + msg.length - polyGenerator.length]; + System.arraycopy(remainder, 0, tempArr, 0, remainder.length); int diff = polyGenerator.length - remainder.length; - System.arraycopy(messageAsShortArray, length + diff, tempArr, length, messageAsShortArray.length - diff - length); - messageAsShortArray = tempArr; + System.arraycopy(msg, remainder.length + diff, tempArr, remainder.length, msg.length - diff - remainder.length); + msg = tempArr; + return msg; } private short[] removeUnecessaryZeros(short[] remainder) { @@ -151,15 +152,57 @@ class CrcTask { polyGenerator[16] = 1; } - private void swapPolynomialValues() { + private short[] swapPolynomialValues(short[] poly) { for (int i = 0; i < polyGenerator.length - 1; i++) { - messageAsShortArray[i] = (short) ((messageAsShortArray[i] + 1) % 2); + poly[i] = (short) ((poly[i] + 1) % 2); } + return poly; } String encode() { convertMessageToBinaryShortArray(); - swapPolynomialValues(); + messageAsShortArray = swapPolynomialValues(messageAsShortArray); return rawMessage + generateFCS(); } + + boolean decode(String encodedString) { + encodedString = fillPolyTo8(encodedString); + short[] encodedShortArray = convertBinaryStringToShortArray(encodedString); + encodedShortArray = swapPolynomialValues(encodedShortArray); + while (true) { + if (shortArrayContains(encodedShortArray, 1)) { + return true; + } + + if (encodedShortArray[0] == 0) { + encodedShortArray = Arrays.copyOfRange(encodedShortArray, 1, encodedShortArray.length); + } else { + short[] piece = Arrays.copyOfRange(encodedShortArray, 0, Math.min(polyGenerator.length, encodedShortArray.length)); + if (piece.length < polyGenerator.length) { + return false; + } + + short[] remainder = calcXOR(piece, polyGenerator); + remainder = removeUnecessaryZeros(remainder); + encodedShortArray = createMessageFromRemainderAndPartFromOldMessage(remainder, encodedShortArray); + } + } + } + + private boolean shortArrayContains(short[] encodedShortArray, int value) { + for (short item : encodedShortArray) { + if (item == value) { + return true; + } + } + return false; + } + + private String fillPolyTo8(String encodedString) { + StringBuilder stringBuilder = new StringBuilder(encodedString); + while (stringBuilder.length() % 8 != 0) { + stringBuilder.insert(0, "0"); + } + return stringBuilder.toString(); + } } diff --git a/Zadanie-03/src/com/tylkowski/crc/Main.java b/Zadanie-03/src/com/tylkowski/crc/Main.java index 3cc07b8..77f226e 100644 --- a/Zadanie-03/src/com/tylkowski/crc/Main.java +++ b/Zadanie-03/src/com/tylkowski/crc/Main.java @@ -5,6 +5,7 @@ public class Main { public static void main(String[] args) { CrcTask crcTask = new CrcTask(toBinary(args[0]), args[0]); System.out.println(crcTask.encode()); + System.out.println(crcTask.decode(toBinary(crcTask.encode()))); } private static String toBinary(String s) { -- 2.20.1 From 744f9793c571e9795aa61b77b966d4777f1dd69b Mon Sep 17 00:00:00 2001 From: Hubert Tylkowski Date: Wed, 20 Jun 2018 01:13:23 +0200 Subject: [PATCH 06/14] small code refactor --- Zadanie-03/src/com/tylkowski/crc/CrcTask.java | 16 ++++++++++++++- Zadanie-03/src/com/tylkowski/crc/Main.java | 20 ++++++------------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/Zadanie-03/src/com/tylkowski/crc/CrcTask.java b/Zadanie-03/src/com/tylkowski/crc/CrcTask.java index b6c9df4..7e36a45 100644 --- a/Zadanie-03/src/com/tylkowski/crc/CrcTask.java +++ b/Zadanie-03/src/com/tylkowski/crc/CrcTask.java @@ -9,11 +9,24 @@ class CrcTask { private String rawMessage; CrcTask(String message, String rawMessage) { - this.message = formatMessage(message) + "0000000000000000"; + this.message = formatMessage(toBinary(message)) + "0000000000000000"; this.rawMessage = rawMessage; createGeneratingPolynomial(); } + private 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(); + } + private String formatMessage(String message) { int firstNonZeroVal = 0; boolean found = false; @@ -166,6 +179,7 @@ class CrcTask { } boolean decode(String encodedString) { + encodedString = toBinary(encodedString); encodedString = fillPolyTo8(encodedString); short[] encodedShortArray = convertBinaryStringToShortArray(encodedString); encodedShortArray = swapPolynomialValues(encodedShortArray); diff --git a/Zadanie-03/src/com/tylkowski/crc/Main.java b/Zadanie-03/src/com/tylkowski/crc/Main.java index 77f226e..c71d643 100644 --- a/Zadanie-03/src/com/tylkowski/crc/Main.java +++ b/Zadanie-03/src/com/tylkowski/crc/Main.java @@ -3,21 +3,13 @@ package com.tylkowski.crc; public class Main { public static void main(String[] args) { - CrcTask crcTask = new CrcTask(toBinary(args[0]), args[0]); + // ex. in command line type "a" + CrcTask crcTask = new CrcTask(args[0], args[0]); System.out.println(crcTask.encode()); - System.out.println(crcTask.decode(toBinary(crcTask.encode()))); + String input = crcTask.encode(); + if (input.length() >= 3) System.out.println(crcTask.decode(input)); + } - 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(); - } + } -- 2.20.1 From 841b8b4590436f89e15bac91492cb2852824c5d0 Mon Sep 17 00:00:00 2001 From: Hubert Tylkowski Date: Wed, 20 Jun 2018 11:45:59 +0200 Subject: [PATCH 07/14] charset update --- Zadanie-03/.idea/description.html | 1 + Zadanie-03/.idea/misc.xml | 12 + Zadanie-03/.idea/modules.xml | 8 + Zadanie-03/.idea/project-template.xml | 3 + Zadanie-03/.idea/workspace.xml | 387 ++++++++++++++++++ .../com/tylkowski/crc/CrcTask.class | Bin 0 -> 6441 bytes .../Zadanie-03/com/tylkowski/crc/Main.class | Bin 0 -> 1086 bytes Zadanie-03/src/com/tylkowski/crc/CrcTask.java | 88 ++-- Zadanie-03/src/com/tylkowski/crc/Main.java | 19 +- 9 files changed, 473 insertions(+), 45 deletions(-) create mode 100644 Zadanie-03/.idea/description.html create mode 100644 Zadanie-03/.idea/misc.xml create mode 100644 Zadanie-03/.idea/modules.xml create mode 100644 Zadanie-03/.idea/project-template.xml create mode 100644 Zadanie-03/.idea/workspace.xml create mode 100644 Zadanie-03/out/production/Zadanie-03/com/tylkowski/crc/CrcTask.class create mode 100644 Zadanie-03/out/production/Zadanie-03/com/tylkowski/crc/Main.class diff --git a/Zadanie-03/.idea/description.html b/Zadanie-03/.idea/description.html new file mode 100644 index 0000000..db5f129 --- /dev/null +++ b/Zadanie-03/.idea/description.html @@ -0,0 +1 @@ +Simple Java application that includes a class with main() method \ No newline at end of file diff --git a/Zadanie-03/.idea/misc.xml b/Zadanie-03/.idea/misc.xml new file mode 100644 index 0000000..5d75313 --- /dev/null +++ b/Zadanie-03/.idea/misc.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Zadanie-03/.idea/modules.xml b/Zadanie-03/.idea/modules.xml new file mode 100644 index 0000000..5982ee3 --- /dev/null +++ b/Zadanie-03/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Zadanie-03/.idea/project-template.xml b/Zadanie-03/.idea/project-template.xml new file mode 100644 index 0000000..1f08b88 --- /dev/null +++ b/Zadanie-03/.idea/project-template.xml @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/Zadanie-03/.idea/workspace.xml b/Zadanie-03/.idea/workspace.xml new file mode 100644 index 0000000..65c30df --- /dev/null +++ b/Zadanie-03/.idea/workspace.xml @@ -0,0 +1,387 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + System.out.println + for + + System + ch + shot + gen_deg + char + swa + chunk + toBin + toBinaryStr + + + + + + + + + + + true + DEFINITION_ORDER + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - @@ -144,8 +141,7 @@ - @@ -244,11 +248,11 @@ - + - + @@ -276,9 +280,27 @@ - + + + + + + + + + + + + + + + + + @@ -366,10 +388,24 @@ + + + + + + + + + + + + + + - - + + @@ -378,8 +414,8 @@ - - + + diff --git a/Zadanie-03/src/com/tylkowski/crc/CrcTask.java b/Zadanie-03/src/com/tylkowski/crc/CrcTask.java index 74a3099..eb9a506 100644 --- a/Zadanie-03/src/com/tylkowski/crc/CrcTask.java +++ b/Zadanie-03/src/com/tylkowski/crc/CrcTask.java @@ -18,10 +18,10 @@ class CrcTask { } private void setEncoding() throws NoSuchFieldException, IllegalAccessException { - System.setProperty("file.encoding","ISO-8859-1"); + System.setProperty("file.encoding", "ISO-8859-1"); Field charset = Charset.class.getDeclaredField("defaultCharset"); charset.setAccessible(true); - charset.set(null,null); + charset.set(null, null); } private String formatMessage(String message) { @@ -65,8 +65,6 @@ class CrcTask { remainder = removeUnecessaryZeros(remainder); messageAsShortArray = createMessageFromRemainderAndPartFromOldMessage(remainder, messageAsShortArray); } - - } } @@ -111,7 +109,6 @@ class CrcTask { private char getCharFromShortArray(short[] piece, int from, int to) { short[] sign = Arrays.copyOfRange(piece, from, to); int character = Integer.parseInt(shortArrayToBinaryString(sign), 2); -// System.out.println(character); return (char) character; } @@ -165,30 +162,23 @@ class CrcTask { } private String letterToBinaryString(char letter) { -// System.out.println("lt: " + letter + " " + (int) letter); int a = (int) letter; -// if (a == 63) a = 157; - System.out.println("letter in int: " + a); - StringBuilder binaryString = new StringBuilder(Integer.toBinaryString(a)); - while (binaryString.length() % 8 != 0) { binaryString.insert(0, "0"); } -// System.out.println("bs" + binaryString.toString()); return binaryString.toString(); } boolean decode(String encodedString) { encodedString = toBinaryString(encodedString); - encodedString = fillPolyTo8(encodedString); + encodedString = fillPoly(encodedString); short[] encodedShortArray = convertBinaryStringToShortArray(encodedString); encodedShortArray = swapPolynomialValues(encodedShortArray); while (true) { if (!shortArrayContains(encodedShortArray, 1)) { return true; } - if (encodedShortArray[0] == 0) { encodedShortArray = Arrays.copyOfRange(encodedShortArray, 1, encodedShortArray.length); } else { @@ -208,7 +198,6 @@ class CrcTask { StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < encodedString.length(); i++) { stringBuilder.append(letterToBinaryString(encodedString.charAt(i))); - } return stringBuilder.toString(); } @@ -222,7 +211,7 @@ class CrcTask { return false; } - private String fillPolyTo8(String encodedString) { + private String fillPoly(String encodedString) { StringBuilder stringBuilder = new StringBuilder(encodedString); while (stringBuilder.length() % 8 != 0) { stringBuilder.insert(0, "0"); diff --git a/Zadanie-03/src/com/tylkowski/crc/Main.java b/Zadanie-03/src/com/tylkowski/crc/Main.java index 1ef0595..b85f350 100644 --- a/Zadanie-03/src/com/tylkowski/crc/Main.java +++ b/Zadanie-03/src/com/tylkowski/crc/Main.java @@ -3,10 +3,10 @@ package com.tylkowski.crc; public class Main { public static void main(String[] args) throws NoSuchFieldException, IllegalAccessException { - // use valid character encoding ISO-8859-1 - // in command line type "1" for mode and "a" for message - //example "1" "a" -> this will encode string "a" and return FCS - // example "2" "abc" -> this will decode string "abc" and return true if it is valid or false if not + // in command line type "1" for mode and "b" for message + // example "1" "b" -> this will encode string "b" and return FCS + // example "2" "bXY" -> this will decode string "bXY" and return true if it is valid or false if not + // X and Y - 1 and 2 character of FCS CrcTask crcTask = new CrcTask(args[1], args[1]); if(args[0].equals("1")) { //create FCS -- 2.20.1 From 59a44d5026c46671f7b7f59fcb73a434741473e2 Mon Sep 17 00:00:00 2001 From: Hubert Tylkowski Date: Mon, 25 Jun 2018 19:20:15 +0200 Subject: [PATCH 09/14] jar built --- .../Wielomiany/DivisionErrorException.class | Bin 0 -> 462 bytes .../out/production/Wielomiany/Main.class | Bin 0 -> 2317 bytes .../Wielomiany/MultiplierNotFoundException.class | Bin 0 -> 475 bytes .../production/Wielomiany/PolynomialTask.class | Bin 0 -> 6951 bytes 4 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 02-Wielomiany/out/production/Wielomiany/DivisionErrorException.class create mode 100644 02-Wielomiany/out/production/Wielomiany/Main.class create mode 100644 02-Wielomiany/out/production/Wielomiany/MultiplierNotFoundException.class create mode 100644 02-Wielomiany/out/production/Wielomiany/PolynomialTask.class diff --git a/02-Wielomiany/out/production/Wielomiany/DivisionErrorException.class b/02-Wielomiany/out/production/Wielomiany/DivisionErrorException.class new file mode 100644 index 0000000000000000000000000000000000000000..f464630ee826043ccf5c71cd71d77c893a85454e GIT binary patch literal 462 zcmZutO-}+b5PgM}g>?}GK@>G|0}pcXhS7uKX=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/02-Wielomiany/out/production/Wielomiany/MultiplierNotFoundException.class new file mode 100644 index 0000000000000000000000000000000000000000..d90334c35fbe1edad6c252f94e1513fa2061a3dc GIT binary patch literal 475 zcmaJ-O-}+b5PgM}g>?}G@e46}0}pcXhS7tGs*Z0RKfD0UZ$e@_RHcDBPJ?x<3V%NnUL*`N{X|EX4^~Qj~xzS_6 zPza{KooYQbF;S~(A;FkNjsI#T2I(@4y%)T+hc z^>k!Lq9bFYlQr7&2fpM!Tx4DB`#8WML;hAS<${db#%SZB>f;DChUyw0hH~uG47r*# z`%|MIlOc+KZ0~tt#f-+*k!7d^s}rf4_eLt)vqtb4y*#n`PcyjlSQIMit0#@Ci>OPg zNvkoyDK_ZC##ByK6VC()AB$we&mhzRbLtO!@WK-;cbx_r7z_ zJ?A^$Ip;o}`}dPi16YlJgwTlF%Fuw@<#C5R?kqA$(ZJ&Jd+PqT{0>RN%G{?#0Js<>T`BggoxkaldSRAcQa;l$B4)<5Qyh)1vsH z5FW-+nSMrId{)QjLRcia!njSAKQGJ2Lihr{D2IMYrjL~2IKCXhSMXI4c~r+^Iv&^Y zH4R#Ve;pbs24l%o`WicaAYqTh%(#YGox9DwW^*PTi#K=1Qt5ULWj(Q>gqhAHEe&-A zuh*z~+)NBLcO=r*kdA#r8SNG6_+jm8h;jH9is^#uy1!>~(9OkjEg2dRQp|8-O;vN-PU0i5IantKY z>}V!#Z;I`WMJ*2+*IMLPVq3;e$E-wJI8ty*5p3vh=`GnEIVx|mhLRR};^E-b()`gZ z)i(^Ltz=K8KbFPrL(>&ePv7$gbSv_aU^NqGOI2apHu;~eFpP;HCoa2TEW({+T$7MkQFb;!Mlr*FY zO)TzRfsw_9raMzyj_JvW*n6$(5(#U-N~O%?ft^;;W<-`0n$uncpBd(eok^s-2i;Ab zg`0{WTd1kH6pc%{%<0`{=i%E@c+RwN79PQ1mI(3oGdNRPt-Q*4OQFu15N9*t z(WzdWl`#=DlhN)>dNjkT;I9|&f_t6U8ZIjiakg0&w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;c5xPVl1U&%jwrjEF-kb2}T6lm;`+UKh58Rd?U2H zfll;NMt~Ly9m)cI2trGN>kz3YK+j^Zx?G?K(9InIp0fkja8$xGw)2El4A(ZEaV_O^ z2mD$BCOU-3Q`!W4CEr4M2}7NPVR>N~7!F|Jo0y^FY6hbYJroUc^CD)Kib^kMyv4au zd5tE8D05atB|i!hf}{8kMSu`*o{9i-@uEwBAdlTgvSzhfj zyN|N`l;Bh9O$Ad-x=UQRkXLj36R4U%HK~!U_Tj(-*c5h){!v^)h840f-~l2^4U?!L z2_lpn$HK7yF?p(~5QARYb{$qQ+g3BuH!{Xi&UZ7eg28Iqx0E;yIE8_hW-*9onG|=K zR88EXWP|E;szivCVuMHt8}=A}RrezAIKG*suaCK7I({l^*Jr(3?|35dT<`eqjj+5EpTzzE zja=)-c9>&+P`YN{>9Vy}Vp|pH^F*|%syb_#6AyLMPwd)>wFIlwAzph3=I*R#K)inyQhfq>;e9X^2 z^!h0*VnMBahLYZU&>nI+&W=CAF29FX-jcOaA}b9?uw9n5cNuGuvUeF}B~w&h_}_p} z3ronQ`UhzBBK{?LYf!oV3fDwapP)C6#hnci8tdm@fW?zVa}rB@xZb;Z(bT170!t@R z=i|L4Ut}E1)Y35owmy#K4JT3m7*E~6W_dl&SL|5gw9E{jd+FakzCFPAw^HIDbK@Q4 z%^}BUb(iaNJuT(CG^3zpD}h?ca78?x1K&BS@TnUKG@aVB1+RjK`{cg?=&}^LNBAot zYUBlPg@*f3((q`cfn8&oi_ap`6_LBgvRqm#8r{woa0i>~o!J0UUp6d_yk4n$KqK9g zdjM}s9vZ215Gj?sA|=VIq^6SB53M}wM6P>VvqJJAM9;;UX8uYZl`MD)x>)IRu8=`z sQC$&L;VdDza*6j7V3B$!{> Date: Mon, 25 Jun 2018 19:23:22 +0200 Subject: [PATCH 10/14] jar built --- 02-Wielomiany/src/Main.java | 6 ++++-- .../com/tylkowski/crc/CrcTask.class | Bin 6441 -> 6304 bytes Zadanie-03/src/com/tylkowski/crc/CrcTask.java | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/02-Wielomiany/src/Main.java b/02-Wielomiany/src/Main.java index 364a9b4..8a36bd9 100644 --- a/02-Wielomiany/src/Main.java +++ b/02-Wielomiany/src/Main.java @@ -8,9 +8,11 @@ public class Main { //ex input in run console : 2 "1 1 1 0 1" "0 1 1" int n = Integer.parseInt(args[0]); List firstPolynomial = new ArrayList<>(); - Arrays.asList(args[1].split("\\s* \\s*")).forEach(factor -> firstPolynomial.add(Integer.valueOf(factor))); + args[1] = args[1].substring(1, args[1].length()-1); + args[2] = args[2].substring(1, args[2].length()-1); + Arrays.asList(args[1].split( ",\\s*" )).forEach(factor -> firstPolynomial.add(Integer.valueOf(factor))); List secondPolynomial = new ArrayList<>(); - Arrays.asList(args[2].split("\\s* \\s*")).forEach(factor -> secondPolynomial.add(Integer.valueOf(factor))); + Arrays.asList(args[2].split(",\\s*" )).forEach(factor -> secondPolynomial.add(Integer.valueOf(factor))); PolynomialTask polynomialTask = new PolynomialTask(n, firstPolynomial, secondPolynomial); polynomialTask.printAllValuesToStandardOutput(); } diff --git a/Zadanie-03/out/production/Zadanie-03/com/tylkowski/crc/CrcTask.class b/Zadanie-03/out/production/Zadanie-03/com/tylkowski/crc/CrcTask.class index 88a50c3fb1b2c538781718aafc5f0b9eeca13969..cf26b3d0c1170d281d50f8a3c3a8cbf29b40c3c7 100644 GIT binary patch delta 2768 zcmZ8jcUV<*7=F*W7tX!MA8@D|#Wt4U6$?v!c-6*hc-_V_ zEEloD#v52E;!V+BC1SORl|HPoOSxGqw$|BLkGEvE!N%LzD5f|0uvykE^7%Wms}QkO z#Jl2fo9rrWyoc=~cF1w3jrZ|^XzY^XZV`J#>=m(3#D^k2vasKRallc=MejiihnymDjdV-7QRq8jxQCy!q*l~D4fJ8h0{1AUe7Az;Tr=+bA@yG zR-p}YEqtf&Jvg6dJfQB}Bb4I=zw^u5tX$Lp#3bJ6mdW7+An_T|`nwQ9Bww#2^&`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03/src/com/tylkowski/crc/CrcTask.java @@ -162,7 +162,7 @@ class CrcTask { } private String letterToBinaryString(char letter) { - int a = (int) letter; + short a = (short) letter; StringBuilder binaryString = new StringBuilder(Integer.toBinaryString(a)); while (binaryString.length() % 8 != 0) { binaryString.insert(0, "0"); -- 2.20.1 From d267883d76ed600de56387301bec73b346851bc7 Mon Sep 17 00:00:00 2001 From: Hubert Tylkowski Date: Mon, 25 Jun 2018 19:47:58 +0200 Subject: [PATCH 11/14] added jar file --- Zadanie-03/.idea/artifacts/Zadanie_03_jar.xml | 8 ++++++++ .../out/artifacts/Zadanie_03_jar/Zadanie-03.jar | Bin 0 -> 4872 bytes .../production/Zadanie-03/META-INF/MANIFEST.MF | 3 +++ Zadanie-03/src/META-INF/MANIFEST.MF | 3 +++ 4 files changed, 14 insertions(+) create mode 100644 Zadanie-03/.idea/artifacts/Zadanie_03_jar.xml create mode 100644 Zadanie-03/out/artifacts/Zadanie_03_jar/Zadanie-03.jar create mode 100644 Zadanie-03/out/production/Zadanie-03/META-INF/MANIFEST.MF create mode 100644 Zadanie-03/src/META-INF/MANIFEST.MF diff --git a/Zadanie-03/.idea/artifacts/Zadanie_03_jar.xml b/Zadanie-03/.idea/artifacts/Zadanie_03_jar.xml new file mode 100644 index 0000000..9e24508 --- /dev/null +++ b/Zadanie-03/.idea/artifacts/Zadanie_03_jar.xml @@ -0,0 +1,8 @@ + + + $PROJECT_DIR$/out/artifacts/Zadanie_03_jar + + + + + \ No newline at end of file diff --git a/Zadanie-03/out/artifacts/Zadanie_03_jar/Zadanie-03.jar b/Zadanie-03/out/artifacts/Zadanie_03_jar/Zadanie-03.jar new file mode 100644 index 0000000000000000000000000000000000000000..8bd6df9d4f5c250f5ce9bc3ee21ca9d2a86fc0ce GIT binary patch literal 4872 zcmaKw2T)Vn*2e<@3`jAw&^s1{&<)aiM>>QeiXc^bXrWiBa_LoimmUElAP^9g-bIK= zK$`R>O7p?H-#oqFyZ8OioS8kd*IIk+wa?iz>!+guB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a&!IE9mS#1fG=$B>m9xw$ z5E=y@ZPfschSC^tF)BASIdvU87xs zY|2WVS)7NZ>f!5vH$hy81k0u?PP2#40^x$;zB^@Pk!Y3zhpfWRL9+XhnpqW-cV`kk zJLs~ZLIhR!Iyr1jpyvcdu&4f`t^J6pCD(4Wq+Wt6Kyse3>079tZ;H;2k($j*#82_~ zr9I0P35JIFdu@DDNAUK71DR~F(%-d+-q6TVe{X%!i6alow{$o67hj|dgW4>s>%A`}h`G7iMMq!4`~fg6ta0D$xb zX!vKwKz#Ah{s)BUXyD;f1AY;c-$BMDG5M?hE0z&}HeUs1v?hJPZEfA+Y9 zAiq>{F}(En9f|z2?TucH0{{oypRRsV5 literal 0 HcmV?d00001 diff --git a/Zadanie-03/out/production/Zadanie-03/META-INF/MANIFEST.MF b/Zadanie-03/out/production/Zadanie-03/META-INF/MANIFEST.MF new file mode 100644 index 0000000..1cc2747 --- /dev/null +++ b/Zadanie-03/out/production/Zadanie-03/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Main-Class: com.tylkowski.crc.Main + diff --git a/Zadanie-03/src/META-INF/MANIFEST.MF b/Zadanie-03/src/META-INF/MANIFEST.MF new file mode 100644 index 0000000..1cc2747 --- /dev/null +++ b/Zadanie-03/src/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Main-Class: com.tylkowski.crc.Main + -- 2.20.1 From 4566e31834398d8026ea23d16837ed2662055770 Mon Sep 17 00:00:00 2001 From: Hubert Tylkowski Date: Wed, 27 Jun 2018 19:18:40 +0200 Subject: [PATCH 12/14] fcs visible on output --- Zadanie-03/.idea/vcs.xml | 6 ------ Zadanie-03/src/com/tylkowski/crc/.Main.java.swp | Bin 0 -> 12288 bytes 2 files changed, 6 deletions(-) delete mode 100644 Zadanie-03/.idea/vcs.xml create mode 100644 Zadanie-03/src/com/tylkowski/crc/.Main.java.swp diff --git a/Zadanie-03/.idea/vcs.xml b/Zadanie-03/.idea/vcs.xml deleted file mode 100644 index 6c0b863..0000000 --- a/Zadanie-03/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/Zadanie-03/src/com/tylkowski/crc/.Main.java.swp b/Zadanie-03/src/com/tylkowski/crc/.Main.java.swp new file mode 100644 index 0000000000000000000000000000000000000000..714621d151bd5b5f8867a6c67a6a5ab6f4050fb9 GIT binary patch literal 12288 zcmeI2L2uJA6vy42H<$o%ew0fitx3CHkfu$VHU^b8E(NqPO~Q5D*3@-E?6j+3aNwix zSvbRmZ!oSqf*2QG(zJ9#8aE`wv-Iz4Z0G&o`z4pEZr7eR_u!siXE>G_JNwW$ES=wC zud9qbOxrSX*}~PMm$q$WuHKWazL_Kpwx#X6C=NDtSGE&gea1s>6c4sHcOUFFYr*7N zR%?yGCL$2gAaG;dk4Cny0)aDoTp9lbAM!tY(hed(1f~R*SYx$b%dYO0@4(F)Po@hL zi2xBG0z`la5CI}U1c(3;_zwuUxWwLKp9@8=w~JW16pKp=M1Tko0U|&IhyW2F0z`la z5CI}U1c<;tNPvfoy<24L8!G$%fBO6X%XP+1QJ+vBQ3h2-onB*XgleLeQD;kxeMY@U zjZx20i>L)u3H1Z>o}<1O9$zyb8bp8y5CI}U1c(3;AOb{y2oQn4N8kjl00+h_WaEV8 zq4-c8sPLp~59>$1mZs}^6%RJnq2WPmY@HnVQR@6SQO0Rg!9&T9x$XO*6j3OrH+tUM zg`7bEq9;WkI>OEtPC#laVdhsm^5x5vYg;L=mOT$%&30y$UEwWF?)|%|NF;X>cD7ox zRH`$nan7uM(QIqd5fq)lIv6>EVs_f#3KWRu8pS5}ftwHxpbGW;+bXur6E2)gAnIHw z1b540K8UphY!}My{ev=8H^B9jg^|)4CP=|LMBObmWa$&>(!_vE(j1<0fOibJRv| Date: Wed, 27 Jun 2018 19:20:25 +0200 Subject: [PATCH 13/14] delete .swp file --- Zadanie-03/src/com/tylkowski/crc/.Main.java.swp | Bin 12288 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 Zadanie-03/src/com/tylkowski/crc/.Main.java.swp diff --git a/Zadanie-03/src/com/tylkowski/crc/.Main.java.swp b/Zadanie-03/src/com/tylkowski/crc/.Main.java.swp deleted file mode 100644 index 714621d151bd5b5f8867a6c67a6a5ab6f4050fb9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI2L2uJA6vy42H<$o%ew0fitx3CHkfu$VHU^b8E(NqPO~Q5D*3@-E?6j+3aNwix zSvbRmZ!oSqf*2QG(zJ9#8aE`wv-Iz4Z0G&o`z4pEZr7eR_u!siXE>G_JNwW$ES=wC zud9qbOxrSX*}~PMm$q$WuHKWazL_Kpwx#X6C=NDtSGE&gea1s>6c4sHcOUFFYr*7N zR%?yGCL$2gAaG;dk4Cny0)aDoTp9lbAM!tY(hed(1f~R*SYx$b%dYO0@4(F)Po@hL zi2xBG0z`la5CI}U1c(3;_zwuUxWwLKp9@8=w~JW16pKp=M1Tko0U|&IhyW2F0z`la z5CI}U1c<;tNPvfoy<24L8!G$%fBO6X%XP+1QJ+vBQ3h2-onB*XgleLeQD;kxeMY@U zjZx20i>L)u3H1Z>o}<1O9$zyb8bp8y5CI}U1c(3;AOb{y2oQn4N8kjl00+h_WaEV8 zq4-c8sPLp~59>$1mZs}^6%RJnq2WPmY@HnVQR@6SQO0Rg!9&T9x$XO*6j3OrH+tUM zg`7bEq9;WkI>OEtPC#laVdhsm^5x5vYg;L=mOT$%&30y$UEwWF?)|%|NF;X>cD7ox zRH`$nan7uM(QIqd5fq)lIv6>EVs_f#3KWRu8pS5}ftwHxpbGW;+bXur6E2)gAnIHw z1b540K8UphY!}My{ev=8H^B9jg^|)4CP=|LMBObmWa$&>(!_vE(j1<0fOibJRv| Date: Wed, 27 Jun 2018 19:25:52 +0200 Subject: [PATCH 14/14] valid FCS output --- .../artifacts/Zadanie_03_jar/Zadanie-03.jar | Bin 4872 -> 4737 bytes .../com/tylkowski/crc/CrcTask.class | Bin 6304 -> 6117 bytes .../Zadanie-03/com/tylkowski/crc/Main.class | Bin 1086 -> 942 bytes Zadanie-03/src/com/tylkowski/crc/CrcTask.java | 40 ++++++++++-------- Zadanie-03/src/com/tylkowski/crc/Main.java | 10 ++--- 5 files changed, 27 insertions(+), 23 deletions(-) diff --git a/Zadanie-03/out/artifacts/Zadanie_03_jar/Zadanie-03.jar b/Zadanie-03/out/artifacts/Zadanie_03_jar/Zadanie-03.jar index 8bd6df9d4f5c250f5ce9bc3ee21ca9d2a86fc0ce..5d76ae0f2dda7ad203d16906b787b506ec968f19 100644 GIT binary patch delta 4107 zcmY+HX*3iJ`^LvI2HE%Q#26E0#vVeJG-C*ZY=z0bJi=IG5E(`GeakYoj3taEH1?&) z7P8A)l08lI^gi|c&-uUaeSi3!bKlpwK3!ifJUCL4`8JYPROFnJ&r_oULUk!bDl-eSje{_oqk#;_m9nXIgc<)cNl zz#D>LX|WGaZQccrhA#PyD%XZn>1@pC^X-)9s#2d^*-q-aW!48-|AQo#S(Nf`U3? zy;t@U+PA<3ogZ#Cj}aFZ`Y$y5`GJ(1LtHg+d+WqN%C`3p*y-1UajLdVXKV3sT905o zQiodp5OMJSad?~{FA0gB$Tj*_=u#RVUx0LxICMJBmkoBPA;h7@n{A7=7A^Zm;}E3^ zWoxsR(|HCLiD4Q-`p%D*lDXVVF(L3O7Y=n2INdf-{4&l2>nF2lR=8vAjof?djhq^Q z*Z=4@^n6sXNN0zY4hk0^M4oT1W8j**uV{8L3i+Te%mugJdo zHml+XYRC7*y@gXC-?_CfpK%PeBuA>ZN<9^l+*Q>e5%u=Cl_HRA<4)a9)$X(r+*rM) z2j9T)d{ekn=Xha_CE1|L{t(ri{ zt{l8|+|t`1(K*}+W>k;r{8C|;YN$?JAs37zhOpJ9dI9B2Hd)VJ0?7ue&#BS+Q1HhR zoVeS%FFpYVq5aJNG-T1q8&r|-{gHJ|ivuH+Kh_=_7o0lc(JD`;*uUlCRkCnQ{be}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X zqla_0qQ0mqI)yr6u95aw)y7nLZf8q}IqoL-jlFR>B2>hUxYU#`9<$=QiljWtnSds$ zp7+47?~S&}Jn=Tb> zVOe!q!>tlIb;Nx~m-67y?nvteTH}kv@e*_E1xo8>4_ys$f0Z(lV$8*PU62pKYEoO^BTdu iu7EjiKFfnM%OxvBr5DKxf&N3sq|h~djcfbx_5T8CB1-cB diff --git a/Zadanie-03/out/production/Zadanie-03/com/tylkowski/crc/Main.class b/Zadanie-03/out/production/Zadanie-03/com/tylkowski/crc/Main.class index daedb274c6ac8373bd76c45c3fcc4a865bad7702..86a430a01424cc018a89e9629cf6c860c9c38fd5 100644 GIT binary patch delta 261 zcmXBOIZgvX5QX8t+ekgrZa`qU#SX);n9bN=z-%@IOyG>r2O>opbwET&ibM*Q55NI9 zjfJQd;rr^Ts>aE?DZYO{$3TaB%M2Ta%%a&$$SqrJr|hsBrD54)Kj9$qVU(jNO~bLF zRTe)g3oX^_wiT*vIB}fPF`PNhxo~v3G+a5Zi3OS7aO>#Nk94Q-<+BeXRoC@K`Qbxf zzlDi@sww8=xmTv-9u!~bVR)%L4pOREJdT`cn#}URJT>X~|0WA8N~+5CC6-aFNJ`NY Na>HsSuqL2c{{wTRAbS7+ delta 381 zcmYk2+e!ja6o$V&9kxwV6qR&7nwpiSX(!8$T0#UNL|qOxm@!zSMLj{c$-F=}-3Hwj z_y9eCPZQA|f{b;u|L^}`vDd4tc`~2h?=>LKzD_4o5}%I7vr{21(WpHb_Y} z4Yt@;Ld;-?U4uQ+F3LDhB78b}Y2KL;+bk6#M_0Mq{6(f{+2?;t1mg`MYui@Aw72tl zt6cu41cHYRDOb5EmI}%0o7bs}7st{1#EJ8uJ$f~|)fJv;Q6Gcs2ijSvIp*{<9iO;& zX=i{A{OT2@ivxPpfcICXU$v+%$sj`rhE-}q`@%07nP61KR;7+HuF46OG$wxl?j%LH diff --git a/Zadanie-03/src/com/tylkowski/crc/CrcTask.java b/Zadanie-03/src/com/tylkowski/crc/CrcTask.java index 6bf7471..1b02ada 100644 --- a/Zadanie-03/src/com/tylkowski/crc/CrcTask.java +++ b/Zadanie-03/src/com/tylkowski/crc/CrcTask.java @@ -1,7 +1,5 @@ package com.tylkowski.crc; -import java.lang.reflect.Field; -import java.nio.charset.Charset; import java.util.Arrays; class CrcTask { @@ -10,19 +8,12 @@ class CrcTask { private short[] polyGenerator; private String rawMessage; - CrcTask(String message, String rawMessage) throws NoSuchFieldException, IllegalAccessException { - setEncoding(); + CrcTask(String message) { + this.rawMessage = message; this.message = formatMessage(toBinaryString(message)) + "0000000000000000"; - this.rawMessage = rawMessage; createGeneratingPolynomial(); } - private void setEncoding() throws NoSuchFieldException, IllegalAccessException { - System.setProperty("file.encoding", "ISO-8859-1"); - Field charset = Charset.class.getDeclaredField("defaultCharset"); - charset.setAccessible(true); - charset.set(null, null); - } private String formatMessage(String message) { int firstNonZeroVal = 0; @@ -59,7 +50,7 @@ class CrcTask { short[] piece = Arrays.copyOfRange(messageAsShortArray, 0, Math.min(polyGenerator.length, messageAsShortArray.length)); if (piece.length < polyGenerator.length) { fillPolynomial(piece); - return "" + getCharFromShortArray(piece, 0, 8) + getCharFromShortArray(piece, piece.length - 8, piece.length); + return createTwoCharsOfFCS(piece); } short[] remainder = calcXOR(piece, polyGenerator); remainder = removeUnecessaryZeros(remainder); @@ -69,6 +60,17 @@ class CrcTask { } + private String createTwoCharsOfFCS(short[] piece) { + short[] firstPiece = Arrays.copyOfRange(piece, 0, 8); + short[] secondPiece = Arrays.copyOfRange(piece, piece.length - 8, piece.length); + short[] mergedPieces = new short[firstPiece.length + secondPiece.length]; + for (int i = 0; i < firstPiece.length; i++) { + mergedPieces[i] = firstPiece[i]; + mergedPieces[i + 8] = secondPiece[i]; + } + return "0x" + Integer.toHexString(Integer.parseInt(shortArrayToBinaryString(mergedPieces), 2)); + } + private short[] createMessageFromRemainderAndPartFromOldMessage(short[] remainder, short[] msg) { short[] tempArr = new short[remainder.length + msg.length - polyGenerator.length]; System.arraycopy(remainder, 0, tempArr, 0, remainder.length); @@ -106,12 +108,6 @@ class CrcTask { return binaryString.toString(); } - private char getCharFromShortArray(short[] piece, int from, int to) { - short[] sign = Arrays.copyOfRange(piece, from, to); - int character = Integer.parseInt(shortArrayToBinaryString(sign), 2); - return (char) character; - } - private void fillPolynomial(short[] piece) { while (piece.length % 8 != 0) { piece = addZeroAtBeginningOfArray(piece); @@ -171,7 +167,10 @@ class CrcTask { } boolean decode(String encodedString) { + String fcs = encodedString.substring(encodedString.indexOf("0x"), encodedString.length()); + encodedString = encodedString.replace(fcs, ""); encodedString = toBinaryString(encodedString); + encodedString = encodedString + toBinaryStringFromHexValue(fcs); encodedString = fillPoly(encodedString); short[] encodedShortArray = convertBinaryStringToShortArray(encodedString); encodedShortArray = swapPolynomialValues(encodedShortArray); @@ -194,6 +193,11 @@ class CrcTask { } } + private String toBinaryStringFromHexValue(String hexString) { + hexString = hexString.substring(2, hexString.length()); + return String.valueOf(Integer.toBinaryString(Integer.parseInt(hexString, 16))); + } + private String toBinaryString(String encodedString) { StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < encodedString.length(); i++) { diff --git a/Zadanie-03/src/com/tylkowski/crc/Main.java b/Zadanie-03/src/com/tylkowski/crc/Main.java index b85f350..3911551 100644 --- a/Zadanie-03/src/com/tylkowski/crc/Main.java +++ b/Zadanie-03/src/com/tylkowski/crc/Main.java @@ -2,13 +2,13 @@ package com.tylkowski.crc; public class Main { - public static void main(String[] args) throws NoSuchFieldException, IllegalAccessException { + public static void main(String[] args) { // in command line type "1" for mode and "b" for message // example "1" "b" -> this will encode string "b" and return FCS - // example "2" "bXY" -> this will decode string "bXY" and return true if it is valid or false if not - // X and Y - 1 and 2 character of FCS - CrcTask crcTask = new CrcTask(args[1], args[1]); - if(args[0].equals("1")) { + // example "2" "bX" -> this will decode string "bX" and return true if it is valid or false if not + // X - FCS + CrcTask crcTask = new CrcTask(args[1]); + if (args[0].equals("1")) { //create FCS System.out.println(crcTask.encode()); } else if (args[0].equals("2")) { -- 2.20.1