Beispiel #1
0
        bool CanPassValie(LivingDog p_dog)
        {
            //1.密码验证
            //2.合法性验证
            //string pwd = "09JJSoft12";
            string pwd = "20JJSoft13";

            if (p_dog.Grand_Passwd(1, pwd) == LivingDog.LIV_SUCCESS)
            {
                //功能验证 读取加密狗数据
                byte[] outByte = new byte[50];
                if (p_dog.Grand_Read(1, outByte) == LivingDog.LIV_SUCCESS)
                {
                    string strs = System.Text.ASCIIEncoding.Default.GetString(outByte).Trim('\0');

                    if (strs[3] == '1') //加密狗有效性验证
                    {
                        //合法加密狗
                        this.IsPassValie = true;
                        return(true);
                    }
                    else
                    {
                        //非法加密狗
                        this.IsPassValie = false;
                        return(false);
                    }
                }

                return(true);
            }
            return(false);
        }
Beispiel #2
0
        /// <summary>
        /// 功能 以及 合法性验证
        /// </summary>
        /// <param name="p_dog"></param>
        /// <returns></returns>
        public void ReadHandle(LivingDog p_dog)
        {
            int Result = p_dog.Grand_Passwd(0, "20JJSoft13");

            if (Result == 0)
            {
                byte[] outByte = new byte[512];
                //读取加密狗的数据
                if (p_dog.Grand_Read(2, outByte) == LivingDog.LIV_SUCCESS)
                {
                    string str   = System.Text.ASCIIEncoding.Default.GetString(outByte).Trim('\0');
                    int    index = str.IndexOf("\0");
                    if (index > 0)
                    {
                        str = str.Substring(0, index);
                    }
                    if (!IsEmptyHandle(str))
                    {
                        //读取数据
                        string[] data = str.Split(',');
                        this.Read(data);
                        this.IsReadHeandle = true;
                    }
                    else
                    {
                        //数据读取失败
                        this.IsReadHeandle = false;
                    }
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// 方法调用前保证加密狗已经成功打开(进验证有效性)
        /// </summary>
        /// <returns></returns>
        bool IsPassValie(LivingDog p_dog)
        {
            //1.密码验证
            //2.合法性验证
            //string pwd = "09JJSoft12";
            string pwd = "JJSoft0912";

            //string pwd = "20JJSoft13";
            if (p_dog.Grand_Passwd(1, pwd) == LivingDog.LIV_SUCCESS)
            {
                //功能验证 读取加密狗数据
                byte[] outByte = new byte[50];
                if (p_dog.Grand_Read(1, outByte) == LivingDog.LIV_SUCCESS)
                {
                    //string strs  = System.Text.ASCIIEncoding.Default.GetString(outByte).Trim('\0');
                    string strs = System.Text.ASCIIEncoding.Default.GetString(outByte);
                    //3.领先版  4是专业版 5是旗舰版 6是网络版
                    if (strs[3] == '1' || strs[4] == '1' || strs[5] == '1' || strs[6] == '1') //加密狗有效性验证
                    {
                        //合法加密狗
                        this.Parent.ClientResult.IsPassValie = true;
                        return(true);
                    }
                    else
                    {
                        //非法加密狗
                        this.Parent.ClientResult.IsPassValie = false;
                        return(false);
                    }
                }

                return(true);
            }
            return(false);
        }
Beispiel #4
0
        /// <summary>
        /// 写入数据(一次完全操作)
        /// </summary>
        /// <param name="dog"></param>
        /// <returns></returns>
        public int WriteHandle(string p_string)
        {
            LivingDog dog = new LivingDog();

            try
            {
                dog.Grand_OpenDog(LIV_APP_CODE, 0);
                //int Result = dog.Grand_Passwd(0, "20JJSoft13");
                int Result = dog.Grand_Passwd(0, "09JJSoft12");

                byte[] oByte = System.Text.ASCIIEncoding.Default.GetBytes(p_string.ToString().Trim());
                //
                if (dog.Grand_Write(2, oByte) == LivingDog.LIV_SUCCESS)
                {
                    return(_GlodSoftDiscern.TRY_SUCCESS);
                }
                return(_GlodSoftDiscern.TRY_ERROR);
            }
            catch
            {
                return(_GlodSoftDiscern.TRY_ERROR);
            }
            finally
            {
                dog.Grand_CloseDog();
            }
        }
Beispiel #5
0
        public static SoftdogProtocol ValidateLocal()
        {
            var message  = "验证不通过";
            var result   = new SoftdogProtocol();
            var pwd      = "JJSoft0912";
            var driver   = new LivingDog();
            var hardware = default(LivingDog.LIV_hardware_info);
            var status   = 0;

            try
            {
                status   = driver.Grand_OpenDog(DogCode, 0);
                hardware = driver.Grand_GetHardware_info();
                switch (hardware.RetCode)
                {
                case 0:
                    if (driver.Grand_Passwd(1, pwd) == LivingDog.LIV_SUCCESS)
                    {
                        byte[] outByte = new byte[50];
                        if (driver.Grand_Read(1, outByte) == LivingDog.LIV_SUCCESS)
                        {
                            string strs = System.Text.ASCIIEncoding.Default.GetString(outByte);
                            //3.领先版  4是专业版 5是旗舰版 6是网络版
                            if (strs[3] == '1' || strs[4] == '1' || strs[5] == '1' || strs[6] == '1')     //加密狗有效性验证
                            {
                                goto success;
                            }
                        }
                    }
                    break;

                default:
                    break;
                }
            }
            catch (Exception e)
            {
                message = e.Message;
            }
            finally
            {
                driver.Grand_CloseDog();
            }

            result.Error   = true;
            result.Message = message;
            return(result);

success:
            result.Success      = true;
            result.SerialNumber = Encoding.Default.GetString(hardware.serialNumber);
            result.Error        = false;
            return(result);
        }
Beispiel #6
0
        /// <summary>
        /// 申请一次加密狗验证(仅验证是否是已经初始化的加密狗)
        /// 附带功能验证
        /// </summary>
        public int Completed()
        {
            LivingDog m_LivingDog = new LivingDog();

            try
            {
                int result = m_LivingDog.Grand_OpenDog(LIV_APP_CODE, 0);

                this.CurrLivInfo = m_LivingDog.Grand_GetHardware_info();
                //密码验证
                switch (this.CurrLivInfo.RetCode)
                {
                case 0:    //成功继续做
                    //判断加密狗的合法性 (密码验证+数据验证)
                    if (!ispass)
                    {
                        ispass = IsPassValie(m_LivingDog);
                    }
                    if (ispass)
                    {
                        this.Parent.ClientResult.IsOwenr     = true;
                        this.Parent.ClientResult.IsPassValie = true;
                        OnHardWareSucc(this, _GlodSoftDiscern.TRY_SUCCESS);
                        //功能合法验证
                        this.ReadHandle(m_LivingDog);
                        return(_GlodSoftDiscern.TRY_SUCCESS);
                    }
                    else
                    {
                        this.Parent.ClientResult.IsOwenr       = false;
                        this.Parent.ClientResult.IsReadHeandle = false;
                        OnHardWareSucc(this, _GlodSoftDiscern.TRY_SUCCESS);
                        return(_GlodSoftDiscern.TRY_ERROR_NOFUNCTION);
                    }

                default:    //其他错误关闭系统
                    this.Parent.ClientResult.IsPassValie   = false;
                    this.Parent.ClientResult.IsOwenr       = false;
                    this.Parent.ClientResult.IsReadHeandle = false;
                    OnHardWareSucc(this, _GlodSoftDiscern.TRY_ERROR);
                    return(_GlodSoftDiscern.TRY_ERROR);
                }
            }
            catch
            {
                this.Parent.ClientResult.IsOwenr = false;
                return(_GlodSoftDiscern.TRY_ERROR);
            }
            finally
            {
                m_LivingDog.Grand_CloseDog();
            }
        }
Beispiel #7
0
        public int getDogInfo()
        {
            LivingDog m_LivingDog = new LivingDog();

            try
            {
                m_LivingDog.Grand_OpenDog(LIV_APP_CODE, 0);
                CurrLivInfo = m_LivingDog.Grand_GetHardware_info();
                //密码验证
                if (CurrLivInfo.RetCode == 0)
                {
                    //判断加密狗的合法性 (密码验证+数据验证)
                    if (!ispass)
                    {
                        ispass = CanPassValie(m_LivingDog);
                    }
                    if (ispass)
                    {
                        IsOwenr     = true;
                        IsPassValie = true;
                        this.ReadHandle(m_LivingDog);
                        return(0);
                    }
                    else
                    {
                        IsOwenr       = false;
                        IsReadHeandle = false;
                        return(3);//功能不存在
                    }
                }
                else
                {
                    this.IsPassValie   = false;
                    this.IsOwenr       = false;
                    this.IsReadHeandle = false;
                    return(-1);
                }
            }
            catch
            {
                IsOwenr = false;
                return(-1);
            }
            finally
            {
                m_LivingDog.Grand_CloseDog();
            }
        }