Compare commits

..

33 Commits

Author SHA1 Message Date
zsyg
f4e871e80e 添加图标 2025-08-01 12:09:09 +08:00
zsyg
43f4be4a0f 修改版本号 2025-08-01 12:07:50 +08:00
zsyg
cedfe32b15 添加内置工具 2025-08-01 12:06:49 +08:00
zsyg
1a31b70fbb 添加哈希提取器代码 2025-08-01 11:11:21 +08:00
zsyg
8805b12223 添加哈希值提取器程序 2025-08-01 11:10:10 +08:00
zsyg
70534c06db 修改版本号 2025-07-28 13:02:03 +08:00
zsyg
9e11e66e03 添加应用卡片图标 2025-07-27 11:26:01 +08:00
zsyg
4b8283574a 添加应用卡片 2025-07-27 11:23:50 +08:00
zsyg
de48557786 Update README.md 2025-07-27 08:24:46 +08:00
zsyg
aa739e8d9e Update README.md 2025-07-27 08:23:35 +08:00
zsyg
924684918c Update README.md 2025-07-27 08:22:23 +08:00
zsyg
76bb4d1b50 完善下载机制 2025-07-27 08:16:32 +08:00
zsyg
94fafdb3ed 2025-07-26 16:07:43 +08:00
zsyg
b09175550e 添加luanti软件图标 2025-07-26 08:22:29 +08:00
zsyg
c3b5e3fe66 修改版本号 2025-07-26 08:21:30 +08:00
zsyg
1cad6573e2 添加应用卡片 2025-07-26 08:20:50 +08:00
zsyg
d01b7a4b5a 修改版本号 2025-07-24 08:09:15 +08:00
zsyg
7d393aa817 添加更多应用卡片 2025-07-24 08:08:43 +08:00
zsyg
f28ec55eaf 修改协议漏洞
zsyg改zs-yg
2025-07-23 19:14:15 +08:00
zsyg
cbf4a2bc2d 修改版本号 2025-07-23 08:20:30 +08:00
zsyg
9269032315 修改freemove描述 2025-07-22 17:28:56 +08:00
zsyg
3c6117933c 修改描述 2025-07-22 15:23:29 +08:00
zsyg
59c6ae623e Add files via upload 2025-07-22 13:59:26 +08:00
zsyg
6ff1506bc2 Add files via upload 2025-07-22 13:57:52 +08:00
zsyg
b8b8b03713 修改cmake配置 2025-07-21 20:54:14 +08:00
zsyg
104aba01da Add files via upload 2025-07-20 13:25:35 +08:00
zsyg
a93e4d67f4 Add files via upload 2025-07-20 13:24:20 +08:00
zsyg
d1c62f4488 Add files via upload 2025-07-20 13:22:11 +08:00
zsyg
f4f4d86faa Add files via upload 2025-07-20 13:21:19 +08:00
zsyg
4c13fe0008 修改版本号 2025-07-20 13:16:24 +08:00
zsyg
6a931e9a85 添加部分软件注释 2025-07-20 10:34:37 +08:00
zsyg
916c944a90 Update README.md 2025-07-20 09:08:15 +08:00
zsyg
996d73f9fe 提供部分软件描述 2025-07-20 08:58:28 +08:00
38 changed files with 1743 additions and 920 deletions

View File

