summaryrefslogtreecommitdiff
path: root/src/crc/pe_crc64.c
blob: 3cd6e069a0fa65149394b6feaaf54f077c745a74 (plain)
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
/***************************************************************/
/*  perk: PE Resource Kit                                      */
/*  Copyright (C) 2015--2025  SysDeer Technologies, LLC        */
/*  Released under GPLv2 and GPLv3; see COPYING.PERK.          */
/***************************************************************/

#include <stdint.h>
#include <unistd.h>

#include <perk/perk.h>
#include <perk/perk_crc64.h>

static const uint64_t crc64_table[256] = PERK_CRC64_TABLE;

uint64_t pe_hash_mbstr_crc64(const unsigned char * str)
{
	const unsigned char *	ch;
	uint64_t		crc64;

	crc64	= 0 ^ 0xFFFFFFFFFFFFFFFF;
	ch	= str;

	while (*ch) {
		crc64 = (crc64 >> 8) ^ crc64_table[(crc64 ^ *ch) & 0xFF];
		ch++;
	}

	return (crc64 ^ 0xFFFFFFFFFFFFFFFF);
}