Пример #1
0
        /// <summary>
        /// 获取密码
        /// </summary>
        /// <returns></returns>
        public string GetPinBlock()
        {
            StringBuilder sbBlock = new StringBuilder();

            F10.SUNSON_ReadCypherPin(sbBlock);
            return(sbBlock.ToString().Substring(0, 16));
        }
Пример #2
0
        /// <summary>
        /// 扫描键盘输入。
        /// </summary>
        /// <returns>返回输入结果,用于前台显示。</returns>
        public F10Key ScanKey()
        {
            StringBuilder sbKey = new StringBuilder();

            F10.SUNSON_ScanKeyPress(sbKey);
            return((F10Key)(Encoding.ASCII.GetBytes(sbKey.ToString())[0]));
        }
Пример #3
0
        /// <summary>
        /// 签到
        /// </summary>
        /// <returns></returns>
        public void LoadWorkKeySign(StringBuilder sbWorkKey, StringBuilder sbMak, StringBuilder sbTrk = null)
        {
            StringBuilder sbReturn = new StringBuilder();

            F10.SUNSON_OpenCom(Convert.ToInt32(Settings.PasswordKeyBoard_COM), 9600);

            #region 01. PIN加密工作密钥
            F10.SUNSON_SetAlgorithmParameter(0x05, 0x04, sbReturn);
            F10.SUNSON_SetAlgorithmParameter(0x00, 0x30, sbReturn);
            F10.SUNSON_LoadWorkKey(0x00, 0x00, 0x10, sbWorkKey, sbReturn);
            #endregion

            #region 02. Mac密钥
            F10.SUNSON_SetAlgorithmParameter(0x00, 0x20, sbReturn);
            F10.SUNSON_SetAlgorithmParameter(0x05, 0x04, sbReturn);
            F10.SUNSON_SetAlgorithmParameter(0x00, 0x30, sbReturn);
            F10.SUNSON_LoadWorkKey(0x00, 0x01, 0x08, sbMak, sbReturn);
            #endregion

            if (sbTrk == null)
            {
                return;
            }
            #region 03. Track工作密钥 TRK
            F10.SUNSON_SetAlgorithmParameter(0x05, 0x04, sbReturn);
            F10.SUNSON_SetAlgorithmParameter(0x00, 0x30, sbReturn);
            F10.SUNSON_LoadWorkKey(0x00, 0x02, 0x10, sbTrk, sbReturn);
            #endregion
        }
Пример #4
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));
        }
Пример #5
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));
        }
Пример #6
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));
        }
Пример #7
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));
        }
Пример #8
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);
        }
Пример #9
0
        /// <summary>
        /// 关闭键盘
        /// </summary>
        public void Close()
        {
            StringBuilder sbReturn = new StringBuilder();

            F10.SUNSON_UseEppPlainTextMode(0x00, sbReturn);
        }
Пример #10
0
 public string GetPinBlock()
 {
     F10.SUNSON_ReadCypherPin(sbBlock);
     return(sbBlock.ToString().Substring(0, 16));
 }