Zadananie 3 - CRC #26

Closed
s426271 wants to merge 8 commits from s426271/DALGLI0:zadanie-3 into master
3 changed files with 40 additions and 0 deletions
Showing only changes of commit 966b225ba8 - Show all commits

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