Examples of CRC32


Examples of com.jcraft.jzlib.CRC32

        return reply_int( inflater.getAdler() );
      }
      return reply_int(0);
    }
    case CRC32_1: {
      CRC32 crc = new CRC32();
      crc.update(cmd.array(), cmd.arrayOffset()+cmd.position(), cmd.remaining());
      return reply_int((int) crc.getValue());
    }
    case CRC32_2: {
      CRC32 crc = new CRC32();
      long init = cmd.getInt() & 0xffffffffL;
      crc.reset(init);
      crc.update(cmd.array(), cmd.arrayOffset()+cmd.position(), cmd.remaining());
      return reply_int((int) crc.getValue());
    }
    }

    throw new erjang.NotImplemented("command="+command+"; data="+EBinary.make(cmd));
  }
View Full Code Here

Examples of java.util.zip.CRC32

            for (File file : files) {
                String fileName = file.getPath();
                String entryName = removeBase(basePath, fileName);
                byte[] data = readFile(file);
                ZipEntry entry = new ZipEntry(entryName);
                CRC32 crc = new CRC32();
                crc.update(data);
                entry.setSize(file.length());
                entry.setCrc(crc.getValue());
                zipOut.putNextEntry(entry);
                zipOut.write(data);
                zipOut.closeEntry();
            }
            zipOut.closeEntry();
View Full Code Here

Examples of java.util.zip.CRC32

                    break;
                }
                s.reset();
                seek(i);
                store.readFully(s.getBytes(), 0, pageSize);
                CRC32 crc = new CRC32();
                crc.update(s.getBytes(), 4, pageSize - 4);
                int expected = (int) crc.getValue();
                int got = s.readInt();
                long writeCounter = s.readLong();
                int key = s.readInt();
                int firstTrunkPage = s.readInt();
                int firstDataPage = s.readInt();
View Full Code Here

Examples of java.util.zip.CRC32

    private static class Crc32InputStream extends FilterInputStream {
        private final CRC32 checksum;

        private Crc32InputStream(InputStream inputStream) {
            super(inputStream);
            checksum = new CRC32();
        }
View Full Code Here

Examples of java.util.zip.CRC32

    private static class Crc32OutputStream extends FilterOutputStream {
        private final CRC32 checksum;

        private Crc32OutputStream(OutputStream outputStream) {
            super(outputStream);
            this.checksum = new CRC32();
        }
View Full Code Here

Examples of java.util.zip.CRC32

            if (i == 3) {
                throw DbException.get(ErrorCode.FILE_CORRUPTED_1, fileName);
            }
            page.reset();
            readPage(i, page);
            CRC32 crc = new CRC32();
            crc.update(page.getBytes(), 4, pageSize - 4);
            int expected = (int) crc.getValue();
            int got = page.readInt();
            if (expected == got) {
                writeCountBase = page.readLong();
                logKey = page.readInt();
                logFirstTrunkPage = page.readInt();
View Full Code Here

Examples of java.util.zip.CRC32

        page.writeInt(0);
        page.writeLong(getWriteCountTotal());
        page.writeInt(logKey);
        page.writeInt(logFirstTrunkPage);
        page.writeInt(logFirstDataPage);
        CRC32 crc = new CRC32();
        crc.update(page.getBytes(), 4, pageSize - 4);
        page.setInt(0, (int) crc.getValue());
        file.seek(pageSize);
        file.write(page.getBytes(), 0, pageSize);
        file.seek(pageSize + pageSize);
        file.write(page.getBytes(), 0, pageSize);
        // don't increment the write counter, because it was just written
View Full Code Here

Examples of java.util.zip.CRC32

            FileInputStream fis = new FileInputStream(fromFile);

            byte[] bytes = new byte[1024];

            int numRead;
            CRC32 checksum = new CRC32();
            while ((numRead = fis.read(bytes)) > 0) {
                zoStream.write(bytes, 0, numRead);
                checksum.update(bytes, 0, numRead);
            }
            zEntry.setCrc(checksum.getValue());

            fis.close();
            zoStream.closeEntry();

        } catch (IOException ioe) {
View Full Code Here

Examples of java.util.zip.CRC32

  public static long gzipCalculateCRC32(File src) throws IOException {
    final byte[] b = new byte[(int) Size.OneMeg.bytes()];

    final GZIPInputStream in = new GZIPInputStream(new FileInputStream(src), 100);

    final CRC32 crc = new CRC32();
   
    int count = 0;
    int length = 0;
    while ((length = in.read(b)) != -1) {
      System.out.printf("#%d: len=%d\n", count, length);
      crc.update(b, 0, length);
      count ++;
    }

    in.close();
   
    return crc.getValue();

  }
View Full Code Here

Examples of java.util.zip.CRC32

   
    String status;
    if (data.length != length) {
      status = "data.length == " + data.length + ", should be " + length;
    } else {
      CRC32 computedCrc32 = new CRC32();
      computedCrc32.update(data);
      if (computedCrc32.getValue() != crc32) {
        status = "Computed crc32 == " + computedCrc32.getValue() + ", should be " + crc32;
      } else {
        status = "OK";
      }
    }
    return status;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.