Exemple #1
0
        //发卡
        public static bool destribute_card_M1(string company_code, string cardCode)
        {
            if (!connect_card_machine("M1"))
            {
                return(false);
            }

            ulong snr  = 0;
            char  mode = '1';

            ICRF.rf_card(icdev, mode, ref snr);

            //string skey = "FFFFFFFFFFFF";
            string skey = "6a3530303033";

            if (verify_pwd_M1(skey))
            {
                write_str_M1(company_code, cardCode);
            }
            else
            {
                MessageBox.Show("验证密码失败");
                ICRF.rf_exit(icdev);
                return(false);
            }

            ICRF.rf_exit(icdev);
            return(true);
        }
Exemple #2
0
        public static bool read_data_M1(string compnay_code, ref string card_str)
        {
            if (!connect_card_machine("M1"))
            {
                return(false);
            }

            ulong snr  = 0;
            char  mode = '1';

            ICRF.rf_card(icdev, mode, ref snr);

            byte[] key1 = new byte[20];
            byte[] key2 = new byte[20];

            string skey      = "6a3530303033";
            string skey_init = "FFFFFFFFFFFF";

            if (verify_pwd_M1(skey_init) || verify_pwd_M1(skey))
            {
                byte[] data   = new byte[16];
                byte[] p_dest = new byte[16];
                for (int i = 0; i < 16; i++)
                {
                    data[i] = 0;
                }
                for (int i = 0; i < 16; i++)
                {
                    p_dest[i] = 0;
                }

                int st = ICRF.rf_read(icdev, 9, data);
                if (st == 0)
                {
                    card_str = System.Text.Encoding.ASCII.GetString(data);
                    if (!card_str.Contains(compnay_code))
                    {
                        return(false);
                    }

                    card_str = card_str.Substring(compnay_code.Length);
                    string tmpStr = "";
                    foreach (char c in card_str)
                    {
                        if (char.IsDigit(c))
                        {
                            tmpStr += c;
                        }
                    }
                    card_str = tmpStr;
                }
                else
                {
                    MessageBox.Show("读取数据失败");
                    ICRF.rf_exit(icdev);
                    return(false);
                }
            }
            else
            {
                MessageBox.Show("装载密码失败");
                ICRF.rf_exit(icdev);
                return(false);
            }



            ICRF.rf_exit(icdev);

            return(true);
        }