🐛 Change char buffers to unsigned char buffers
This commit is contained in:
parent
04e8f80b20
commit
6b9b31c2bc
11 changed files with 67 additions and 47 deletions
|
@ -46,16 +46,16 @@ const uint32_t crc32_tab[] = {
|
|||
0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
|
||||
};
|
||||
|
||||
uint32_t getCrc(uint32_t old_crc, unsigned char c) {
|
||||
return (old_crc >> 8) ^ crc32_tab[(old_crc & 0xffU) ^ c];
|
||||
uint32_t getCrc(uint32_t old_crc, uint8_t c) {
|
||||
return (old_crc >> 8) ^ crc32_tab[(old_crc & (uint32_t)0xff) ^ c];
|
||||
}
|
||||
|
||||
void updateKeys(uint32_t *key_0, uint32_t *key_1, uint32_t *key_2, unsigned char c) {
|
||||
void updateKeys(uint32_t *key_0, uint32_t *key_1, uint32_t *key_2, uint8_t c) {
|
||||
*key_0 = getCrc(*key_0, c);
|
||||
*key_1 = ((*key_1) + ((*key_0) & (uint32_t)0xffU)) * ((uint32_t)134775813U) + ((uint32_t)1U);
|
||||
*key_2 = getCrc(*key_2, (*key_1) >> 24);
|
||||
}
|
||||
|
||||
unsigned char decryptByte(uint16_t keyPart) {
|
||||
uint8_t decryptByte(uint16_t keyPart) {
|
||||
return (keyPart * (keyPart ^ 1)) >> 8;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,6 @@
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
void updateKeys(uint32_t *key_0, uint32_t *key_1, uint32_t *key_2, unsigned char c);
|
||||
void updateKeys(uint32_t *key_0, uint32_t *key_1, uint32_t *key_2, uint8_t c);
|
||||
|
||||
unsigned char decryptByte(unsigned short keyPart);
|
||||
uint8_t decryptByte(uint16_t keyPart);
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
|
||||
//Reads the given amount of bytes from the currently open file into the given buffer.
|
||||
void readBytesIntoBuffer(char* buffer, long numBytes) {
|
||||
void readBytesIntoBuffer(uint8_t* buffer, long numBytes) {
|
||||
const size_t result = fread(buffer, 1, numBytes, file.filePointer);
|
||||
file.offset += result;
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
//A structure to store various information needed when reading from a file.
|
||||
struct FILE_INFO {
|
||||
char* name;
|
||||
|
@ -12,7 +14,7 @@ struct FILE_INFO file;
|
|||
|
||||
|
||||
//Reads the given amount of bytes from the currently open file into the given buffer.
|
||||
void readBytesIntoBuffer(char* buffer, long numBytes);
|
||||
void readBytesIntoBuffer(uint8_t* buffer, long numBytes);
|
||||
|
||||
|
||||
//Closes the currently opened file and opens the next file at its beginning.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue