添加项目文件。
parent
cbaf2539ee
commit
7905b6f572
|
|
@ -0,0 +1,22 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 17
|
||||||
|
VisualStudioVersion = 17.12.35514.174 d17.12
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HIR-Activate", "HIR-Activate\HIR-Activate.csproj", "{01A02918-32D7-4EFF-8F04-4E1A80DBD646}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{01A02918-32D7-4EFF-8F04-4E1A80DBD646}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{01A02918-32D7-4EFF-8F04-4E1A80DBD646}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{01A02918-32D7-4EFF-8F04-4E1A80DBD646}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{01A02918-32D7-4EFF-8F04-4E1A80DBD646}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
|
|
@ -0,0 +1,153 @@
|
||||||
|
using Org.BouncyCastle.Crypto;
|
||||||
|
using Org.BouncyCastle.Crypto.Engines;
|
||||||
|
using Org.BouncyCastle.Crypto.Modes;
|
||||||
|
using Org.BouncyCastle.Crypto.Paddings;
|
||||||
|
using Org.BouncyCastle.Crypto.Parameters;
|
||||||
|
using System;
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace IRaCIS.Core.Infrastructure.Encryption;
|
||||||
|
|
||||||
|
public class AesEncryption
|
||||||
|
{
|
||||||
|
// AES 加密(不带 IV)
|
||||||
|
public static string Encrypt(string plainText, string key)
|
||||||
|
{
|
||||||
|
var keyBytes = Encoding.UTF8.GetBytes(key);
|
||||||
|
|
||||||
|
// 使用 AES 引擎 + PKCS7 填充
|
||||||
|
var engine = new AesEngine();
|
||||||
|
var blockCipher = new PaddedBufferedBlockCipher(engine, new Pkcs7Padding());
|
||||||
|
blockCipher.Init(true, new KeyParameter(keyBytes)); // true 表示加密
|
||||||
|
|
||||||
|
var inputBytes = Encoding.UTF8.GetBytes(plainText);
|
||||||
|
var encryptedBytes = ProcessCipher(blockCipher, inputBytes);
|
||||||
|
|
||||||
|
// 返回 Base64 编码的加密字符串
|
||||||
|
return Convert.ToBase64String(encryptedBytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
// AES 解密(不带 IV)
|
||||||
|
public static string Decrypt(string encryptedText, string key)
|
||||||
|
{
|
||||||
|
var keyBytes = Encoding.UTF8.GetBytes(key);
|
||||||
|
var cipherBytes = Convert.FromBase64String(encryptedText);
|
||||||
|
|
||||||
|
// 使用 AES 引擎 + PKCS7 填充
|
||||||
|
var engine = new AesEngine();
|
||||||
|
var blockCipher = new PaddedBufferedBlockCipher(engine, new Pkcs7Padding());
|
||||||
|
blockCipher.Init(false, new KeyParameter(keyBytes)); // false 表示解密
|
||||||
|
|
||||||
|
var decryptedBytes = ProcessCipher(blockCipher, cipherBytes);
|
||||||
|
return Encoding.UTF8.GetString(decryptedBytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
// AES 加密(带 IV)
|
||||||
|
/// <summary>
|
||||||
|
/// AES 密钥的长度必须是以下之一:128 位(16 字节)192 位(24 字节)256 位(32 字节)
|
||||||
|
/// IV must be 16 bytes
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="plainText"></param>
|
||||||
|
/// <param name="key"></param>
|
||||||
|
/// <param name="iv"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string Encrypt(string plainText, string key, string iv)
|
||||||
|
{
|
||||||
|
var keyBytes = Encoding.UTF8.GetBytes(key.PadRight(32, '0').Substring(0, 32));
|
||||||
|
var ivBytes = Encoding.UTF8.GetBytes(iv.PadRight(16, '0').Substring(0, 16));
|
||||||
|
|
||||||
|
// 使用 AES 引擎 + PKCS7 填充 + CBC 模式
|
||||||
|
var engine = new AesEngine();
|
||||||
|
var blockCipher = new PaddedBufferedBlockCipher(new CbcBlockCipher(engine), new Pkcs7Padding());
|
||||||
|
blockCipher.Init(true, new ParametersWithIV(new KeyParameter(keyBytes), ivBytes)); // true 表示加密
|
||||||
|
|
||||||
|
var inputBytes = Encoding.UTF8.GetBytes(plainText);
|
||||||
|
var encryptedBytes = ProcessCipher(blockCipher, inputBytes);
|
||||||
|
|
||||||
|
// 返回 Base64 编码的加密字符串
|
||||||
|
return Convert.ToBase64String(encryptedBytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
// AES 解密(带 IV)
|
||||||
|
public static string Decrypt(string encryptedText, string key, string iv)
|
||||||
|
{
|
||||||
|
var keyBytes = Encoding.UTF8.GetBytes(key.PadRight(32, '0').Substring(0, 32));
|
||||||
|
var ivBytes = Encoding.UTF8.GetBytes(iv.PadRight(16, '0').Substring(0, 16));
|
||||||
|
var cipherBytes = Convert.FromBase64String(encryptedText);
|
||||||
|
|
||||||
|
// 使用 AES 引擎 + PKCS7 填充 + CBC 模式
|
||||||
|
var engine = new AesEngine();
|
||||||
|
var blockCipher = new PaddedBufferedBlockCipher(new CbcBlockCipher(engine), new Pkcs7Padding());
|
||||||
|
blockCipher.Init(false, new ParametersWithIV(new KeyParameter(keyBytes), ivBytes)); // false 表示解密
|
||||||
|
|
||||||
|
var decryptedBytes = ProcessCipher(blockCipher, cipherBytes);
|
||||||
|
return Encoding.UTF8.GetString(decryptedBytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理加密/解密数据
|
||||||
|
private static byte[] ProcessCipher(IBufferedCipher cipher, byte[] input)
|
||||||
|
{
|
||||||
|
var output = new byte[cipher.GetOutputSize(input.Length)];
|
||||||
|
int length = cipher.ProcessBytes(input, 0, input.Length, output, 0);
|
||||||
|
length += cipher.DoFinal(output, length);
|
||||||
|
Array.Resize(ref output, length); // 调整输出数组大小以适应实际数据长度
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string DefaultKey = "12345678901234567890123456789012";
|
||||||
|
|
||||||
|
public static string EncryptPartial(string plainText, int unencryptedPrefixLength)
|
||||||
|
{
|
||||||
|
if (plainText.Length <= unencryptedPrefixLength)
|
||||||
|
{
|
||||||
|
return Encrypt(plainText, DefaultKey); // 如果文本太短,直接加密
|
||||||
|
}
|
||||||
|
|
||||||
|
var prefix = plainText.Substring(0, unencryptedPrefixLength);
|
||||||
|
var suffix = plainText.Substring(unencryptedPrefixLength);
|
||||||
|
|
||||||
|
return prefix + Encrypt(suffix, DefaultKey); // 前缀保留,后缀加密
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string DecryptPartial(string encryptedText, int unencryptedPrefixLength)
|
||||||
|
{
|
||||||
|
if (encryptedText.Length <= unencryptedPrefixLength)
|
||||||
|
{
|
||||||
|
return Decrypt(encryptedText, DefaultKey); // 如果文本太短,直接解密
|
||||||
|
}
|
||||||
|
|
||||||
|
var prefix = encryptedText.Substring(0, unencryptedPrefixLength);
|
||||||
|
var suffix = encryptedText.Substring(unencryptedPrefixLength);
|
||||||
|
|
||||||
|
return prefix + Decrypt(suffix, DefaultKey); // 前缀保留,后缀解密
|
||||||
|
}
|
||||||
|
|
||||||
|
//public static string Encrypt(string plainText)
|
||||||
|
//{
|
||||||
|
// using var aes = Aes.Create();
|
||||||
|
// aes.Key = Encoding.UTF8.GetBytes(EncryptionKey);
|
||||||
|
// aes.Mode = CipherMode.ECB; // 根据需要选择加密模式,这里使用 ECB 模式
|
||||||
|
// aes.Padding = PaddingMode.PKCS7;
|
||||||
|
|
||||||
|
// var encryptor = aes.CreateEncryptor();
|
||||||
|
// var plainBytes = Encoding.UTF8.GetBytes(plainText);
|
||||||
|
// var encryptedBytes = encryptor.TransformFinalBlock(plainBytes, 0, plainBytes.Length);
|
||||||
|
|
||||||
|
// return Convert.ToBase64String(encryptedBytes);
|
||||||
|
//}
|
||||||
|
|
||||||
|
//public static string Decrypt(string encryptedText)
|
||||||
|
//{
|
||||||
|
// using var aes = Aes.Create();
|
||||||
|
// aes.Key = Encoding.UTF8.GetBytes(EncryptionKey);
|
||||||
|
// aes.Mode = CipherMode.ECB;
|
||||||
|
// aes.Padding = PaddingMode.PKCS7;
|
||||||
|
|
||||||
|
// var decryptor = aes.CreateDecryptor();
|
||||||
|
// var encryptedBytes = Convert.FromBase64String(encryptedText);
|
||||||
|
// var decryptedBytes = decryptor.TransformFinalBlock(encryptedBytes, 0, encryptedBytes.Length);
|
||||||
|
|
||||||
|
// return Encoding.UTF8.GetString(decryptedBytes);
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,94 @@
|
||||||
|
using Org.BouncyCastle.Crypto;
|
||||||
|
using Org.BouncyCastle.Crypto.Encodings;
|
||||||
|
using Org.BouncyCastle.Crypto.Engines;
|
||||||
|
using Org.BouncyCastle.Crypto.Generators;
|
||||||
|
using Org.BouncyCastle.OpenSsl;
|
||||||
|
using Org.BouncyCastle.Security;
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace IRaCIS.Core.Infrastructure.Encryption;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// https://www.cnblogs.com/NBDWDYS2214143926/p/13329231.html
|
||||||
|
/// </summary>
|
||||||
|
public class RSAEncryption
|
||||||
|
{
|
||||||
|
|
||||||
|
public static AsymmetricCipherKeyPair GenerateRSAKeyPair(int keySize)
|
||||||
|
{
|
||||||
|
var keyGenerationParameters = new KeyGenerationParameters(new SecureRandom(), keySize);
|
||||||
|
var keyPairGenerator = new RsaKeyPairGenerator();
|
||||||
|
keyPairGenerator.Init(keyGenerationParameters);
|
||||||
|
return keyPairGenerator.GenerateKeyPair();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string ExportPublicKey(AsymmetricKeyParameter publicKey)
|
||||||
|
{
|
||||||
|
using (StringWriter sw = new StringWriter())
|
||||||
|
{
|
||||||
|
PemWriter pw = new PemWriter(sw);
|
||||||
|
pw.WriteObject(publicKey);
|
||||||
|
pw.Writer.Flush();
|
||||||
|
return sw.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string ExportPrivateKey(AsymmetricKeyParameter privateKey)
|
||||||
|
{
|
||||||
|
using (StringWriter sw = new StringWriter())
|
||||||
|
{
|
||||||
|
PemWriter pw = new PemWriter(sw);
|
||||||
|
pw.WriteObject(privateKey);
|
||||||
|
pw.Writer.Flush();
|
||||||
|
return sw.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// RSA解密
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="privateKey">私钥</param>
|
||||||
|
/// <param name="decryptstring">待解密的字符串(Base64)</param>
|
||||||
|
/// <returns>解密后的字符串</returns>
|
||||||
|
public static string Decrypt(string privateKey, string decryptstring)
|
||||||
|
{
|
||||||
|
using (TextReader reader = new StringReader(privateKey))
|
||||||
|
{
|
||||||
|
dynamic key = new PemReader(reader).ReadObject();
|
||||||
|
var rsaDecrypt = new Pkcs1Encoding(new RsaEngine());
|
||||||
|
if (key is AsymmetricKeyParameter)
|
||||||
|
{
|
||||||
|
key = (AsymmetricKeyParameter)key;
|
||||||
|
}
|
||||||
|
else if (key is AsymmetricCipherKeyPair)
|
||||||
|
{
|
||||||
|
key = ((AsymmetricCipherKeyPair)key).Private;
|
||||||
|
}
|
||||||
|
rsaDecrypt.Init(false, key); //这里加密是true;解密是false
|
||||||
|
|
||||||
|
byte[] entData = Convert.FromBase64String(decryptstring);
|
||||||
|
entData = rsaDecrypt.ProcessBlock(entData, 0, entData.Length);
|
||||||
|
return Encoding.UTF8.GetString(entData);
|
||||||
|
}
|
||||||
|
}/// <summary>
|
||||||
|
|
||||||
|
/// 加密
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="publicKey">公钥</param>
|
||||||
|
/// <param name="encryptstring">待加密的字符串</param>
|
||||||
|
/// <returns>加密后的Base64</returns>
|
||||||
|
public static string Encrypt(string publicKey, string encryptstring)
|
||||||
|
{
|
||||||
|
using (TextReader reader = new StringReader(publicKey))
|
||||||
|
{
|
||||||
|
AsymmetricKeyParameter key = new PemReader(reader).ReadObject() as AsymmetricKeyParameter;
|
||||||
|
Pkcs1Encoding pkcs1 = new Pkcs1Encoding(new RsaEngine());
|
||||||
|
pkcs1.Init(true, key);//加密是true;解密是false;
|
||||||
|
byte[] entData = Encoding.UTF8.GetBytes(encryptstring);
|
||||||
|
entData = pkcs1.ProcessBlock(entData, 0, entData.Length);
|
||||||
|
return Convert.ToBase64String(entData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,123 @@
|
||||||
|
namespace HIR_Activate
|
||||||
|
{
|
||||||
|
partial class Form1
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
label1 = new Label();
|
||||||
|
txtFilePath = new TextBox();
|
||||||
|
btn_select = new Button();
|
||||||
|
btn_activate = new Button();
|
||||||
|
label2 = new Label();
|
||||||
|
txtActivateFilePath = new TextBox();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
label1.AutoSize = true;
|
||||||
|
label1.Font = new Font("Microsoft YaHei UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 134);
|
||||||
|
label1.Location = new Point(12, 57);
|
||||||
|
label1.Name = "label1";
|
||||||
|
label1.Size = new Size(138, 21);
|
||||||
|
label1.TabIndex = 0;
|
||||||
|
label1.Text = "选择项目激活文件";
|
||||||
|
//
|
||||||
|
// txtFilePath
|
||||||
|
//
|
||||||
|
txtFilePath.Location = new Point(167, 55);
|
||||||
|
txtFilePath.Name = "txtFilePath";
|
||||||
|
txtFilePath.ReadOnly = true;
|
||||||
|
txtFilePath.Size = new Size(462, 23);
|
||||||
|
txtFilePath.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// btn_select
|
||||||
|
//
|
||||||
|
btn_select.Font = new Font("Microsoft YaHei UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 134);
|
||||||
|
btn_select.Location = new Point(650, 49);
|
||||||
|
btn_select.Name = "btn_select";
|
||||||
|
btn_select.Size = new Size(100, 33);
|
||||||
|
btn_select.TabIndex = 2;
|
||||||
|
btn_select.Text = "选择";
|
||||||
|
btn_select.UseVisualStyleBackColor = true;
|
||||||
|
btn_select.Click += btn_select_Click;
|
||||||
|
//
|
||||||
|
// btn_activate
|
||||||
|
//
|
||||||
|
btn_activate.Font = new Font("Microsoft YaHei UI", 15F, FontStyle.Regular, GraphicsUnit.Point, 134);
|
||||||
|
btn_activate.Location = new Point(230, 236);
|
||||||
|
btn_activate.Name = "btn_activate";
|
||||||
|
btn_activate.Size = new Size(307, 57);
|
||||||
|
btn_activate.TabIndex = 3;
|
||||||
|
btn_activate.Text = "生成激活文件";
|
||||||
|
btn_activate.UseVisualStyleBackColor = true;
|
||||||
|
btn_activate.Click += btn_activate_Click;
|
||||||
|
//
|
||||||
|
// label2
|
||||||
|
//
|
||||||
|
label2.AutoSize = true;
|
||||||
|
label2.Font = new Font("Microsoft YaHei UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 134);
|
||||||
|
label2.Location = new Point(12, 133);
|
||||||
|
label2.Name = "label2";
|
||||||
|
label2.Size = new Size(106, 21);
|
||||||
|
label2.TabIndex = 4;
|
||||||
|
label2.Text = "生成文件路径";
|
||||||
|
//
|
||||||
|
// txtActivateFilePath
|
||||||
|
//
|
||||||
|
txtActivateFilePath.Location = new Point(167, 131);
|
||||||
|
txtActivateFilePath.Name = "txtActivateFilePath";
|
||||||
|
txtActivateFilePath.ReadOnly = true;
|
||||||
|
txtActivateFilePath.Size = new Size(591, 23);
|
||||||
|
txtActivateFilePath.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// Form1
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 17F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(800, 542);
|
||||||
|
Controls.Add(txtActivateFilePath);
|
||||||
|
Controls.Add(label2);
|
||||||
|
Controls.Add(btn_activate);
|
||||||
|
Controls.Add(btn_select);
|
||||||
|
Controls.Add(txtFilePath);
|
||||||
|
Controls.Add(label1);
|
||||||
|
Name = "Form1";
|
||||||
|
Text = "HIR 激活码";
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Label label1;
|
||||||
|
private TextBox txtFilePath;
|
||||||
|
private Button btn_select;
|
||||||
|
private Button btn_activate;
|
||||||
|
private Label label2;
|
||||||
|
private TextBox txtActivateFilePath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,218 @@
|
||||||
|
using IRaCIS.Core.Infrastructure.Encryption;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace HIR_Activate
|
||||||
|
{
|
||||||
|
public partial class Form1 : Form
|
||||||
|
{
|
||||||
|
public Form1()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btn_select_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
using (OpenFileDialog openFileDialog = new OpenFileDialog())
|
||||||
|
{
|
||||||
|
openFileDialog.Filter = "Request Files (*.req)|*.req";
|
||||||
|
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
txtFilePath.Text = openFileDialog.FileName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btn_activate_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
string filePath = txtFilePath.Text;
|
||||||
|
var fileName=Path.GetFileNameWithoutExtension(filePath);
|
||||||
|
if (string.IsNullOrWhiteSpace(filePath) || !File.Exists(filePath))
|
||||||
|
{
|
||||||
|
MessageBox.Show("请选择一个有效的文件路径!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// 读取文件内容
|
||||||
|
string authorizationCode = File.ReadAllText(filePath);
|
||||||
|
|
||||||
|
// 解密 Base64 编码后的数据
|
||||||
|
byte[] base64DecodedBytes = Convert.FromBase64String(authorizationCode);
|
||||||
|
string decodedText = System.Text.Encoding.UTF8.GetString(base64DecodedBytes);
|
||||||
|
|
||||||
|
var authorizationInfo = JsonConvert.DeserializeObject<TrialAuthorizationInfo>(decodedText);
|
||||||
|
|
||||||
|
if (authorizationInfo == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("不能解析该项目授权码!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//一周内激活
|
||||||
|
authorizationInfo.ActiveDeadLineDate = DateTime.Now.Date.AddDays(8).AddSeconds(-1);
|
||||||
|
|
||||||
|
var licenseContent = AesEncryption.Encrypt($"{JsonConvert.SerializeObject(authorizationInfo)}", "HIR_System_AES_Key_Info", "Trial_AuthorizationEncrypt");
|
||||||
|
|
||||||
|
Console.WriteLine("HIR_System_AES_Key_Info".PadRight(32, '0').Substring(0, 32) + " " + "Trial_AuthorizationEncrypt".PadRight(16, '0').Substring(0, 16));
|
||||||
|
|
||||||
|
//var dd = AesEncryption.Decrypt(info, "HIR_System_AES_Key_Info", "Trial_AuthorizationEncrypt");
|
||||||
|
|
||||||
|
// 保存许可证文件
|
||||||
|
string licensePath = Path.Combine(Path.GetDirectoryName(filePath), $"{fileName}_Activation_Code.lic");
|
||||||
|
File.WriteAllText(licensePath, licenseContent);
|
||||||
|
|
||||||
|
txtActivateFilePath.Text = licensePath;
|
||||||
|
|
||||||
|
MessageBox.Show($"许可证生成成功", "成功", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show($"生成许可证失败:{ex.Message}", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class TrialAuthorizationInfo
|
||||||
|
{
|
||||||
|
public Guid TrialId { get; set; }
|
||||||
|
public Guid CreateUserId { get; set; }
|
||||||
|
public string TrialCode { get; set; }
|
||||||
|
|
||||||
|
public string HospitalName { get; set; }
|
||||||
|
|
||||||
|
public string HospitalCode { get; set; }
|
||||||
|
|
||||||
|
public int PurchaseDuration { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public List<CriterionType> CriterionTypeList { get; set; }
|
||||||
|
|
||||||
|
public DateTime? AuthorizationDeadLineDate { get; set; }
|
||||||
|
|
||||||
|
public DateTime? ActiveDeadLineDate { get; set; }
|
||||||
|
|
||||||
|
public DateTime? ActiveTime { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 标准类型
|
||||||
|
/// </summary>
|
||||||
|
public enum CriterionType
|
||||||
|
{
|
||||||
|
NoCriterion = -1,
|
||||||
|
|
||||||
|
//自定义
|
||||||
|
SelfDefine = 0,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// RECIST 1.1
|
||||||
|
/// </summary>
|
||||||
|
RECIST1Point1 = 1,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Lugano 2014
|
||||||
|
/// </summary>
|
||||||
|
Lugano2014 = 2,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// iRECIST1Point1
|
||||||
|
/// </summary>
|
||||||
|
IRECIST1Point1 = 3,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// RANO-BM
|
||||||
|
/// </summary>
|
||||||
|
RANO_BM = 4,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// RANO
|
||||||
|
/// </summary>
|
||||||
|
RANO = 5,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// IWCLL 2018
|
||||||
|
/// </summary>
|
||||||
|
IWCLL2018 = 6,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// mRECIST HCC
|
||||||
|
/// </summary>
|
||||||
|
mRECISTHCC = 7,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Cheson 2007
|
||||||
|
/// </summary>
|
||||||
|
Cheson2007 = 8,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// IMWG 2016
|
||||||
|
/// </summary>
|
||||||
|
IMWG2016 = 9,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// PCWG3
|
||||||
|
/// </summary>
|
||||||
|
PCWG3 = 10,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// mRECIST Mesothelioma
|
||||||
|
/// </summary>
|
||||||
|
mRECISTMesothelioma = 11,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// RECIL
|
||||||
|
/// </summary>
|
||||||
|
RECIL = 12,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// RECIST 1.0
|
||||||
|
/// </summary>
|
||||||
|
RECIST1Point0 = 13,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// WHO
|
||||||
|
/// </summary>
|
||||||
|
WHO = 14,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// PERCIST
|
||||||
|
/// </summary>
|
||||||
|
PERCIST = 15,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Forrest
|
||||||
|
/// </summary>
|
||||||
|
Forrest = 16,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// RECIST 1.1-BM
|
||||||
|
/// </summary>
|
||||||
|
RECIST1Pointt1_MB = 17,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Lugano 2014 Without PET
|
||||||
|
/// </summary>
|
||||||
|
Lugano2014WithoutPET = 18,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// IVUS定量评估
|
||||||
|
/// </summary>
|
||||||
|
IVUS = 19,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// OCT定量评估
|
||||||
|
/// </summary>
|
||||||
|
OCT = 20,
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,120 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>WinExe</OutputType>
|
||||||
|
<TargetFramework>net8.0-windows</TargetFramework>
|
||||||
|
<RootNamespace>HIR_Activate</RootNamespace>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
|
<PackageReference Include="Portable.BouncyCastle" Version="1.9.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
namespace HIR_Activate
|
||||||
|
{
|
||||||
|
internal static class Program
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The main entry point for the application.
|
||||||
|
/// </summary>
|
||||||
|
[STAThread]
|
||||||
|
static void Main()
|
||||||
|
{
|
||||||
|
// To customize application configuration such as set high DPI settings or default font,
|
||||||
|
// see https://aka.ms/applicationconfiguration.
|
||||||
|
ApplicationConfiguration.Initialize();
|
||||||
|
Application.Run(new Form1());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue