Created
June 8, 2017 04:28
-
-
Save adityasatrio/babc0b90b127b2aaf845fca369da379b to your computer and use it in GitHub Desktop.
to mba fai
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void validateCheckSum(DocumentUploadRequest documentUploadRequest) { | |
long checksumValue = Utilities.checksum(documentUploadRequest.getDocument().getBytes()); | |
long checksumReq = Long.parseLong(documentUploadRequest.getDocumentChecksum()); | |
Logger.info("Checksum Document request " + checksumReq); | |
Logger.info("Checksum Document calculate " + checksumValue); | |
if (checksumReq != checksumValue) { | |
Logger.info("Checksum Document calculate " + checksumValue); | |
throw new ConstraintValidationException("Checksum vallidation failed"); | |
} | |
} | |
import java.util.zip.CRC32; | |
import java.util.zip.Checksum; | |
public static long checksum(byte[] file) { | |
Checksum checksumHash = new CRC32(); | |
checksumHash.update(file, 0, file.length); | |
return checksumHash.getValue(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment