mirror of
https://github.com/babalae/better-genshin-impact.git
synced 2026-05-25 10:05:49 +08:00
Merge branch 'main' into d-v3
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<AssemblyName>BetterGI</AssemblyName>
|
||||
<Version>0.48.0</Version>
|
||||
<Version>0.48.1-alpha.1</Version>
|
||||
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net8.0-windows10.0.22621.0</TargetFramework>
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using BetterGenshinImpact.Helpers.Security;
|
||||
using BetterGenshinImpact.View.Windows;
|
||||
using TextBox = Wpf.Ui.Controls.TextBox;
|
||||
|
||||
@@ -11,8 +12,16 @@ namespace BetterGenshinImpact.GameTask.UseRedeemCode;
|
||||
|
||||
public class RedeemCodeManager
|
||||
{
|
||||
public static HashSet<string> CancelClipboardHash { get; } = [];
|
||||
|
||||
public static async Task ImportFromClipboard(string clipboardText)
|
||||
{
|
||||
var md5Hash = MD5Helper.ComputeMD5(clipboardText);
|
||||
if (CancelClipboardHash.Contains(md5Hash))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var codes = ExtractAllCodes(clipboardText);
|
||||
if (codes.Count == 0)
|
||||
{
|
||||
@@ -36,6 +45,11 @@ public class RedeemCodeManager
|
||||
|
||||
if (p.DialogResult != true)
|
||||
{
|
||||
if (CancelClipboardHash.Count > 10)
|
||||
{
|
||||
CancelClipboardHash.Clear();
|
||||
}
|
||||
CancelClipboardHash.Add(md5Hash);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
35
BetterGenshinImpact/Helpers/Security/MD5Helper.cs
Normal file
35
BetterGenshinImpact/Helpers/Security/MD5Helper.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace BetterGenshinImpact.Helpers.Security;
|
||||
|
||||
public static class MD5Helper
|
||||
{
|
||||
/// <summary>
|
||||
/// 计算字符串的MD5哈希值
|
||||
/// </summary>
|
||||
/// <param name="input">输入字符串</param>
|
||||
/// <param name="encoding">字符编码,默认为UTF-8</param>
|
||||
/// <returns>32位小写MD5哈希值</returns>
|
||||
public static string ComputeMD5(string input, Encoding encoding = null)
|
||||
{
|
||||
if (string.IsNullOrEmpty(input))
|
||||
return string.Empty;
|
||||
|
||||
encoding = encoding ?? Encoding.UTF8;
|
||||
|
||||
using (var md5 = MD5.Create())
|
||||
{
|
||||
byte[] inputBytes = encoding.GetBytes(input);
|
||||
byte[] hashBytes = md5.ComputeHash(inputBytes);
|
||||
|
||||
// 将字节数组转换为十六进制字符串
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < hashBytes.Length; i++)
|
||||
{
|
||||
sb.Append(hashBytes[i].ToString("x2"));
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -74,7 +74,8 @@ BetterGI · 更好的原神, 一个基于计算机视觉技术,意图让原
|
||||
>
|
||||
> 不知道下载哪个?第一次使用?请看:[快速上手](https://bettergi.com/quickstart.html) , 遇到问题请先看:[常见问题](https://bettergi.com/faq.html)
|
||||
|
||||
最新编译版本可以从自动构建中获取: [](https://github.com/babalae/better-genshin-impact/actions/workflows/publish.yml)
|
||||
最新测试版本可以从自动构建中获取: [](https://github.com/babalae/better-genshin-impact/actions/workflows/publish.yml)
|
||||
或者从CNB上直接下载(速度快):[CNB Releases](https://cnb.cool/bettergi/better-genshin-impact/-/releases)
|
||||
|
||||
## 使用方法
|
||||
由于图像识别比较吃性能,低配置电脑可能无法正常使用部分功能。
|
||||
|
||||
Reference in New Issue
Block a user