Skip to content

Commit

Permalink
feat: 更新到v1.0.0.3
Browse files Browse the repository at this point in the history
1.更新ciftl库
  • Loading branch information
sandinpool committed Dec 19, 2024
1 parent 79c34b2 commit c021c8b
Show file tree
Hide file tree
Showing 11 changed files with 52 additions and 177 deletions.
19 changes: 10 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.20)

project(ciftl-gui VERSION 1.0.0.2 LANGUAGES CXX)
project(ciftl-gui VERSION 1.0.0.3 LANGUAGES CXX)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
Expand All @@ -25,6 +25,8 @@ endif()
# 根据构建类型设置编译器选项
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
message(STATUS "Build type: Debug")
set(LIBRARY_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH}/Debug")
set(EXECUTABLE_OUTPUT_PATH "${EXECUTABLE_OUTPUT_PATH}/Debug")
if(MSVC)
# Visual Studio 编译器的 Debug 选项
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Od /Zi /D_DEBUG")
Expand All @@ -34,6 +36,8 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug")
endif()
else()
message(STATUS "Build type: Release")
set(LIBRARY_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH}/Release")
set(EXECUTABLE_OUTPUT_PATH "${EXECUTABLE_OUTPUT_PATH}/Release")
if(MSVC)
# Visual Studio 编译器的 Release 选项
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /O2 /Oi /Gy /DNDEBUG")
Expand Down Expand Up @@ -106,14 +110,9 @@ set(PROJECT_SOURCES
)

include_directories(${CIFTL_GUI_INCLUDE_PATH})
include_directories(deps/ciftl-cpp/include)

find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets LinguistTools)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets LinguistTools)
find_package(OpenSSL REQUIRED)
find_package(fmt REQUIRED)

add_subdirectory(deps/ciftl-cpp)

if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
qt_add_executable(${PROJECT_NAME}
Expand Down Expand Up @@ -144,10 +143,12 @@ else()
qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
endif()

find_package(fmt CONFIG REQUIRED)
find_package(OpenSSL REQUIRED)
find_package(Ciftl CONFIG REQUIRED)

target_link_libraries(${PROJECT_NAME} PRIVATE Qt${QT_VERSION_MAJOR}::Widgets
OpenSSL::SSL OpenSSL::Crypto
fmt::fmt
ciftl)
fmt::fmt OpenSSL::SSL OpenSSL::Crypto Ciftl::ciftl)

# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
# If you are developing for iOS or macOS you should consider setting an
Expand Down
23 changes: 0 additions & 23 deletions CMakePresets.json

This file was deleted.

18 changes: 3 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
# README

**ciftl**是一款密码学工具。

## 配置

1. 启动bootstrap,配置vcpkg

```
python bootstrap.py
```

2. 调用CMake进行配置

```
cmake --preset=qt-gui-debug
```
**ciftl**是一个密码学工具箱,包括了"密码工具"、"哈希工具"等实用工具。

- 密码工具:用于对字符串进行加密,目前支持ChaCha20,AES和SM4三种加密算法。
- 哈希工具:用于对文件进行哈希计算,支持MD5, Sha1, Sha256, Sha512四种哈希算法。
52 changes: 0 additions & 52 deletions bootstrap.py

This file was deleted.

13 changes: 11 additions & 2 deletions include/cryption/crypter_form.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ namespace Ui
class CrypterForm;
}

enum class CipherAlgorithm
{
ChaCha20,
AES128OFB,
AES192OFB,
AES256OFB,
SM4OFB,
};

class LineImorter;

class CrypterTableDataModel : public QAbstractTableModel
Expand Down Expand Up @@ -165,8 +174,8 @@ private slots:
LineImporter *m_line_importer;

