]>
glassweightruler.freedombox.rocks Git - Ventoy.git/blob - Plugson/src/Core/ventoy_crc32.c
1 /******************************************************************************
2 * crc32.c ---- ventoy crc32
4 * Copyright (c) 2021, longpanda <admin@ventoy.net>
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 3 of the
9 * License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
25 #if defined(_MSC_VER) || defined(WIN32)
27 #define uint32_t UINT32
32 static uint32_t g_crc_table
[256] = {
291 uint32_t ventoy_crc32(void *Buffer
, uint32_t Length
)
294 uint8_t *Ptr
= Buffer
;
295 uint32_t Crc
= 0xFFFFFFFF;
297 for (i
= 0; i
< Length
; i
++, Ptr
++)
299 Crc
= (Crc
>> 8) ^ g_crc_table
[(uint8_t) Crc
^ *Ptr
];
302 return Crc
^ 0xffffffff;