public string CheckTRK(StringBuilder source) { StringBuilder result = new StringBuilder(); ZT_EPP.ZT_EPP_ActivWorkPin(0x00, 0x02); ZT_EPP.ZT_EPP_SetDesPara(0x01, 0x30); ZT_EPP.ZT_EPP_SetDesPara(0x07, 0x20); ZT_EPP.ZT_EPP_PinAdd(0, 0, source, result); return(result.ToString().Substring(0, 16)); }
/// <summary> /// 计算PIN码 /// </summary> /// <param name="source"></param> /// <returns></returns> public string CalculatePIN(StringBuilder source) { File.AppendAllText("pin.txt", source.ToString()); StringBuilder result = new StringBuilder(); ZT_EPP.ZT_EPP_ActivWorkPin(0x00, 0x00); ZT_EPP.ZT_EPP_SetDesPara(0x01, 0x30); ZT_EPP.ZT_EPP_PinAdd(2, 0, source, result); return(result.ToString().Substring(0, 16)); }
/// <summary> /// 核对MAC码 /// </summary> /// <param name="source"></param> /// <returns></returns> public string CheckMAK(StringBuilder source) { StringBuilder sbMac = new StringBuilder(); StringBuilder sbReturn = new StringBuilder(); ZT_EPP.ZT_EPP_ActivWorkPin(0x00, 0x01); ZT_EPP.ZT_EPP_SetDesPara(0x01, 0x20); ZT_EPP.ZT_EPP_SetDesPara(0x07, 0x10); ZT_EPP.ZT_EPP_PinAdd(1, 0, source, sbMac); return(sbMac.ToString().Substring(0, 16)); }
/// <summary> /// 计算Track码 /// </summary> /// <param name="source"></param> /// <returns></returns> public string CalculateTRK(StringBuilder source) { File.AppendAllText("track.txt", source.ToString()); StringBuilder result = new StringBuilder(); StringBuilder resultOnce = new StringBuilder(); ZT_EPP.ZT_EPP_ActivWorkPin(0x00, 0x02); ZT_EPP.ZT_EPP_SetDesPara(0x01, 0x30); int sourcelength = source.ToString().Length; if (sourcelength % 16 != 0) { throw new ArgumentException("数据源长度不正确,必须为16的倍数!"); } int count = sourcelength / 16; for (int i = 0; i < count; i++) { ZT_EPP.ZT_EPP_PinAdd(2, 0, new StringBuilder(source.ToString().Substring(i * 16, 16)), resultOnce); result.Append(resultOnce.ToString()); } return(result.ToString().Substring(0, sourcelength)); }