/// <summary> /// 自定义加密算法,传入原始数据,返回加密结果 /// </summary> /// <param name="origin"></param> /// <returns>加密结果</returns> public static string AuthorizeEncrypted(string origin) { //DES对称加密 string license = SoftSecurity.MD5Encrypt(origin, "CSTLASER"); return(license); }
/// <summary> /// 一个自定义的加密方法,传入一个原始数据,返回一个加密结果 /// </summary> /// <param name="origin"></param> /// <returns></returns> private static string AuthorizeEncrypted(string origin) { // 此处使用了组件支持的DES对称加密技术 string Result = SoftSecurity.MD5Encrypt(origin, "12345678"); return(Result); }
/// <summary> /// 自定义加密算法,传入原始数据,返回加密结果 /// </summary> /// <param name="origin"></param> /// <returns>加密结果</returns> private string AuthorizeEncrypted(string origin) { //使用了组件支持的DES对称加密技术 string license = SoftSecurity.MD5Encrypt(origin, "CSTLASER"); return(license); }
/// <summary> /// 授权检测 /// </summary> /// <param name="machineCode"></param> /// <param name="softName"></param> /// <param name="softVersion"></param> /// <param name="regCode"></param> /// <returns></returns> public static bool IsAuthorize(string regCode, string machineCode, string softName, ref string softVersion, ref string expireDate, ref string msg) { bool ret = false; try { string regJson = SoftSecurity.MD5Decrypt(regCode, "bayuejun"); JObject regJObject = JObject.Parse(regJson); softVersion = regJObject.Property("softVersion").Value.ToString(); string regMachineCode = regJObject.Property("machineCode").Value.ToString(); if (regMachineCode != machineCode) { msg = "机器码错误"; return(false); } if (!regJObject.ContainsKey("lic")) { //兼容未加入时间限制时的许可证处理 expireDate = "长期"; return(true); } JObject dateJObject = (JObject)regJObject.Property("lic").Value; bool dateType = (bool)dateJObject.Property("dateType").Value; if (dateType) { //长期许可 ret = true; expireDate = "长期"; } else { DateTime now = DateTime.Now; DateTime expireDateTime = (DateTime)dateJObject.Property("expireDate").Value; DateTime lastDateTime = (DateTime)dateJObject.Property("lastDate").Value; DateTime licDateTime = (DateTime)dateJObject.Property("licDate").Value; if (CheckLicDate(now, expireDateTime, lastDateTime, licDateTime, ref msg)) { //当前时间小于expiretime并且大于上次时间和lic生成时间 //regJObject dateJObject["lastDate"] = DateTime.Now; regJObject["lic"] = dateJObject; expireDate = expireDateTime.ToString("yyyy-MM-dd"); ret = true; } } } catch (Exception e) { msg = "软件未注册"; LogHelper.WriteLog("注册文件读取处理错误", e); } return(ret); }
private static void WriteCode(JObject licJObject) { try { string txt = SoftSecurity.MD5Encrypt(licJObject.ToString(), "bayuejun"); File.WriteAllText(Application.StartupPath + @"\license.lic", txt); } catch (Exception e) { Console.WriteLine(e); throw; } }
public FormMain( ) { InitializeComponent( ); if (File.Exists(SettingsPath)) { redisSettings = JArray.Parse(SoftSecurity.MD5Decrypt(File.ReadAllText(SettingsPath, Encoding.UTF8), "oa8H01kz")).ToObject <List <RedisSettings> >( ); } else { redisSettings = new List <RedisSettings>( ); } }
/// <summary> /// 生成按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void userButton_Generate_Click(object sender, EventArgs e) { //校验Request Code是否为空 //if(string.IsNullOrEmpty(textBox_RequetsCode.Text)) //{ // MessageBox.Show("Please input the Request Code!"); // return; //} ////校验Request Code是否为空 //if (string.IsNullOrEmpty(textBox_EncryptionCode.Text)) //{ // MessageBox.Show("Please input the Request Code!"); //} ////生成注册码 //textBox_RegisterCode.Text = SoftSecurity.MD5Encrypt(textBox_RequetsCode.Text, textBox_EncryptionCode.Text); SoftSecurity.CreatKey(@"./Key"); }
private void btnCalcuCode_Click(object sender, EventArgs e) { if (txtKey.Text.Trim().Length != 8) { MessageBoxEx.Show("秘钥必须为8位字母或数字"); return; } Dictionary <string, string> funcList = new Dictionary <string, string>(); GetFuncs(treeView1.Nodes, funcList); var funcJson = new JObject(); foreach (var variable in funcList) { funcJson.Add(variable.Key, variable.Value); } var licJObjectobj = new JObject { { "dateType", chkDateType.Checked }, { "licDate", DateTime.Now }, { "lastDate", DateTime.Now }, { "expireDate", dateTimeExpire.Value } }; var sourceJObjectobj = new JObject { { "softName", cmbSoftName.SelectedItem.ToString() }, { "lic", licJObjectobj }, { "softVersion", funcJson }, { "machineCode", txtMachineCode.Text } }; txtCode.Text = SoftSecurity.MD5Encrypt(sourceJObjectobj.ToString(), txtKey.Text); }
private void FormMain_Load(object sender, EventArgs e) { ImageList imageList = new ImageList( ); imageList.Images.Add("loading", Properties.Resources.loading); imageList.Images.Add("VirtualMachine", Properties.Resources.VirtualMachine); imageList.Images.Add("Class_489", Properties.Resources.Class_489); imageList.Images.Add("redis", Properties.Resources.redis); imageList.Images.Add("redis_db", Properties.Resources.redis_db); imageList.Images.Add("Method_636", Properties.Resources.Method_636); imageList.Images.Add("Structure_507", Properties.Resources.Structure_507); imageList.Images.Add("Module_648", Properties.Resources.Module_648); imageList.Images.Add("docview_xaml_on_16x16", Properties.Resources.docview_xaml_on_16x16); imageList.Images.Add("Enum_582", Properties.Resources.Enum_582); // string imageList.Images.Add("brackets_Square_16xMD", Properties.Resources.brackets_Square_16xMD); // 数组 imageList.Images.Add("Table_748", Properties.Resources.Table_748); // 哈希 imageList.Images.Add("zset", Properties.Resources.zset); // 集合 imageList.Images.Add("Tag_7213", Properties.Resources.Tag_7213); // 有序集合 treeView1.ImageList = imageList; LoadRedisSettings( ); // DB块右键 新增KeyToolStripMenuItem.Click += 新增KeyToolStripMenuItem_Click; 刷新数据ToolStripMenuItem.Click += 刷新数据ToolStripMenuItem_Click; 过滤KeyToolStripMenuItem.Click += 过滤KeyToolStripMenuItem_Click; 清除所有KeyToolStripMenuItem.Click += 清除所有KeyToolStripMenuItem_Click; // Redis右键 刷新所有数据ToolStripMenuItem.Click += 刷新所有数据ToolStripMenuItem_Click; 务器状态ToolStripMenuItem.Click += 务器状态ToolStripMenuItem_Click; 控制台操作ToolStripMenuItem.Click += 控制台操作ToolStripMenuItem_Click; 修改连接配置ToolStripMenuItem.Click += 修改连接配置ToolStripMenuItem_Click; 修改密码ToolStripMenuItem.Click += 修改密码ToolStripMenuItem_Click; 断开当前连接ToolStripMenuItem.Click += 断开当前连接ToolStripMenuItem_Click; 除当前链接ToolStripMenuItem.Click += 除当前链接ToolStripMenuItem_Click; // 分类器右键 展开所有ToolStripMenuItem.Click += 展开所有ToolStripMenuItem_Click; FormClosing += FormMain_FormClosing; // 显示初始的界面信息 CreateRedisShowTagControl <StartControl>( ); // 关于 aboutToolStripMenuItem.Click += AboutToolStripMenuItem_Click; sourceCodeToolStripMenuItem.Click += SourceCodeToolStripMenuItem_Click; contactToolStripMenuItem.Click += ContactToolStripMenuItem_Click; activateToolStripMenuItem.Click += ActivateToolStripMenuItem_Click; try { if (File.Exists(Path.Combine(Application.StartupPath, "code.txt"))) { string content = File.ReadAllText(Path.Combine(Application.StartupPath, "code.txt"), Encoding.UTF8); string code = SoftSecurity.MD5Decrypt(content, "1234asdf"); if (HslCommunication.Authorization.SetAuthorizationCode(code)) { activateToolStripMenuItem.Text = "Activated"; activateToolStripMenuItem.ForeColor = Color.White; } else { //MessageBox.Show( "Wrong Code" ); } } } catch { } }
/// <summary> /// 使用指定的加密实现数据加密 /// </summary> public override void SaveToFile() { SaveToFile(m => SoftSecurity.MD5Encrypt(m, CommonProtocol.Security)); }
/// <summary> /// 使用指定的解密实现数据解密 /// </summary> public override void LoadByFile() { LoadByFile(m => SoftSecurity.MD5Decrypt(m, CommonProtocol.Security)); }
/// <summary> /// 使用指定的加密实现数据加密 /// </summary> public override void SaveToFile() { SaveToFile(m => SoftSecurity.MD5Encrypt(m, UserSystem.Security)); }
/// <summary> /// 使用指定的解密实现数据解密 /// </summary> public override void LoadByFile() { LoadByFile(m => SoftSecurity.MD5Decrypt(m, UserSystem.Security)); }
private void SaveRedisSettings( ) { File.WriteAllText(SettingsPath, SoftSecurity.MD5Encrypt(JArray.FromObject(redisSettings).ToString( ), "oa8H01kz"), Encoding.UTF8); }
public override void SaveToFile() { SaveToFile(m => SoftSecurity.MD5Encrypt(m, CommonLibrary.Security)); }
private string AuthorizeEncrypted(string origin) { //softAuthorize = new SoftAuthorize(); // 此处使用了组件支持的DES对称加密技术 return(SoftSecurity.MD5Encrypt(origin, "19951005")); }
/// <summary> /// 一个自定义的加密方法,传入一个原始数据,返回一个加密结果 /// </summary> /// <param name="origin"></param> /// <returns></returns> private string AuthorizeEncrypted(string origin) { return(SoftSecurity.MD5Encrypt(origin, textBox1.Text)); }
/// <summary> /// 此处使用了组件支持的DES对称加密技术 /// </summary> /// <param name="origin"></param> /// <returns></returns> public string AuthorizeEncrypted(string origin) { return(SoftSecurity.MD5Encrypt(origin, "19951005")); }
/// <summary> /// 使用指定的解密实现数据解密 /// </summary> public override void LoadByFile() { LoadByFile(m => SoftSecurity.MD5Decrypt(m, CommonLibrary.Security)); }