Exemplo n.º 1
0
        public static bool Sign_SHA256(string Input, ref string Output)
        {
            bool bResult = false;

            try
            {
                byte[]        SHA256Data = Encoding.UTF8.GetBytes(Input); // Encoding.GetEncoding("GBK").GetBytes(Input); //Encoding.Default.GetBytes(Input); //
                SHA256Managed Sha256     = new SHA256Managed();
                byte[]        Result     = Sha256.ComputeHash(SHA256Data);
                //Output= Convert.ToBase64String(Result);  //返回长度为44字节的字符串
                Output  = MyTools.ByteToString(Result, 0, Result.Length);
                bResult = true;
            }
            catch (Exception ex)
            {
                Output = "计算SHA256出错(ex=" + ex.ToString() + ")";
            }
            return(bResult);
        }
Exemplo n.º 2
0
        public bool ReadCardInf(out string szInf)
        {
            szInf = "";
            bool bResult = false;

            byte[] sData   = new byte[30];
            byte[] rData   = new byte[50];
            int    iRetLen = 0;

            sData[0] = 0xA5;
            sData[1] = 0x00;

            //Thread.Sleep(100);
            if (SendOrder(sData, 2, ref rData, ref iRetLen))
            {
                szInf = MyTools.ByteToString(rData, 2, iRetLen);
                if (rData[0] == 0 && rData[1] == 0 && iRetLen == 40)
                {
                    bResult = true;
                }
            }
            return(bResult);
        }