1
0
Fork 0

project started

This commit is contained in:
Hubert Tylkowski 2018-06-19 00:04:34 +02:00
parent 4c976710f9
commit 966b225ba8
3 changed files with 40 additions and 0 deletions

6
Zadanie-03/.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

@ -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";
}
}

View File

@ -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();
}
}