@@ -51,7 +51,7 @@ namespace AppStore
// 初始化并添加应用信息
infoLabel = new Label();
infoLabel.Text = "kortapp-z\n版本: 1.3.3\n作者: zs-yg\n一个简单、开源的应用商店\nkortapp-z是完全免费\n基于.NET8和C/C++的软件";
infoLabel.Text = "kortapp-z\n版本: 1.3.8\n作者: zs-yg\n一个简单、开源的应用商店\nkortapp-z是完全免费\n基于.NET8和C/C++的软件";
infoLabel.Font = new Font("Microsoft YaHei", 12);
infoLabel.AutoSize = false;
infoLabel.Width = 300;
@@ -125,7 +125,7 @@ namespace AppStore
}
}
// 保留原AboutForm作为容器(可选)
// 保留原AboutForm作为容器
public class AboutForm : Form
{
public AboutForm()

View File

@@ -15,6 +15,7 @@ namespace AppStore
private Label nameLabel;
private Panel namePanel;
private Button downloadBtn;
private ToolTip? toolTip;
private Color borderColor = SystemColors.ControlDark;
private static readonly ConcurrentDictionary<string, System.Drawing.Drawing2D.GraphicsPath> PathCache =
new ConcurrentDictionary<string, System.Drawing.Drawing2D.GraphicsPath>();
@@ -22,6 +23,7 @@ namespace AppStore
public string AppName { get; set; } = string.Empty;
public Image AppIcon { get; set; } = SystemIcons.Application.ToBitmap();
public string DownloadUrl { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty;
public bool ShowDownloadButton { get; set; } = true;
public AppCard()
@@ -126,6 +128,13 @@ namespace AppStore
this.Controls.Add(namePanel);
}
// 初始化ToolTip控件
toolTip = new ToolTip();
toolTip.AutoPopDelay = 5000;
toolTip.InitialDelay = 500;
toolTip.ReshowDelay = 500;
toolTip.ShowAlways = true;
// 下载按钮 - 添加null检查
if (downloadBtn != null)
{
@@ -144,6 +153,10 @@ namespace AppStore
if (downloadBtn != null)
{
downloadBtn.BackColor = Color.FromArgb(0, 150, 255);
if (!string.IsNullOrEmpty(Description))
{
toolTip.SetToolTip(downloadBtn, Description);
}
}
};
@@ -373,7 +386,7 @@ namespace AppStore
try
{
var safePath = path ?? CalculatePathFallback(Width, Height, 10);
// 更严格的null检查包括路径和控件状态
// 更严格的null检查,包括路径和控件状态
if (safePath != null &&
safePath.PointCount > 0 &&
this.IsHandleCreated &&
@@ -450,7 +463,7 @@ namespace AppStore
try
{
// 更严格的null检查
// 更严格的null检查包括DownloadManager.Instance和其方法
// 更严格的null检查,包括DownloadManager.Instance和其方法
// 全面的null和状态检查
var downloadManager = DownloadManager.Instance;
if (sender == null || e == null ||

View File

@@ -1,4 +1,5 @@
using System;
using System.Diagnostics;
using System.Drawing;
using System.Windows.Forms;
@@ -14,6 +15,7 @@ namespace AppStore
public string FileName { get; set; } = string.Empty;
public int Progress { get; set; }
public string Status { get; set; } = string.Empty;
public Process? DownloadProcess { get; set; }
public DownloadItem()
{
@@ -123,9 +125,26 @@ namespace AppStore
try
{
// 1. 先取消下载
DownloadManager.Instance.CancelDownload(this);
// 2. 更新状态为已取消
Status = "已取消";
UpdateDisplay();
// 3. 延迟100ms后移除控件确保UI更新完成
var timer = new System.Windows.Forms.Timer { Interval = 100 };
timer.Tick += (s, args) =>
{
timer.Stop();
timer.Dispose();
if (this.Parent != null)
{
this.Parent.Controls.Remove(this);
this.Dispose();
}
};
timer.Start();
}
catch (Exception ex)
{

View File

@@ -24,7 +24,6 @@ namespace AppStore
private static DownloadManager instance = null!;
public static DownloadManager Instance => instance ??= new DownloadManager();
private Process? currentProcess;
public List<DownloadItem> DownloadItems { get; } = new List<DownloadItem>();
public event Action<DownloadItem> DownloadAdded = delegate { };
@@ -59,7 +58,7 @@ namespace AppStore
}
catch
{
// 忽略所有异常使用默认值
// 忽略所有异常,使用默认值
}
return result;
@@ -78,6 +77,8 @@ namespace AppStore
Status = "准备下载"
};
// 创建进程并关联到下载项
downloadItem.DownloadProcess = new Process();
DownloadItems.Add(downloadItem);
DownloadAdded?.Invoke(downloadItem);
@@ -115,7 +116,7 @@ namespace AppStore
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
"Downloads");
Logger.LogError($"下载路径{downloadsDir}不可用将使用默认路径: {defaultPath}", ex);
Logger.LogError($"下载路径{downloadsDir}不可用,将使用默认路径: {defaultPath}", ex);
downloadsDir = defaultPath;
Directory.CreateDirectory(downloadsDir);
}
@@ -137,9 +138,7 @@ namespace AppStore
var arguments = $"--out=\"{originalFileName}\" --dir=\"{downloadsDir}\" --split=16 --max-connection-per-server=16 {url}";
currentProcess = new Process
{
StartInfo = new ProcessStartInfo
downloadItem.DownloadProcess.StartInfo = new ProcessStartInfo
{
FileName = aria2cPath,
Arguments = arguments,
@@ -148,7 +147,6 @@ namespace AppStore
CreateNoWindow = true,
RedirectStandardOutput = true,
RedirectStandardError = true
}
};
// 获取目标文件路径
@@ -170,7 +168,7 @@ namespace AppStore
}
};
currentProcess.OutputDataReceived += (sender, e) =>
downloadItem.DownloadProcess.OutputDataReceived += (sender, e) =>
{
if (!string.IsNullOrEmpty(e.Data))
{
@@ -211,7 +209,7 @@ namespace AppStore
}
};
currentProcess.ErrorDataReceived += (sender, e) =>
downloadItem.DownloadProcess.ErrorDataReceived += (sender, e) =>
{
if (!string.IsNullOrEmpty(e.Data))
{
@@ -221,9 +219,9 @@ namespace AppStore
}
};
currentProcess.Exited += (sender, e) =>
downloadItem.DownloadProcess.Exited += (sender, e) =>
{
var process = currentProcess;
var process = downloadItem.DownloadProcess;
if (process == null) return;
var result = GetProcessResult(process);
@@ -292,10 +290,8 @@ namespace AppStore
}
finally
{
if (process != null)
{
currentProcess = null;
}
// 清理资源
downloadItem.DownloadProcess = null;
}
// 强制更新显示
@@ -304,13 +300,13 @@ namespace AppStore
if (!currentProcess.Start())
if (!downloadItem.DownloadProcess.Start())
{
throw new Exception("进程启动失败");
}
currentProcess.BeginOutputReadLine();
currentProcess.BeginErrorReadLine();
downloadItem.DownloadProcess.BeginOutputReadLine();
downloadItem.DownloadProcess.BeginErrorReadLine();
progressTimer.Start();
}
catch (Exception ex)
@@ -333,7 +329,7 @@ namespace AppStore
{
try
{
var process = currentProcess;
var process = item.DownloadProcess;
if (process?.StartInfo == null || process.HasExited)
{
item.Status = "已取消";
@@ -343,7 +339,7 @@ namespace AppStore
process.Kill();
process.Dispose();
currentProcess = null;
item.DownloadProcess = null;
item.Status = "已取消";
DownloadProgressChanged?.Invoke(item);

View File

@@ -1,6 +1,6 @@
MIT License
Copyright (c) 2025 zsyg
Copyright (c) 2025 zs-yg
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

File diff suppressed because it is too large Load Diff

View File

@@ -1,20 +1,20 @@
# Kortapp-z - Windows应用商店 --主张软件开源、免费拒绝广告
# Kortapp-z - Windows应用商店 --主张软件开源、免费,拒绝广告
小立一个flag从不接受广告不停更新
小立一个flag从不接受广告,不停更新
## 项目开源行为
1. 项目代码开源允许任何人使用、修改、分发、商用但必须注明原作者。
2. 项目图标、截图等资源开源允许任何人使用、修改、分发、商用但必须注明原作者。
1. 项目代码开源,允许任何人使用、修改、分发、商用,但必须注明原作者。
2. 项目图标、截图等资源开源,允许任何人使用、修改、分发、商用,但必须注明原作者。
3. 项目的任何衍生品包括但不限于网站、APP、插件等必须遵循以上开源协议。
4. 项目不接受任何形式的广告不得在任何地方投放广告。
4. 项目不接受任何形式的广告,不得在任何地方投放广告。
5. 项目不接受任何形式的捐赠、赞助
6. 项目可以进行PR欢迎任何形式的PR不提交issue也可以
7. 本项目可以PR一些你自己的项目如果star数量不到1k都会被删除
6. 项目可以进行PR,欢迎任何形式的PR,不提交issue也可以
7. 本项目可以PR一些你自己的项目,如果star数量不到1k,都会被删除
## 项目简介
一个简单的Windows应用商店应用提供软件下载和管理功能。
一个简单的Windows应用商店应用,提供软件下载和管理功能。
提供软件管理、下载管理、内置工具使用等功能
## 功能特点
@@ -44,7 +44,7 @@ dotnet publish AppStore.csproj -c Release -r win-x86 --self-contained false /p:O
dotnet publish AppStore.csproj -c Release -r win-x64 --self-contained false /p:Optimize=true /p:DebugType=None
```
打包后的可执行文件将包含指定的应用程序图标输出路径为:
打包后的可执行文件将包含指定的应用程序图标,输出路径为:
```
bin\Release\net8.0-windows\[platform]\publish
```
@@ -83,13 +83,15 @@ Copyright (c) 2025 zsyg
## 其他网站
gitee镜像仓库:https://gitee.com/chr_super/kortapp-z (目前已经停止维护)
gitee镜像仓库:https://gitee.com/chr_super/kortapp-z (目前已经停止维护,仅镜像代码)
sourceforge镜像仓库:https://sourceforge.net/projects/kortapp-z/ 提供releases镜像
## 维护
由于gitee我没怎么用而且操作麻烦gitee镜像将不会继续同步有懂得人可以帮我搞下镜像吗qq 3872006562也可以b站直接私信我会在readme中鸣谢的谢谢各位
由于和Daye发生了矛盾所以windowscleaner将永远不上架我要自己努力
提示由于github上传文件的限制img/png/NET.png请改名为.NET.png否则程序可能出现无法预料的问题
由于gitee我没怎么用,而且操作麻烦,gitee镜像将不会继续同步,有懂得人可以帮我搞下镜像吗,qq 3872006562,也可以b站直接私信,我会在readme中鸣谢的,谢谢各位
由于和Daye发生了矛盾,所以windowscleaner将永远不上架,我要自己努力
提示由于github上传文件的限制,img/png/NET.png,请改名为.NET.png,否则程序可能出现无法预料的问题
每一个人都可以通过PR添加属于自己的合法软件

View File

@@ -205,7 +205,7 @@ namespace AppStore
var jsonData = JsonSerializer.Deserialize<JsonElement>(jsonString);
string customPath = jsonData.GetProperty("DownloadPath").GetString() ?? "";
// 如果自定义路径有效则显示否则显示默认路径
// 如果自定义路径有效则显示,否则显示默认路径
txtBox.Text = !string.IsNullOrWhiteSpace(customPath) ? customPath : defaultPath;
}
else

View File

@@ -1,4 +1,4 @@
首先如果希望编译程序那么必须安装.NET8.0 SDK
首先,如果希望编译程序,那么必须安装.NET8.0 SDK
下载链接https://dotnet.microsoft.com/zh-cn/download/dotnet/thank-you/sdk-8.0.411-windows-x64-installer
使用一下指令编译

View File

@@ -1,4 +1,4 @@
如果希望运行那么必须安装.NET8.0 SDK
如果希望运行,那么必须安装.NET8.0 SDK
下载链接https://dotnet.microsoft.com/zh-cn/download/dotnet/thank-you/sdk-8.0.411-windows-x64-installer

View File

@@ -32,7 +32,7 @@ namespace AppStore
}
catch
{
// 忽略错误使用默认主题
// 忽略错误,使用默认主题
}
return ThemeMode.Light;
}

View File

@@ -15,13 +15,13 @@
<main>
<section class="about-project">
<h2>项目简介</h2>
<p>kortapp-z是一个专为Windows系统设计的实用工具集合旨在提供一站式的系统优化和管理解决方案。</p>
<p>项目始于2025年由热爱效率工具的开发者创建。</p>
<p>kortapp-z是一个专为Windows系统设计的实用工具集合,旨在提供一站式的系统优化和管理解决方案。</p>
<p>项目始于2025年,由热爱效率工具的开发者创建。</p>
</section>
<section class="team">
<h2>开发团队</h2>
<p>我们的团队由经验丰富的开发人员组成专注于创建高质量的系统工具。</p>
<p>我们的团队由经验丰富的开发人员组成,专注于创建高质量的系统工具。</p>
<ul>
<li>核心开发者: 1人</li>
<li>UI设计师: 1人</li>
@@ -31,7 +31,7 @@
<section class="contact">
<h2>联系我们</h2>
<p>如有任何问题或建议欢迎通过GitHub提交issue或pull request。</p>
<p>如有任何问题或建议,欢迎通过GitHub提交issue或pull request。</p>
<a href="https://github.com/zs-yg/kortapp-z/issues" target="_blank">提交反馈</a>
</section>
</main>

View File

@@ -17,7 +17,21 @@
<h2>核心功能</h2>
<article class="feature">
<h3>目前没有什么东西,别看了,害羞(✿◡‿◡)
<h3>应用程序管理</h3>
<p>批量安装、卸载(目前没有)和更新应用程序(目前没有),管理启动项(目前没有)。</p>
<p>优势:集中管理所有应用,节省时间,避免系统臃肿。</p>
</article>
<article class="feature">
<h3>资源监控(之后可能在内置工具里有)</h3>
<p>实时监控CPU、内存、磁盘和网络使用情况。</p>
<p>优势:直观的图表展示,及时发现资源瓶颈。</p>
</article>
<article class="feature">
<h3>文件管理(之后可能在内置工具里有)</h3>
<p>高级文件搜索、批量重命名和快速文件分类。</p>
<p>优势:提升文件管理效率,支持正则表达式搜索。</p>
</article>
</section>
</main>

BIN
img/png/FreeMove.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

BIN
img/png/Luanti.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
img/png/keycloak.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 889 KiB

View File

@@ -1,8 +1,8 @@
; 脚本由 Inno Setup 脚本向导生成。
; 有关创建 Inno Setup 脚本文件的详细信息请参阅帮助文档!
; 有关创建 Inno Setup 脚本文件的详细信息,请参阅帮助文档!
#define MyAppName "kortapp-z"
#define MyAppVersion "1.3.3"
#define MyAppVersion "1.3.8"
#define MyAppPublisher "zsyg"
#define MyAppURL "https://github.com/zs-yg/kortapp-z"
#define MyAppExeName "kortapp-z.exe"
@@ -12,7 +12,7 @@
[Setup]
; 注意AppId 的值唯一标识此应用程序。不要在其他应用程序的安装程序中使用相同的 AppId 值。
; (若要生成新的 GUID请在 IDE 中单击 "工具|生成 GUID"。)
; (若要生成新的 GUID,请在 IDE 中单击 "工具|生成 GUID"。)
AppId={{8020EC01-6133-40BB-8B8B-0EB71E49696C}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
@@ -27,7 +27,7 @@ UninstallDisplayIcon={app}\{#MyAppExeName}
; 除 Arm 上的 x64 和 Windows 11 之外的任何平台上。
ArchitecturesAllowed=x64compatible
; "ArchitecturesInstallIn64BitMode=x64compatible" 要求
; 安装可以在 x64 或 Arm 上的 Windows 11 上以“64 位模式”完成
; 安装可以在 x64 或 Arm 上的 Windows 11 上以“64 位模式”完成,
; 这意味着它应该使用本机 64 位 Program Files 目录和
; 注册表的 64 位视图。
ArchitecturesInstallIn64BitMode=x64compatible

View File

@@ -1,8 +1,8 @@
; 脚本由 Inno Setup 脚本向导生成。
; 有关创建 Inno Setup 脚本文件的详细信息请参阅帮助文档!
; 有关创建 Inno Setup 脚本文件的详细信息,请参阅帮助文档!
#define MyAppName "kortapp-z"
#define MyAppVersion "1.3.3"
#define MyAppVersion "1.3.8"
#define MyAppPublisher "zsyg"
#define MyAppURL "https://github.com/zs-yg/kortapp-z"
#define MyAppExeName "kortapp-z.exe"
@@ -12,7 +12,7 @@
[Setup]
; 注意AppId 的值唯一标识此应用程序。不要在其他应用程序的安装程序中使用相同的 AppId 值。
; (若要生成新的 GUID请在 IDE 中单击 "工具|生成 GUID"。)
; (若要生成新的 GUID,请在 IDE 中单击 "工具|生成 GUID"。)
AppId={{BF1944C3-CD0C-4119-A340-49C54961D48B}
AppName={#MyAppName}
AppVersion={#MyAppVersion}

View File

@@ -44,7 +44,7 @@ int main() {
}
}
} else {
std::cout << "日志目录不存在无需清理" << std::endl;
std::cout << "日志目录不存在,无需清理" << std::endl;
return 0;
}

View File

@@ -28,6 +28,9 @@ find_library(AVIF_STATIC_LIB NAMES libavif.a PATHS ${AVIF_LIBRARY_DIRS})
find_package(FLTK REQUIRED)
find_library(FLTK_STATIC_LIB NAMES libfltk.a PATHS ${FLTK_LIBRARY_DIRS})
# 查找cairo导入库
find_library(CAIRO_IMPORT_LIB NAMES libcairo.dll.a PATHS "C:/msys64/ucrt64/lib")
# 查找其他依赖库
find_library(JPEG_STATIC_LIB NAMES libjpeg.a PATHS ${MSYS2_LIB_DIR})
find_library(ZLIB_STATIC_LIB NAMES libz.a PATHS ${MSYS2_LIB_DIR})
@@ -44,7 +47,7 @@ find_library(RAV1E_STATIC_LIB NAMES librav1e.a PATHS ${MSYS2_LIB_DIR})
find_library(DAV1D_STATIC_LIB NAMES libdav1d.a PATHS ${MSYS2_LIB_DIR})
# 包含头文件目录
include_directories(include ${TIFF_INCLUDE_DIRS} ${WEBP_INCLUDE_DIRS} ${FLTK_INCLUDE_DIRS} ${AVIF_INCLUDE_DIRS})
include_directories(include ${TIFF_INCLUDE_DIRS} ${WEBP_INCLUDE_DIRS} ${FLTK_INCLUDE_DIRS} ${AVIF_INCLUDE_DIRS} "C:/msys64/ucrt64/include/cairo")
# 收集所有源文件
file(GLOB SOURCES "src/*.cpp")
@@ -71,6 +74,9 @@ target_link_libraries(ImageFormatConverter
${SVTAV1_ENC_STATIC_LIB}
${RAV1E_STATIC_LIB}
${DAV1D_STATIC_LIB}
${CAIRO_IMPORT_LIB}
"C:/msys64/ucrt64/lib/libcairo.a"
-lgdi32 -lmsimg32 # 添加Windows图形库
-lstdc++ -lgcc -lwinpthread -lcomctl32 -lole32 -luuid -lws2_32 -lntdll)
# 设置输出目录

View File

@@ -272,6 +272,6 @@ void MainWindow::convert_cb(Fl_Widget* w, void* data) {
if (success) {
fl_message("转换成功!");
} else {
fl_alert("转换失败请检查输入文件!");
fl_alert("转换失败,请检查输入文件!");
}
}

View File

@@ -130,7 +130,7 @@ ImageData ImageLoader::load(const std::string& path) {
throw std::runtime_error("无法解码WebP图像");
}
// 如果没有alpha通道转换为RGB格式
// 如果没有alpha通道,转换为RGB格式
if (data.channels == 3) {
uint8_t* rgb_pixels = new uint8_t[data.width * data.height * 3];
for (int i = 0; i < data.width * data.height; ++i) {

View File

@@ -9,7 +9,7 @@ public:
static std::string getVersion() { return "1.0.0"; }
static std::string getAuthor() { return "zsyg"; }
static std::string getDescription() {
return "一个简单的文本转换工具支持文本转换";
return "一个简单的文本转换工具,支持文本转换";
}
};

View File

@@ -5,18 +5,6 @@
#include "Converter.hpp"
#include "BinaryConverter.hpp"
#include "HexConverter.hpp"
#include "ROT13Converter.hpp"
#include "MD5Converter.hpp"
#include "SHA1Converter.hpp"
#include "SHA256Converter.hpp"
#include "SHA224Converter.hpp"
#include "SHA384Converter.hpp"
#include "SHA512Converter.hpp"
#include "SHA3Converter.hpp"
#include "Base64Converter.hpp"
#include "Base32Converter.hpp"
#include "Ascii85Converter.hpp"
#include "CRC32Converter.hpp"
class Utils {
public:

View File

@@ -11,7 +11,7 @@ std::string BinaryConverter::convert(const std::string& input) {
std::stringstream result;
for (char c : input) {
std::string binary = std::bitset<8>(c).to_string();
// 去除前导0保留后6位
// 去除前导0,保留后6位
size_t firstOne = binary.find('1');
if (firstOne != std::string::npos) {
binary = binary.substr(firstOne);

View File

@@ -22,10 +22,6 @@ MainWindow::MainWindow(int w, int h, const char* title) : Fl_Window(w, h, title)
conversionType->add("MD5");
conversionType->add("SHA1");
conversionType->add("SHA256");
conversionType->add("SHA224");
conversionType->add("SHA384");
conversionType->add("SHA512");
conversionType->add("SHA3");
conversionType->add("Base64");
conversionType->add("Base32");
conversionType->add("Ascii85");
@@ -52,7 +48,6 @@ void MainWindow::ConvertCallback(Fl_Widget* widget, void* data) {
}
void MainWindow::ConvertText() {
try {
const char* input = inputText->value();
if (!input || strlen(input) == 0) {
fl_alert("请输入要转换的文本");
@@ -68,9 +63,4 @@ void MainWindow::ConvertText() {
std::string result = converter->convert(input);
outputText->value(result.c_str());
} catch (const std::exception& e) {
fl_alert(("转换失败: " + std::string(e.what())).c_str());
} catch (...) {
fl_alert("未知错误: 转换失败");
}
}

View File

@@ -3,10 +3,6 @@
#include "../include/MD5Converter.hpp"
#include "../include/SHA1Converter.hpp"
#include "../include/SHA256Converter.hpp"
#include "../include/SHA224Converter.hpp"
#include "../include/SHA384Converter.hpp"
#include "../include/SHA512Converter.hpp"
#include "../include/SHA3Converter.hpp"
#include "../include/Base64Converter.hpp"
#include "../include/Base32Converter.hpp"
#include "../include/Ascii85Converter.hpp"
@@ -24,10 +20,6 @@ std::unique_ptr<Converter> Utils::createConverter(int type) {
case 7: return std::unique_ptr<Converter>(new Base32Converter());
case 8: return std::unique_ptr<Converter>(new Ascii85Converter());
case 9: return std::unique_ptr<Converter>(new CRC32Converter());
case 10: return std::unique_ptr<Converter>(new SHA224Converter());
case 11: return std::unique_ptr<Converter>(new SHA384Converter());
case 12: return std::unique_ptr<Converter>(new SHA512Converter());
case 13: return std::unique_ptr<Converter>(new SHA3Converter());
default: return nullptr;
}
}

View File

@@ -0,0 +1,55 @@
cmake_minimum_required(VERSION 3.10)
project(hash_value_extractor)
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
# 静态编译选项
option(BUILD_STATIC "Build with static linking" ON)
# 查找OpenSSL
find_package(OpenSSL REQUIRED)
# 设置Windows子系统
if(WIN32)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -mwindows")
if(BUILD_STATIC)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
set(CMAKE_FIND_LIBRARY_SUFFIXES .a)
set(CMAKE_EXE_LINK_DYNAMIC_C_FLAGS)
set(CMAKE_EXE_LINK_DYNAMIC_CXX_FLAGS)
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS)
set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS)
endif()
endif()
# 包含目录
include_directories(include)
# 添加可执行文件
add_executable(hash_value_extractor
src/main.c
src/md5.c
src/sha256.c
src/sha512.c
src/string_util.c
)
# 链接OpenSSL库
if(BUILD_STATIC)
# 显式指定静态库路径和名称
find_library(OPENSSL_SSL_STATIC_LIBRARY NAMES ssl libssl.a PATHS ${OPENSSL_ROOT_DIR}/lib)
find_library(OPENSSL_CRYPTO_STATIC_LIBRARY NAMES crypto libcrypto.a PATHS ${OPENSSL_ROOT_DIR}/lib)
target_link_libraries(hash_value_extractor
${OPENSSL_SSL_STATIC_LIBRARY}
${OPENSSL_CRYPTO_STATIC_LIBRARY}
-lcrypt32
-lws2_32
)
else()
target_link_libraries(hash_value_extractor
OpenSSL::SSL
OpenSSL::Crypto
)
endif()

View File

@@ -0,0 +1,37 @@
#ifndef HASH_CALCULATOR_H
#define HASH_CALCULATOR_H
#include <stddef.h>
typedef enum {
HASH_MD5,
HASH_SHA256,
HASH_SHA512
} HashAlgorithm;
// 各算法计算函数
int calculate_md5(const char* filename, char* output);
int calculate_sha256(const char* filename, char* output);
int calculate_sha512(const char* filename, char* output);
/**
* 计算文件的哈希值
* @param filename 文件路径
* @param algorithm 哈希算法
* @param output 输出缓冲区(必须足够大)
* @return 成功返回0失败返回-1
*/
static inline int calculate_file_hash(const char* filename, HashAlgorithm algorithm, char* output) {
switch (algorithm) {
case HASH_MD5:
return calculate_md5(filename, output);
case HASH_SHA256:
return calculate_sha256(filename, output);
case HASH_SHA512:
return calculate_sha512(filename, output);
default:
return -1;
}
}
#endif // HASH_CALCULATOR_H

View File

@@ -0,0 +1,21 @@
#ifndef STRING_UTIL_H
#define STRING_UTIL_H
#include <stddef.h>
// 快速分配字符串内存
char* str_alloc(size_t size);
// 快速释放字符串内存
void str_free(char* str);
// 快速字符串复制
char* str_copy(const char* src);
// 快速字符串连接
char* str_concat(const char* str1, const char* str2);
// 二进制转十六进制字符串
char* bin_to_hex(const unsigned char* data, size_t len);
#endif // STRING_UTIL_H

View File

@@ -0,0 +1,53 @@
#include "hash_calculator.h"
#include <openssl/md5.h>
#include <openssl/sha.h>
#include <stdio.h>
#include <stdlib.h>
int calculate_file_hash(const char* filename, HashAlgorithm algorithm, char* output) {
FILE* file = fopen(filename, "rb");
if (!file) return -1;
const EVP_MD* md = NULL;
EVP_MD_CTX* mdctx = EVP_MD_CTX_new();
unsigned char hash[EVP_MAX_MD_SIZE];
unsigned int hash_len = 0;
switch (algorithm) {
case HASH_MD5:
md = EVP_md5();
break;
case HASH_SHA256:
md = EVP_sha256();
break;
case HASH_SHA512:
md = EVP_sha512();
break;
default:
fclose(file);
return -1;
}
EVP_DigestInit_ex(mdctx, md, NULL);
unsigned char buffer[1024];
size_t bytes_read;
while ((bytes_read = fread(buffer, 1, sizeof(buffer), file))) {
EVP_DigestUpdate(mdctx, buffer, bytes_read);
}
EVP_DigestFinal_ex(mdctx, hash, &hash_len);
EVP_MD_CTX_free(mdctx);
fclose(file);
hash_to_hex(hash, hash_len, output);
return 0;
}
void hash_to_hex(const unsigned char* hash, size_t hash_len, char* output) {
for (size_t i = 0; i < hash_len; i++) {
sprintf(output + (i * 2), "%02x", hash[i]);
}
output[hash_len * 2] = '\0';
}
</fitten_content>

View File

@@ -0,0 +1,204 @@
// 确保使用Unicode字符集
#define UNICODE
#define _UNICODE
#include <windows.h>
#include <commdlg.h>
#include "hash_calculator.h"
#include <openssl/evp.h>
#include <wchar.h>
#define IDC_ALGORITHM_COMBO 1001
#define IDC_FILE_EDIT 1002
#define IDC_HASH_EDIT 1003
#define IDC_BROWSE_BUTTON 1004
#define IDC_CALCULATE_BUTTON 1005
#define IDC_COPY_BUTTON 1006
// 中文UI字符串定义
static const wchar_t* APP_TITLE = L"哈希值提取器";
static const wchar_t* ALGORITHMS[] = {L"MD5", L"SHA-256", L"SHA-512"};
static const wchar_t* CALCULATE_BTN = L"计算哈希";
static const wchar_t* BROWSE_BTN = L"浏览...";
static const wchar_t* COPY_BTN = L"复制哈希值";
static const wchar_t* CALC_FAILED = L"计算哈希值失败";
// 全局变量
HWND g_hAlgorithmCombo, g_hFileEdit, g_hHashEdit;
// 初始化控件
void InitControls(HWND hWnd) {
// 算法选择下拉框
g_hAlgorithmCombo = CreateWindowW(L"COMBOBOX", NULL,
WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST | WS_VSCROLL,
10, 10, 200, 200, hWnd, (HMENU)IDC_ALGORITHM_COMBO, NULL, NULL);
// 添加算法选项
SendMessageW(g_hAlgorithmCombo, CB_ADDSTRING, 0, (LPARAM)L"MD5");
SendMessageW(g_hAlgorithmCombo, CB_ADDSTRING, 0, (LPARAM)L"SHA-256");
SendMessageW(g_hAlgorithmCombo, CB_ADDSTRING, 0, (LPARAM)L"SHA-512");
SendMessageW(g_hAlgorithmCombo, CB_SETCURSEL, 0, 0);
// 文件路径编辑框
g_hFileEdit = CreateWindowW(L"EDIT", NULL,
WS_CHILD | WS_VISIBLE | WS_BORDER | ES_AUTOHSCROLL,
10, 40, 300, 25, hWnd, (HMENU)IDC_FILE_EDIT, NULL, NULL);
// 浏览按钮
CreateWindowW(L"BUTTON", L"浏览...",
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
320, 40, 80, 25, hWnd, (HMENU)IDC_BROWSE_BUTTON, NULL, NULL);
// 计算按钮
CreateWindowW(L"BUTTON", L"计算哈希",
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
10, 75, 100, 30, hWnd, (HMENU)IDC_CALCULATE_BUTTON, NULL, NULL);
// 哈希结果显示框
g_hHashEdit = CreateWindowW(L"EDIT", NULL,
WS_CHILD | WS_VISIBLE | WS_BORDER | ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY,
10, 115, 380, 100, hWnd, (HMENU)IDC_HASH_EDIT, NULL, NULL);
// 复制按钮
CreateWindowW(L"BUTTON", L"复制哈希值",
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
10, 225, 100, 30, hWnd, (HMENU)IDC_COPY_BUTTON, NULL, NULL);
}
// 选择文件
void BrowseFile(HWND hWnd) {
OPENFILENAMEW ofn;
WCHAR szFile[MAX_PATH] = {0};
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = hWnd;
ofn.lpstrFile = szFile;
ofn.nMaxFile = sizeof(szFile)/sizeof(szFile[0]);
ofn.lpstrFilter = L"所有文件\0*.*\0";
ofn.nFilterIndex = 1;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
if (GetOpenFileNameW(&ofn)) {
SetWindowTextW(g_hFileEdit, szFile);
}
}
// 计算哈希值
void CalculateHash() {
WCHAR wszFile[MAX_PATH];
char szFile[MAX_PATH];
char szHash[EVP_MAX_MD_SIZE * 2 + 1];
GetWindowTextW(g_hFileEdit, wszFile, MAX_PATH);
WideCharToMultiByte(CP_UTF8, 0, wszFile, -1, szFile, MAX_PATH, NULL, NULL);
int algorithm = SendMessageW(g_hAlgorithmCombo, CB_GETCURSEL, 0, 0);
if (calculate_file_hash(szFile, algorithm, szHash) == 0) {
WCHAR wszHash[EVP_MAX_MD_SIZE * 2 + 1];
MultiByteToWideChar(CP_UTF8, 0, szHash, -1, wszHash, EVP_MAX_MD_SIZE * 2 + 1);
SetWindowTextW(g_hHashEdit, wszHash);
} else {
SetWindowTextW(g_hHashEdit, L"计算哈希值失败");
}
}
// 复制哈希值到剪贴板
void CopyHashToClipboard() {
if (OpenClipboard(NULL)) {
EmptyClipboard();
int len = GetWindowTextLengthW(g_hHashEdit) + 1;
HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE, len * sizeof(WCHAR));
if (hMem) {
WCHAR* pszMem = (WCHAR*)GlobalLock(hMem);
GetWindowTextW(g_hHashEdit, pszMem, len);
GlobalUnlock(hMem);
SetClipboardData(CF_UNICODETEXT, hMem);
}
CloseClipboard();
}
}
// 窗口过程
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
switch (message) {
case WM_CREATE:
InitControls(hWnd);
break;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDC_BROWSE_BUTTON:
BrowseFile(hWnd);
break;
case IDC_CALCULATE_BUTTON:
CalculateHash();
break;
case IDC_COPY_BUTTON:
CopyHashToClipboard();
break;
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
// 程序入口
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
// 注册窗口类
WNDCLASSEXW wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = NULL;
wcex.lpszClassName = L"HashValueExtractor";
wcex.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if (!RegisterClassExW(&wcex)) {
return 1;
}
// 创建窗口
HWND hWnd = CreateWindowW(
L"HashValueExtractor", L"哈希值提取器",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 420, 300,
NULL, NULL, hInstance, NULL);
if (!hWnd) {
return 1;
}
// 显示窗口
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
// 消息循环
MSG msg;
while (GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (int)msg.wParam;
}

View File

@@ -0,0 +1,35 @@
#include "hash_calculator.h"
#include "string_util.h"
#include <openssl/evp.h>
#include <stdio.h>
#include <string.h>
int calculate_md5(const char* filename, char* output) {
FILE* file = fopen(filename, "rb");
if (!file) return -1;
EVP_MD_CTX* mdctx = EVP_MD_CTX_new();
const EVP_MD* md = EVP_md5();
unsigned char hash[EVP_MAX_MD_SIZE];
unsigned int hash_len = 0;
EVP_DigestInit_ex(mdctx, md, NULL);
unsigned char buffer[1024];
size_t bytes_read;
while ((bytes_read = fread(buffer, 1, sizeof(buffer), file))) {
EVP_DigestUpdate(mdctx, buffer, bytes_read);
}
EVP_DigestFinal_ex(mdctx, hash, &hash_len);
EVP_MD_CTX_free(mdctx);
fclose(file);
char* hex = bin_to_hex(hash, hash_len);
if (hex) {
strcpy(output, hex);
str_free(hex);
return 0;
}
return -1;
}

View File

@@ -0,0 +1,35 @@
#include "hash_calculator.h"
#include "string_util.h"
#include <openssl/evp.h>
#include <stdio.h>
#include <string.h>
int calculate_sha256(const char* filename, char* output) {
FILE* file = fopen(filename, "rb");
if (!file) return -1;
EVP_MD_CTX* mdctx = EVP_MD_CTX_new();
const EVP_MD* md = EVP_sha256();
unsigned char hash[EVP_MAX_MD_SIZE];
unsigned int hash_len = 0;
EVP_DigestInit_ex(mdctx, md, NULL);
unsigned char buffer[1024];
size_t bytes_read;
while ((bytes_read = fread(buffer, 1, sizeof(buffer), file))) {
EVP_DigestUpdate(mdctx, buffer, bytes_read);
}
EVP_DigestFinal_ex(mdctx, hash, &hash_len);
EVP_MD_CTX_free(mdctx);
fclose(file);
char* hex = bin_to_hex(hash, hash_len);
if (hex) {
strcpy(output, hex);
str_free(hex);
return 0;
}
return -1;
}

View File

@@ -0,0 +1,35 @@
#include "hash_calculator.h"
#include "string_util.h"
#include <openssl/evp.h>
#include <stdio.h>
#include <string.h>
int calculate_sha512(const char* filename, char* output) {
FILE* file = fopen(filename, "rb");
if (!file) return -1;
EVP_MD_CTX* mdctx = EVP_MD_CTX_new();
const EVP_MD* md = EVP_sha512();
unsigned char hash[EVP_MAX_MD_SIZE];
unsigned int hash_len = 0;
EVP_DigestInit_ex(mdctx, md, NULL);
unsigned char buffer[1024];
size_t bytes_read;
while ((bytes_read = fread(buffer, 1, sizeof(buffer), file))) {
EVP_DigestUpdate(mdctx, buffer, bytes_read);
}
EVP_DigestFinal_ex(mdctx, hash, &hash_len);
EVP_MD_CTX_free(mdctx);
fclose(file);
char* hex = bin_to_hex(hash, hash_len);
if (hex) {
strcpy(output, hex);
str_free(hex);
return 0;
}
return -1;
}

View File

@@ -0,0 +1,120 @@
#include "string_util.h"
#include <stdlib.h>
#include <string.h>
// 内存池块大小
#define MEMORY_BLOCK_SIZE 4096
// 内存池结构
typedef struct MemoryBlock {
char* buffer;
size_t used;
struct MemoryBlock* next;
} MemoryBlock;
static MemoryBlock* memory_pool = NULL;
// 初始化内存池
static void init_memory_pool() {
if (memory_pool == NULL) {
memory_pool = malloc(sizeof(MemoryBlock));
memory_pool->buffer = malloc(MEMORY_BLOCK_SIZE);
memory_pool->used = 0;
memory_pool->next = NULL;
}
}
// 从内存池分配
static char* pool_alloc(size_t size) {
init_memory_pool();
MemoryBlock* block = memory_pool;
while (block != NULL) {
if (MEMORY_BLOCK_SIZE - block->used >= size) {
char* ptr = block->buffer + block->used;
block->used += size;
return ptr;
}
if (block->next == NULL) {
block->next = malloc(sizeof(MemoryBlock));
block = block->next;
block->buffer = malloc(MEMORY_BLOCK_SIZE);
block->used = 0;
block->next = NULL;
} else {
block = block->next;
}
}
return NULL;
}
char* str_alloc(size_t size) {
// 小内存从池分配,大内存直接分配
if (size <= MEMORY_BLOCK_SIZE / 4) {
char* ptr = pool_alloc(size + 1); // +1 for null terminator
if (ptr != NULL) {
ptr[size] = '\0';
return ptr;
}
}
char* ptr = malloc(size + 1);
if (ptr != NULL) {
ptr[size] = '\0';
}
return ptr;
}
void str_free(char* str) {
// 池分配的内存不单独释放
if (str == NULL) return;
// 检查是否在内存池中
MemoryBlock* block = memory_pool;
while (block != NULL) {
if (str >= block->buffer && str < block->buffer + MEMORY_BLOCK_SIZE) {
return; // 池内存不释放
}
block = block->next;
}
free(str);
}
char* str_copy(const char* src) {
if (src == NULL) return NULL;
size_t len = strlen(src);
char* dest = str_alloc(len);
if (dest != NULL) {
memcpy(dest, src, len);
}
return dest;
}
char* str_concat(const char* str1, const char* str2) {
if (str1 == NULL) return str_copy(str2);
if (str2 == NULL) return str_copy(str1);
size_t len1 = strlen(str1);
size_t len2 = strlen(str2);
char* result = str_alloc(len1 + len2);
if (result != NULL) {
memcpy(result, str1, len1);
memcpy(result + len1, str2, len2);
}
return result;
}
char* bin_to_hex(const unsigned char* data, size_t len) {
if (data == NULL || len == 0) return NULL;
char* hex = str_alloc(len * 2);
if (hex != NULL) {
static const char hex_chars[] = "0123456789abcdef";
for (size_t i = 0; i < len; i++) {
hex[i * 2] = hex_chars[(data[i] >> 4) & 0x0F];
hex[i * 2 + 1] = hex_chars[data[i] & 0x0F];
}
}
return hex;
}

Binary file not shown.