Example #1
0
        /// <summary>
        /// 在固定的位置读出固定长度的数据
        /// </summary>
        private static short IC_Read_hex(int icdev, int offset, int len, StringBuilder Databuffer)
        {
            Int16 result = 0;

            result = Dcrf32.dc_authentication(icdev, pwd_mode, getSecNr(offset));    //校验第0套密码;
            if (result != 0)
            {
                return(result);
            }
            result = Dcrf32.dc_read_hex(icdev, offset, Databuffer);     //获取数据
            return(result);
        }
Example #2
0
        /// <summary>
        /// 在固定的位置写入固定长度的数据
        /// </summary>
        private static short IC_Write(int icdev, int offset, int Length, byte[] Databuffer)
        {
            Int16 result = 0;

            result = Dcrf32.dc_authentication(icdev, pwd_mode, getSecNr(offset));    //校验第0套密码;
            if (result != 0)
            {
                return(result);
            }
            result = Dcrf32.dc_write(icdev, offset, Databuffer);
            return(result);
        }
Example #3
0
        /// <summary>
        /// 在固定的位置写入固定长度的数据
        /// </summary>
        private static short IC_Write_hex(int icdev, int offset, int Length, string Databuffer)
        {
            Int16 result = 0;

            result = Dcrf32.dc_authentication(icdev, pwd_mode, getSecNr(offset));    //校验第0套密码;
            if (result != 0)
            {
                return(result);
            }
            string data = addZero(Databuffer, 32, true);

            result = Dcrf32.dc_write_hex(icdev, offset, data);
            return(result);
        }
Example #4
0
        /// <summary>
        /// 更改密码(0为更改成功)
        /// </summary>
        private static short IC_ChangePass(int icdev, int pwd_postion, int secnr_index, string oldPassWord, string newPassWord)
        {
            Int16 result = 0;

            result = Dcrf32.dc_authentication(icdev, pwd_mode, secnr_index);
            result = ICCardUtility.IC_CheckPass_4442hex(icdev, oldPassWord, secnr_index); //校验出厂密码
            if (result != 0)
            {
                return(result);
            }
            string data = newPassWord + "FF078069" + newPassWord;

            result = Dcrf32.dc_write_hex(icdev, pwd_postion, data);
            return(result);
        }
Example #5
0
        /// <summary>
        /// 检查原始密码(不等于0为校验失败)
        /// </summary>
        private static short IC_CheckPass_4442hex(int icdev, string Password, int index = secnr_index)
        {
            Int16 result   = 0;
            ulong icCardNo = 0;

            //B_ICPass = new byte[6] { 0x77, 0x88, 0x52, 0x01, 0x31, 0x45 };
            for (int i = 0; i < 6; i++)
            {
                B_ICPass[i] = Convert.ToByte(Password.Substring(i * 2, 2), 16);
            }
            //B_ICPass = Encoding.ASCII.GetBytes(Password);
            result = Dcrf32.dc_load_key(icdev, pwd_mode, index, B_ICPass); //密码加载到设备
            result = Dcrf32.dc_card(icdev, pwd_mode, ref icCardNo);        //读取卡号,校验之前必须调用
            result = Dcrf32.dc_authentication(icdev, pwd_mode, index);     //校验出厂密码
            return(result);
        }