/// <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); }
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> public override void LoadByFile() { LoadByFile(m => SoftSecurity.MD5Decrypt(m, CommonProtocol.Security)); }
/// <summary> /// 使用指定的解密实现数据解密 /// </summary> public override void LoadByFile() { LoadByFile(m => SoftSecurity.MD5Decrypt(m, UserSystem.Security)); }
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 LoadByFile() { LoadByFile(m => SoftSecurity.MD5Decrypt(m, CommonLibrary.Security)); }