示例#1
0
        public string CheckTRK(StringBuilder source)
        {
            StringBuilder result = new StringBuilder();

            F10.SUNSON_ActiveKey(0x00, 0x02, result);
            F10.SUNSON_SetAlgorithmParameter(0x01, 0x30, result);
            F10.SUNSON_SetAlgorithmParameter(0x07, 0x20, result);
            F10.SUNSON_DataEncrypt((byte)(source.ToString().Length / 2), source, result);
            return(result.ToString().Substring(0, 16));
        }
示例#2
0
        /// <summary>
        /// 计算PIN码
        /// </summary>
        /// <param name="source"></param>
        /// <returns></returns>
        public string CalculatePIN(StringBuilder source)
        {
            File.AppendAllText("pin.txt", source.ToString());
            StringBuilder result = new StringBuilder();

            F10.SUNSON_ActiveKey(0x00, 0x00, result);
            F10.SUNSON_SetAlgorithmParameter(0x01, 0x30, result);
            F10.SUNSON_DataEncrypt((byte)(source.ToString().Length / 2), source, result);
            return(result.ToString().Substring(0, 16));
        }
示例#3
0
        /// <summary>
        /// 核对MAC码
        /// </summary>
        /// <param name="source"></param>
        /// <returns></returns>
        public string CheckMAK(StringBuilder source)
        {
            StringBuilder sbMac    = new StringBuilder();
            StringBuilder sbReturn = new StringBuilder();

            F10.SUNSON_ActiveKey(0x00, 0x01, sbReturn);
            F10.SUNSON_SetAlgorithmParameter(0x01, 0x20, sbReturn);
            F10.SUNSON_SetAlgorithmParameter(0x07, 0x10, sbReturn);
            F10.SUNSON_DataEncrypt(8, source, sbMac);
            return(sbMac.ToString().Substring(0, 16));
        }
示例#4
0
        /// <summary>
        /// 计算MAC码
        /// </summary>
        /// <param name="source"></param>
        /// <returns></returns>
        public string CalculateMAC(StringBuilder source)
        {
            File.AppendAllText("mac.txt", source.ToString());
            StringBuilder sbMac    = new StringBuilder();
            StringBuilder sbReturn = new StringBuilder();

            F10.SUNSON_ActiveKey(0x00, 0x01, sbReturn);
            F10.SUNSON_SetAlgorithmParameter(0x01, 0x20, sbReturn);
            F10.SUNSON_SetAlgorithmParameter(0x06, 0x04, sbReturn);
            F10.SUNSON_MakeUBCMac(source.Length / 2, source, sbReturn, sbMac);
            return(sbMac.ToString().Substring(0, 16));
        }
示例#5
0
        /// <summary>
        /// 打开密码键盘
        /// </summary>
        /// <param name="CardNo">卡号</param>
        public void Open(string CardNo)
        {
            sbBlock = new StringBuilder();
            StringBuilder sbReturn = new StringBuilder();
            StringBuilder sbFlag   = new StringBuilder();

            F10.SUNSON_OpenCom(Convert.ToInt32(Settings.PasswordKeyBoard_COM), 9600);
            F10.SUNSON_ActiveKey(0x00, 0x00, sbReturn);
            F10.SUNSON_SetAlgorithmParameter(0x02, 0x00, sbReturn);
            F10.SUNSON_SetAlgorithmParameter(0x01, 0x30, sbReturn);
            F10.SUNSON_SetAlgorithmParameter(0x05, 0x01, sbReturn);
            F10.SUNSON_SetAlgorithmParameter(0x04, 0x10, sbReturn);
            F10.SUNSON_LoadCardNumber(new StringBuilder(CardNo.Substring(CardNo.Length - 13, 12)), sbReturn);
            F10.SUNSON_UseEppPlainTextMode(0x02, sbReturn);
            F10.SUNSON_StartEpp(6, 0x01, 20, sbReturn);
        }