-
Notifications
You must be signed in to change notification settings - Fork 395
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2629 from verilog-to-routing/rem_warnings
Removing warnings from libencrypt and libdecrypt
- Loading branch information
Showing
11 changed files
with
421 additions
and
199 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
cmake_minimum_required(VERSION 3.10) | ||
project(EncryptionDecryptionTest) | ||
|
||
# Find OpenSSL | ||
find_package(OpenSSL REQUIRED) | ||
|
||
add_executable(test_encrypt_decrypt src/test.cpp src/main.cpp) | ||
|
||
set(PUBLIC_KEY_FILE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../libencrypt/public_key.pem") | ||
target_compile_definitions(test_encrypt_decrypt PRIVATE PUBLIC_KEY_FILE="${PUBLIC_KEY_FILE_PATH}") | ||
|
||
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../../libencrypt/src" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/../src" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/src") | ||
|
||
target_link_libraries(test_encrypt_decrypt | ||
libpugixml | ||
libdecrypt | ||
libencrypt) | ||
|
||
add_test(NAME test_encrypt_decrypt COMMAND test_encrypt_decrypt) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include "test.h" | ||
|
||
int main() { | ||
std::string testFilePath = "test.xml"; | ||
std::string publicKeyFile = PUBLIC_KEY_FILE; // Path to your public key file | ||
std::string encryptedFilePath = "test.xmle"; | ||
|
||
// Step 1: Create a test XML file | ||
createTestXMLFile(testFilePath); | ||
|
||
std::string originalContent = readFileToString(testFilePath); | ||
|
||
// Step 2: Encrypt XML content | ||
Encryption encryption; | ||
if (!encryption.encryptFile(publicKeyFile, testFilePath)) { | ||
std::cerr << "Encryption failed" << std::endl; | ||
return 1; | ||
} | ||
|
||
// Step 3: Decrypt XML content | ||
Decryption decryption(encryptedFilePath); | ||
std::string decryptedContent = decryption.getDecryptedContent(); | ||
|
||
// Step 4: Compare original XML content with decrypted XML content | ||
if (decryptedContent == originalContent) { | ||
std::cout << "Test passed: Decrypted content matches original content" << std::endl; | ||
} else { | ||
std::cerr << "Test failed: Decrypted content does not match original content" << std::endl; | ||
return 1; | ||
} | ||
|
||
return 0; | ||
} |
Oops, something went wrong.