Exemplo n.º 1
0
        public string ReadLicense()
        {
            SecStrHelper SSH = new SecStrHelper();

            string LicenseKeyStr = "";
            string LicenseStr    = "";

            try
            {
                //读取本地许可信息
                RegistryKey LMKey          = Registry.LocalMachine;
                RegistryKey LicenseKeyEdit = LMKey.CreateSubKey("software\\HiSoft");
                RegistryKey LicenseKey     = LMKey.OpenSubKey("SOFTWARE\\HiSoft", true);
                LicenseKeyStr = LicenseKey.GetValue("HiStr").ToString();

                //解密许可信息
                LicenseStr = SSH.DESLite(false, LicenseKeyStr);
                List <string> LicenseInfo = new List <string>(LicenseStr.Split(','));
                //提取许可信息
                AppID   = LicenseInfo[2];
                AppTime = DateTime.Parse(LicenseInfo[1].ToString());
                AppMac  = LicenseInfo[0];
            }
            catch (Exception ex)
            {
                //
            }


            //提取硬件信息
            HardwareHelper HwH     = new HardwareHelper();
            string         ThisMAC = SSH.DESLite(true, HwH.GetMacAddress());

            //许可验证
            if (AppMac != ThisMAC)
            {
                AllowLogin = false;
                return("False,未注册," + ThisMAC);
            }
            else if (AppTime < DateTime.Now)
            {
                AllowLogin = false;
                return("False,注册过期," + AppTime);
            }
            else
            {
                AllowLogin = true;
                return("True,验证成功," + AppID);
            }
        }
Exemplo n.º 2
0
        //初始化本地数据库
        public void InitialSQLiteDB(string path = null)
        {
            SQLitePath = "Data Source=" + path + "database.s3db";
            try
            {
                SQLiteConn = new SQLiteConnection(SQLitePath + SQLitePWD);
                SQLiteConn.Open();
            }
            catch (Exception ex)
            {
                SQLiteConn = new SQLiteConnection(SQLitePath);
                SQLiteConn.Open();
                SQLiteConn.ChangePassword("Hc@3232327");
                SQLiteConn.Close();
                SQLiteConn = new SQLiteConnection(SQLitePath + SQLitePWD);
                SQLiteConn.Open();
            }

            SQLiteComm = new SQLiteCommand(SQLiteConn);

            //初始化SQLite设置
            string    sql1      = "SELECT name FROM sqlite_master WHERE type = 'table' and name='Soft_User' ORDER BY name";
            DataTable TableIsIn = SQLiteDT(sql1);

            if (!(TableIsIn.Rows.Count > 0))
            {
                //初始化系统表
                try
                {
                    SQLiteComm.CommandText = "CREATE TABLE [Soft_User] ([UID] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,[UserName] VARCHAR(20)  UNIQUE NULL,[UserPWD] VARCHAR(100)  NULL,[UserAPP] VARCHAR(200)  NULL)";
                    SQLiteComm.ExecuteNonQuery();
                    SecStrHelper SSH = new SecStrHelper();
                    string       pwd = SSH.DESLite(true, "admin");
                    SQLiteComm.CommandText = "insert into [Soft_User]([UserName],[UserPWD],[UserAPP]) values('admin','" + pwd + "','ALL')";
                    SQLiteComm.ExecuteNonQuery();
                }
                catch (Exception ex)
                {
                }
            }
        }