//发卡 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); byte[] key1 = new byte[20]; byte[] key2 = new byte[20]; string skey = "6a3530303033"; int keylen = skey.Length; key1 = Encoding.ASCII.GetBytes(skey); ICRF.a_hex(key1, key2, 12); int st = ICRF.rf_load_key(icdev, 1, 2, key2); if (st != 0) { MessageBox.Show("装载密码失败"); ICRF.rf_exit(icdev); return(false); } st = ICRF.rf_authentication(icdev, 1, 2); if (st != 0) { MessageBox.Show("验证密码失败"); ICRF.rf_exit(icdev); return(false); } string str = company_code + cardCode; byte[] data = Encoding.ASCII.GetBytes(str); //byte[] buff = new byte[16]; //st = IC4442.my_encrypt(data, buff); st = ICRF.rf_write(icdev, 9, data); if (st != 0) { BathClass.printErrorMsg("写卡失败!"); return(false); } st = ICRF.rf_beep(icdev, 20); st = ICRF.rf_exit(icdev); return(true); }
private static bool verify_pwd_M1(string skey) { byte[] key1 = new byte[20]; byte[] key2 = new byte[20]; key1 = Encoding.ASCII.GetBytes(skey); ICRF.a_hex(key1, key2, 12); int st = ICRF.rf_load_key(icdev, 1, 2, key2); if (st != 0) { return(false); } st = ICRF.rf_authentication(icdev, 1, 2); if (st != 0) { return(false); } return(true); }