32 lines
850 B
Java
32 lines
850 B
Java
|
|
package com.cbsd.client.verification;
|
||
|
|
|
||
|
|
import com.cbsd.client.verification.IVerificationInterface;
|
||
|
|
import com.cbsd.client.verification.VerifyUtils;
|
||
|
|
import org.springframework.stereotype.Component;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* CRC校验
|
||
|
|
*/
|
||
|
|
@Component
|
||
|
|
public class CrcCheck implements IVerificationInterface {
|
||
|
|
|
||
|
|
@Override
|
||
|
|
public boolean verification(byte[] data, byte[] verify, VerifyUtils verifyUtils) {
|
||
|
|
try {
|
||
|
|
byte[] verifyCRC = new byte[data.length + verify.length];
|
||
|
|
System.arraycopy(data, 0, verifyCRC, 0, data.length);
|
||
|
|
System.arraycopy(verify, 0, verifyCRC, data.length, verify.length);
|
||
|
|
return verifyUtils.verifyCRC(verifyCRC);
|
||
|
|
} catch (Exception e) {
|
||
|
|
e.printStackTrace();
|
||
|
|
}
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
@Override
|
||
|
|
public String comment() {
|
||
|
|
return "";
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|