Skip to content

Instantly share code, notes, and snippets.

@atc1441
Created May 19, 2020 17:16
Show Gist options
  • Save atc1441/4b8550c9a83449d7c5e1b752c97c6e5d to your computer and use it in GitHub Desktop.
Save atc1441/4b8550c9a83449d7c5e1b752c97c6e5d to your computer and use it in GitHub Desktop.
import java.lang.Math;
public class HelloWorld
{
public static void main(String[] args)
{
ParserData parserData1 = parser(new int[]{ 0x52,0x5D,0xD7,0x9F,0x00,0x31 },false);
System.out.print("Flag:");
System.out.print(parserData1.flag);
System.out.print("\r\nSeconds in unix -40 Years: ");
System.out.print(parserData1.secondTime);
System.out.print("\r\nData Value: ");
System.out.print(parserData1.value);
System.out.print("\r\nData Value1:");
System.out.print(parserData1.value1);
}
public static class ParserData {
public int flag;
public long secondTime;
public int value;
public int value1;
}
public static ParserData parser(int[] arr, boolean realTime) {
int s;
if (!realTime) {
boolean b = true;
int length = arr.length;
int i = 0;
while (true) {
if (i >= length) {
break;
} else if (arr[i] != 255) {
b = false;
break;
} else {
i++;
}
}
if (b) {
return null;
}
}
int time = 0;
int usetime = 0;
int flag = (arr[0] >> 6) & 3;
int s2 = 0;
while (true) {
s = s2;
if (s >= 4) {
break;
}
int s3 = s + 1;
time = (time << 16) | arr[s3] | (arr[s] << 8);
s2 = s3 + 1;
}
int time2 = time & 1073741823;
int s4 = s + 1;
int s5 = s4 + 1;
int value = (arr[s] << 8) | arr[s4];
if (realTime) {
int s6 = s5 + 1;
usetime = (arr[s5] << 8) | arr[s6];
int i2 = s6 + 1;
}
ParserData parserData = new ParserData();
parserData.flag = flag;
parserData.secondTime = (long) time2;
parserData.value = value;
parserData.value1 = usetime;
return parserData;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment