C# Класс Adler32.AdlerChecksum

Adler 32 check sum calculation (From en.wikipedia.org) Adler-32 is a checksum algorithm which was invented by Mark Adler. It is almost as reliable as a 32-bit cyclic redundancy check for protecting against accidental modification of data, such as distortions occurring during a transmission. An Adler-32 checksum is obtained by calculating two 16-bit checksums A and B and concatenating their bits into a 32-bit integer. A is the sum of all bytes in the string, B is the sum of the individual values of A from each step. At the beginning of an Adler-32 run, A is initialized to 1, B to 0. The sums are done modulo 65521 (the largest prime number smaller than 216). The bytes are stored in network order (big endian), B occupying the two most significant bytes. The function may be expressed as A = 1 + D1 + D2 + ... + DN (mod 65521) B = (1 + D1) + (1 + D1 + D2) + ... + (1 + D1 + D2 + ... + DN) (mod 65521) = NЧD1 + (N-1)ЧD2 + (N-2)ЧD3 + ... + DN + N (mod 65521) Adler-32(D) = B * 65536 + A where D is the string of bytes for which the checksum is to be calculated, and N is the length of D.
Показать файл Открыть проект

Открытые методы

Метод Описание
Equals ( object obj ) : bool

Equals determines whether two files (buffers) have the same checksum value (identical).

GetHashCode ( ) : int

GetHashCode returns hash code for this instance.

MakeForBuff ( byte bytesBuff, int length ) : bool

Calculate Adler-32 checksum for buffer

MakeForFile ( FileStream fs ) : bool

Calculate Adler-32 checksum for file

ToString ( ) : string

ToString is a method for current AdlerChecksum object representation in textual form.

operator ( ) : bool

operator!= determines whether AdlerChecksum objects are not equal.

Приватные методы

Метод Описание
MakeForBuff ( byte bytesBuff, uint unAdlerCheckSum, int length ) : bool

Calculate Adler-32 checksum for buffer

Описание методов

Equals() публичный Метод

Equals determines whether two files (buffers) have the same checksum value (identical).
public Equals ( object obj ) : bool
obj object A AdlerChecksum object for comparison
Результат bool

GetHashCode() публичный Метод

GetHashCode returns hash code for this instance.
public GetHashCode ( ) : int
Результат int

MakeForBuff() публичный Метод

Calculate Adler-32 checksum for buffer
public MakeForBuff ( byte bytesBuff, int length ) : bool
bytesBuff byte Bites array for checksum calculation
length int
Результат bool

MakeForFile() публичный Метод

Calculate Adler-32 checksum for file
public MakeForFile ( FileStream fs ) : bool
fs FileStream
Результат bool

ToString() публичный Метод

ToString is a method for current AdlerChecksum object representation in textual form.
public ToString ( ) : string
Результат string

operator() публичный статический Метод

operator!= determines whether AdlerChecksum objects are not equal.
public static operator ( ) : bool
Результат bool