public:
const static std::vector<std::pair<std::string, ciftl::CipherAlgorithm>> __supported_cipher_algorithm__;
const static std::unordered_map<std::string, ciftl::CipherAlgorithm> __str_to_cipher_algorithm__;
const static std::vector<std::pair<std::string, CipherAlgorithm>> __supported_cipher_algorithm__;
const static std::unordered_map<std::string, CipherAlgorithm> __str_to_cipher_algorithm__;

};

Expand Down
2 changes: 1 addition & 1 deletion include/cryption/hash_form.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class HashForm : public QWidget
~HashForm();

private:
std::vector<std::pair<std::string, std::shared_ptr<ciftl::Hasher>>> generate_hasher_vec();
std::vector<std::pair<std::string, std::shared_ptr<ciftl::IHasher>>> generate_hasher_vec();

protected:
void dragEnterEvent(QDragEnterEvent *event) override
Expand Down
8 changes: 4 additions & 4 deletions res/ciftl.rc
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ IDI_ICON1 ICON DISCARDABLE "icon/ciftl.ico"

// �汾��Ϣ
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,2
PRODUCTVERSION 1,0,0,2
FILEVERSION 1,0,0,3
PRODUCTVERSION 1,0,0,3
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -26,11 +26,11 @@ BEGIN
BEGIN
VALUE "CompanyName", "����һ�ޣ�sandinpool��\0"
VALUE "FileDescription", "CipherTool\0"
VALUE "FileVersion", "1.0.0.2\0"
VALUE "FileVersion", "1.0.0.3\0"
VALUE "LegalCopyright", "����һ�ޣ�sandinpool��\0"
VALUE "OriginalFilename", "ciftl-gui.exe\0"
VALUE "ProductName", "ciftl\0"
VALUE "ProductVersion", "1.0.0.2\0"
VALUE "ProductVersion", "1.0.0.3\0"
END
END
BLOCK "VarFileInfo"
Expand Down
43 changes: 21 additions & 22 deletions src/cryption/crypter_form.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,22 @@
#include <ciftl/crypter/crypter.h>

#include "mainwindow.h"

#include "cryption/crypter_form.h"
#include "etc/line_importer.h"

#include "ui_crypter_form.h"

using namespace ciftl;

const std::vector<std::pair<std::string, ciftl::CipherAlgorithm>> CrypterForm::__supported_cipher_algorithm__= {
{"ChaCha20-Standard", ciftl::CipherAlgorithm::ChaCha20Standard},
{"ChaCha20-OpenSSL", ciftl::CipherAlgorithm::ChaCha20},
{"AES-OpenSSL-128位", ciftl::CipherAlgorithm::AES128},
{"AES-OpenSSL-192位", ciftl::CipherAlgorithm::AES192},
{"AES-OpenSSL-256位", ciftl::CipherAlgorithm::AES256},
{"SM4-OpenSSL", ciftl::CipherAlgorithm::SM4}
const std::vector<std::pair<std::string, CipherAlgorithm>> CrypterForm::__supported_cipher_algorithm__= {
{"ChaCha20", CipherAlgorithm::ChaCha20},
{"AES-128位-OFB", CipherAlgorithm::AES128OFB},
{"AES-192位-OFB", CipherAlgorithm::AES192OFB},
{"AES-256位-OFB", CipherAlgorithm::AES256OFB},
{"SM4-OFB", CipherAlgorithm::SM4OFB}
};
const std::unordered_map<std::string, ciftl::CipherAlgorithm> CrypterForm::__str_to_cipher_algorithm__(__supported_cipher_algorithm__.begin(), __supported_cipher_algorithm__.end());
const std::unordered_map<std::string, CipherAlgorithm> CrypterForm::__str_to_cipher_algorithm__(__supported_cipher_algorithm__.begin(), __supported_cipher_algorithm__.end());


CrypterForm::CrypterForm(QWidget *parent) : QWidget(parent),
Expand Down Expand Up @@ -154,7 +155,7 @@ void CrypterForm::copy_result()
clipboard->setText(res.c_str());
}

