Class RarCRC

java.lang.Object
com.github.junrar.crc.RarCRC

public class RarCRC extends Object
DOCUMENT ME
  • Method Details

    • checkOldCrc

      public static short checkOldCrc(short startCrc, byte[] data, int count)
      Computes the legacy 16-bit checksum used by RAR 1.5 archives.

      This is not a standard CRC-16 algorithm. It is a simple rotating-add checksum equivalent to the OldCRC16 function in the original unrar source code. For each byte, it adds the byte value to the accumulator and then rotates the result left by 1 bit:

         crc = crc + byte;
         crc = (crc << 1) | (crc >>> 15);
       

      Only used for RAR 1.5 (method 15) archives. RAR 2.0 and later use standard CRC-32 (polynomial 0xEDB88320).

      Parameters:
      startCrc - initial CRC value (typically 0 for RAR 1.5)
      data - data to compute the checksum over
      count - number of bytes to process
      Returns:
      the 16-bit rotating-add checksum