23 lines
777 B
Java
23 lines
777 B
Java
package com.tylkowski.crc;
|
|
|
|
public class Main {
|
|
|
|
public static void main(String[] args) throws NoSuchFieldException, IllegalAccessException {
|
|
// 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
|
|
System.out.println(crcTask.encode());
|
|
} else if (args[0].equals("2")) {
|
|
// check fcs
|
|
if (args[1].length() >= 3) System.out.println(crcTask.decode(args[1]));
|
|
}
|
|
|
|
}
|
|
|
|
|
|
}
|