inline std::shared_ptr<StringCrypterInterface> string_crypter_selection(const std::string &algo_name)
inline std::shared_ptr<IStringCrypter> string_crypter_selection(const std::string &algo_name)
{
auto iter = CrypterForm::__str_to_cipher_algorithm__.find(algo_name);
if (iter == CrypterForm::__str_to_cipher_algorithm__.end())
Expand All @@ -163,18 +164,16 @@ inline std::shared_ptr<StringCrypterInterface> string_crypter_selection(const st
}
switch (iter->second)
{
case CipherAlgorithm::ChaCha20Standard:
return std::make_shared<ChaCha20StdStringCrypter>();
case CipherAlgorithm::ChaCha20:
return std::make_shared<ChaCha20OpenSSLStringCrypter>();
case CipherAlgorithm::AES128:
return std::make_shared<AES128OpenSSLStringCrypter>();
case CipherAlgorithm::AES192:
return std::make_shared<AES192OpenSSLStringCrypter>();
case CipherAlgorithm::AES256:
return std::make_shared<AES256OpenSSLStringCrypter>();
case CipherAlgorithm::SM4:
return std::make_shared<SM4OpenSSLStringCrypter>();
return std::make_shared<StringCrypter<ChaCha20CipherAlgorithm>>();
case CipherAlgorithm::AES128OFB:
return std::make_shared<StringCrypter<AES128OFBCipherAlgorithm>>();
case CipherAlgorithm::AES192OFB:
return std::make_shared<StringCrypter<AES192OFBCipherAlgorithm>>();
case CipherAlgorithm::AES256OFB:
return std::make_shared<StringCrypter<AES256OFBCipherAlgorithm>>();
case CipherAlgorithm::SM4OFB:
return std::make_shared<StringCrypter<SM4OFBCipherAlgorithm>>();
default:
return nullptr;
}
Expand All @@ -198,7 +197,7 @@ void CrypterForm::encrypt()
QMessageBox::critical(this, "错误", "待加密内容不能为空");
return;
}
std::shared_ptr<StringCrypterInterface> string_crypter = string_crypter_selection(ui->comboBoxCipherType->currentText().toStdString());
std::shared_ptr<IStringCrypter> string_crypter = string_crypter_selection(ui->comboBoxCipherType->currentText().toStdString());
for (auto &item : *res_data->get_raw_data())
{
std::string plain_text = item.src_text;
Expand Down Expand Up @@ -237,7 +236,7 @@ void CrypterForm::decrypt()
QMessageBox::critical(this, "错误", "待解密内容不能为空");
return;
}
std::shared_ptr<StringCrypterInterface> string_crypter = string_crypter_selection(ui->comboBoxCipherType->currentText().toStdString());
std::shared_ptr<IStringCrypter> string_crypter = string_crypter_selection(ui->comboBoxCipherType->currentText().toStdString());
for (auto &item : *res_data->get_raw_data())
{
std::string cipher_text = item.src_text;
Expand Down
4 changes: 2 additions & 2 deletions src/cryption/hash_form.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ HashForm::~HashForm()
delete ui;
}

std::vector<std::pair<std::string, std::shared_ptr<ciftl::Hasher>>> HashForm::generate_hasher_vec()
std::vector<std::pair<std::string, std::shared_ptr<ciftl::IHasher>>> HashForm::generate_hasher_vec()
{
std::vector<std::pair<std::string, std::shared_ptr<ciftl::Hasher>>> hasher_vec;
std::vector<std::pair<std::string, std::shared_ptr<ciftl::IHasher>>> hasher_vec;
if (ui->checkBoxMD5->isChecked())
{
hasher_vec.push_back({"MD5", std::make_shared<ciftl::MD5Hasher>()});
Expand Down
14 changes: 0 additions & 14 deletions vcpkg-configuration.json

This file was deleted.

33 changes: 0 additions & 33 deletions vcpkg.json

This file was deleted.

0 comments on commit c021c8b

Please sign in to comment.