-
Notifications
You must be signed in to change notification settings - Fork 3
/
CRC32_BASE91D.pas
84 lines (72 loc) · 3.8 KB
/
CRC32_BASE91D.pas
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
unit CRC32_BASE91D;
//CRC-32 BASE91-D
//Author: domasz
//Last Update: 2022-11-20
//Licence: MIT
interface
uses SysUtils, HasherBase;
type THasherCRC32_BASE91D= class(THasherbase)
private
FHash: Cardinal;
public
constructor Create; override;
procedure Update(Msg: PByte; Length: Integer); override;
function Final: String; override;
end;
implementation
var Table: array[0..255] of LongInt = (
$00000000, $2BDDD04F, $57BBA09E, $7C6670D1, $AF77413C, $84AA9173, $F8CCE1A2, $D31131ED,
$F6DD1A53, $DD00CA1C, $A166BACD, $8ABB6A82, $59AA5B6F, $72778B20, $0E11FBF1, $25CC2BBE,
$4589AC8D, $6E547CC2, $12320C13, $39EFDC5C, $EAFEEDB1, $C1233DFE, $BD454D2F, $96989D60,
$B354B6DE, $98896691, $E4EF1640, $CF32C60F, $1C23F7E2, $37FE27AD, $4B98577C, $60458733,
$8B13591A, $A0CE8955, $DCA8F984, $F77529CB, $24641826, $0FB9C869, $73DFB8B8, $580268F7,
$7DCE4349, $56139306, $2A75E3D7, $01A83398, $D2B90275, $F964D23A, $8502A2EB, $AEDF72A4,
$CE9AF597, $E54725D8, $99215509, $B2FC8546, $61EDB4AB, $4A3064E4, $36561435, $1D8BC47A,
$3847EFC4, $139A3F8B, $6FFC4F5A, $44219F15, $9730AEF8, $BCED7EB7, $C08B0E66, $EB56DE29,
$BE152A1F, $95C8FA50, $E9AE8A81, $C2735ACE, $11626B23, $3ABFBB6C, $46D9CBBD, $6D041BF2,
$48C8304C, $6315E003, $1F7390D2, $34AE409D, $E7BF7170, $CC62A13F, $B004D1EE, $9BD901A1,
$FB9C8692, $D04156DD, $AC27260C, $87FAF643, $54EBC7AE, $7F3617E1, $03506730, $288DB77F,
$0D419CC1, $269C4C8E, $5AFA3C5F, $7127EC10, $A236DDFD, $89EB0DB2, $F58D7D63, $DE50AD2C,
$35067305, $1EDBA34A, $62BDD39B, $496003D4, $9A713239, $B1ACE276, $CDCA92A7, $E61742E8,
$C3DB6956, $E806B919, $9460C9C8, $BFBD1987, $6CAC286A, $4771F825, $3B1788F4, $10CA58BB,
$708FDF88, $5B520FC7, $27347F16, $0CE9AF59, $DFF89EB4, $F4254EFB, $88433E2A, $A39EEE65,
$8652C5DB, $AD8F1594, $D1E96545, $FA34B50A, $292584E7, $02F854A8, $7E9E2479, $5543F436,
$D419CC15, $FFC41C5A, $83A26C8B, $A87FBCC4, $7B6E8D29, $50B35D66, $2CD52DB7, $0708FDF8,
$22C4D646, $09190609, $757F76D8, $5EA2A697, $8DB3977A, $A66E4735, $DA0837E4, $F1D5E7AB,
$91906098, $BA4DB0D7, $C62BC006, $EDF61049, $3EE721A4, $153AF1EB, $695C813A, $42815175,
$674D7ACB, $4C90AA84, $30F6DA55, $1B2B0A1A, $C83A3BF7, $E3E7EBB8, $9F819B69, $B45C4B26,
$5F0A950F, $74D74540, $08B13591, $236CE5DE, $F07DD433, $DBA0047C, $A7C674AD, $8C1BA4E2,
$A9D78F5C, $820A5F13, $FE6C2FC2, $D5B1FF8D, $06A0CE60, $2D7D1E2F, $511B6EFE, $7AC6BEB1,
$1A833982, $315EE9CD, $4D38991C, $66E54953, $B5F478BE, $9E29A8F1, $E24FD820, $C992086F,
$EC5E23D1, $C783F39E, $BBE5834F, $90385300, $432962ED, $68F4B2A2, $1492C273, $3F4F123C,
$6A0CE60A, $41D13645, $3DB74694, $166A96DB, $C57BA736, $EEA67779, $92C007A8, $B91DD7E7,
$9CD1FC59, $B70C2C16, $CB6A5CC7, $E0B78C88, $33A6BD65, $187B6D2A, $641D1DFB, $4FC0CDB4,
$2F854A87, $04589AC8, $783EEA19, $53E33A56, $80F20BBB, $AB2FDBF4, $D749AB25, $FC947B6A,
$D95850D4, $F285809B, $8EE3F04A, $A53E2005, $762F11E8, $5DF2C1A7, $2194B176, $0A496139,
$E11FBF10, $CAC26F5F, $B6A41F8E, $9D79CFC1, $4E68FE2C, $65B52E63, $19D35EB2, $320E8EFD,
$17C2A543, $3C1F750C, $407905DD, $6BA4D592, $B8B5E47F, $93683430, $EF0E44E1, $C4D394AE,
$A496139D, $8F4BC3D2, $F32DB303, $D8F0634C, $0BE152A1, $203C82EE, $5C5AF23F, $77872270,
$524B09CE, $7996D981, $05F0A950, $2E2D791F, $FD3C48F2, $D6E198BD, $AA87E86C, $815A3823
);
constructor THasherCRC32_BASE91D.Create;
begin
inherited Create;
FHash := $FFFFFFFF;
Check := '87315576';
end;
procedure THasherCRC32_BASE91D.Update(Msg: PByte; Length: Integer);
var i: Integer;
begin
for i:=0 to Length-1 do begin
FHash := (FHash shr 8) xor Table[byte(FHash) xor Msg^];
Inc(Msg);
end;
end;
function THasherCRC32_BASE91D.Final: String;
begin
FHash := FHash xor $FFFFFFFF;
Result := IntToHex(FHash, 8);
end;
initialization
HasherList.RegisterHasher('CRC-32 BASE91-D', THasherCRC32_BASE91D);
end.