Skip to content

Commit

Permalink
Feat: Add the encryption
Browse files Browse the repository at this point in the history
  • Loading branch information
czs108 committed Feb 6, 2024
1 parent fb808fc commit b79e1f6
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
24 changes: 24 additions & 0 deletions include/utility/encrypt.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* @file encrypt.h
* @brief Encrypt the data.
* @author Chen Zhenshuo (chenzs108@outlook.com)
* @version 1.0
* @date 2020-01-13
*
* @par GitHub
* https://github.com/czs108/
*/

#pragma once

#include <windows.h>

/**
* @brief Encrypt the data.
*
* @param base The base address of the data.
* @param size The size of the data.
*/
void EncryptData(
BYTE *const base,
const DWORD size);
2 changes: 2 additions & 0 deletions src/utility/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ target_sources(utility
PRIVATE
${CMAKE_CURRENT_LIST_DIR}/error_handling.c
${CMAKE_CURRENT_LIST_DIR}/file_access.c
${CMAKE_CURRENT_LIST_DIR}/encrypt.c
PUBLIC
${HEADER_PATH}/error_handling.h
${HEADER_PATH}/file_access.h
${HEADER_PATH}/platform_check.h
${HEADER_PATH}/encrypt.h
)

if(CMAKE_SIZEOF_VOID_P EQUAL 8)
Expand Down
32 changes: 32 additions & 0 deletions src/utility/encrypt.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* @file encrypt.c
* @brief Encrypt the data.
* @author Chen Zhenshuo (chenzs108@outlook.com)
* @version 1.0
* @date 2020-01-13
*
* @par GitHub
* https://github.com/czs108/
*/

#include "encrypt.h"

#include <assert.h>


void EncryptData(
BYTE *const base,
const DWORD size)
{
if (size == 0)
{
return;
}

assert(base != NULL);

for (DWORD i = 0; i != size; ++i)
{
base[i] += 0xCC;
}
}

0 comments on commit b79e1f6

Please sign in to comment.