forked from kalmar/DALGLI0
project started
This commit is contained in:
parent
4c976710f9
commit
966b225ba8
6
Zadanie-03/.idea/vcs.xml
Normal file
6
Zadanie-03/.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>
|
13
Zadanie-03/src/com/tylkowski/crc/CrcTask.java
Normal file
13
Zadanie-03/src/com/tylkowski/crc/CrcTask.java
Normal 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";
|
||||
}
|
||||
}
|
21
Zadanie-03/src/com/tylkowski/crc/Main.java
Normal file
21
Zadanie-03/src/com/tylkowski/crc/Main.java
Normal 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();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user