File: BZip2Crc.h

package info (click to toggle)
p7zip 16.02%2Bdfsg-8
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 14,148 kB
  • sloc: cpp: 167,145; ansic: 14,992; python: 1,911; asm: 1,688; sh: 1,132; makefile: 703
file content (31 lines) | stat: -rw-r--r-- 756 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// BZip2Crc.h

#ifndef __BZIP2_CRC_H
#define __BZIP2_CRC_H

#include "../../Common/MyTypes.h"

class CBZip2Crc
{
  UInt32 _value;
  static UInt32 Table[256];
public:
  static void InitTable();
  CBZip2Crc(): _value(0xFFFFFFFF) {};
  void Init() { _value = 0xFFFFFFFF; }
  void UpdateByte(Byte b) { _value = Table[(_value >> 24) ^ b] ^ (_value << 8); }
  void UpdateByte(unsigned int b) { _value = Table[(_value >> 24) ^ b] ^ (_value << 8); }
  UInt32 GetDigest() const { return _value ^ 0xFFFFFFFF; }
};

class CBZip2CombinedCrc
{
  UInt32 _value;
public:
  CBZip2CombinedCrc():  _value(0){};
  void Init() { _value = 0; }
  void Update(UInt32 v) { _value = ((_value << 1) | (_value >> 31)) ^ v; }
  UInt32 GetDigest() const { return _value ; }
};

#endif