• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * CRC32
3  *
4  * Author: Lasse Collin <lasse.collin@tukaani.org>
5  *
6  * This file has been put into the public domain.
7  * You can do whatever you want with this file.
8  */
9 
10 package org.tukaani.xz.check;
11 
12 public class CRC32 extends Check {
13     private final java.util.zip.CRC32 state = new java.util.zip.CRC32();
14 
CRC32()15     public CRC32() {
16         size = 4;
17         name = "CRC32";
18     }
19 
update(byte[] buf, int off, int len)20     public void update(byte[] buf, int off, int len) {
21         state.update(buf, off, len);
22     }
23 
finish()24     public byte[] finish() {
25         long value = state.getValue();
26         byte[] buf = { (byte)(value),
27                        (byte)(value >>> 8),
28                        (byte)(value >>> 16),
29                        (byte)(value >>> 24) };
30         state.reset();
31         return buf;
32     }
33 }
34