Java CRC Calculate crc320(byte[] buf, int off, int len)

Here you can find the source of crc320(byte[] buf, int off, int len)

Description

crc

License

Open Source License

Declaration

public final static int crc320(byte[] buf, int off, int len) 

Method Source Code

//package com.java2s;

public class Main {
    private static int[] crc_t;

    public final static int crc320(byte[] buf, int off, int len) {
        return update(buf, off, len) ^ 0xFFFFFFFF;
    }//from w ww. jav a  2  s.  co m

    private final static int update(byte[] buf, int off, int len) {
        int c = 0xFFFFFFFF;
        int n;
        if (crc_t == null)
            mk();
        for (n = off; n < len + off; n++) {
            c = crc_t[(c ^ buf[n]) & 0xFF] ^ (c >>> 8);
        }
        return c;
    }

    private final static void mk() {
        int c, k;
        if (crc_t == null)
            crc_t = new int[256];
        for (int n = 0; n < 256; n++) {
            c = n;
            for (k = 0; k < 8; k++)
                c = (c & 1) == 1 ? 0xEDB88320 ^ (c >>> 1) : c >>> 1;
            crc_t[n] = c;
        }
    }
}

Related

  1. crc32(byte[] array, int offset, int size)
  2. CRC32(final byte[] buf, final int startPos, final int endPos)
  3. crc32(int[] table, int crc, byte[] buffer, int off, int len)
  4. crc32(long crcin, byte[] buf, int off, int alen)
  5. crc32(String input)
  6. crc321(byte[] buf, int off, int len)
  7. crc32Hash(String key)
  8. crc64(String value)
  9. crc8(byte data, byte crcInit, byte poly)