Exemplo n.º 1
0
        public SunKeyException(string message)
            : base(0, message)
        {
            int code = SunKeyAPI.GetUkeyLastErr();

            SetCode(code);
        }
Exemplo n.º 2
0
        public SunKeyException()
            : base(0, "")
        {
            int code = SunKeyAPI.GetUkeyLastErr();

            SetCode(code);
        }
Exemplo n.º 3
0
 public SunKeyException(int code, string message)
     : base(code, message)
 {
     if (code == 0)
     {
         code = SunKeyAPI.GetUkeyLastErr();
         SetCode(code);
     }
 }
Exemplo n.º 4
0
 public SunKeyException(int code)
     : base(code, "")
 {
     if (code == 0)
     {
         code = SunKeyAPI.GetUkeyLastErr();
         SetCode(code);
     }
 }
Exemplo n.º 5
0
 public bool Write(short wOffset, short len, byte[] pbDataBuf)
 {
     if (IsVerifyPass)
     {
         if (SunKeyAPI.Dev_SunKeyWrite(mSunKeyHandle, wOffset, len, pbDataBuf))
         {
             return(true);
         }
         else
         {
             System.Console.Out.WriteLine("SunkeyLastErr = " + new SunKeyException().FullMessage);
         }
     }
     return(false);
 }
Exemplo n.º 6
0
 public string Read(short wOffset, short len)
 {
     if (IsVerifyPass)
     {
         byte[] pbDataBuf = new byte[len];
         if (SunKeyAPI.Dev_SunKeyRead(mSunKeyHandle, wOffset, len, pbDataBuf))
         {
             return(System.Text.Encoding.Default.GetString(pbDataBuf));
         }
         else
         {
             System.Console.Out.WriteLine("SunkeyLastErr = " + new SunKeyException().FullMessage);
         }
     }
     return("");
 }
Exemplo n.º 7
0
        public bool Write(short wOffset, string dataBuf)
        {
            if (IsVerifyPass)
            {
                byte[] pbDataBuf = System.Text.Encoding.Default.GetBytes(dataBuf);

                if (SunKeyAPI.Dev_SunKeyWrite(mSunKeyHandle, wOffset, (short)pbDataBuf.Length, pbDataBuf))
                {
                    return(true);
                }
                else
                {
                    System.Console.Out.WriteLine("SunkeyLastErr = " + new SunKeyException().FullMessage);
                }
            }
            return(false);
        }
Exemplo n.º 8
0
        public string GetGuid()
        {
            if (IsOpen)
            {
                byte[] pGuid = new byte[GUIDSIZE];
                short  wLen  = GUIDSIZE;

                if (SunKeyAPI.Dev_SunKeyGetGuid(mSunKeyHandle, pGuid, ref wLen))
                {
                    return(System.Text.Encoding.Default.GetString(pGuid));
                }
                else
                {
                    System.Console.Out.WriteLine("SunkeyLastErr = " + new SunKeyException().FullMessage);
                }
            }
            return("");
        }
Exemplo n.º 9
0
        public bool UnBlockPIN(PinType PinType, string unBlockPin)
        {
            if (IsOpen)
            {
                byte[] pbUnBlockPin = System.Text.Encoding.Default.GetBytes(unBlockPin);

                if (SunKeyAPI.Dev_SunKeyUnBlockPIN(mSunKeyHandle, (byte)PinType, pbUnBlockPin, (short)pbUnBlockPin.Length))
                {
                    mPinCount = MAXPINCOUNT;
                    return(true);
                }
                else
                {
                    System.Console.Out.WriteLine("SunkeyLastErr = " + new SunKeyException().FullMessage);
                }
            }
            return(false);
        }
Exemplo n.º 10
0
        public bool ChangePIN(PinType PinType, string oldPin, string newPin)
        {
            if (IsOpen)
            {
                byte[] pbOld = System.Text.Encoding.Default.GetBytes(oldPin);
                byte[] pbNew = System.Text.Encoding.Default.GetBytes(newPin);

                if (SunKeyAPI.Dev_SunKeyChangePIN(mSunKeyHandle, (byte)PinType, pbOld, (short )pbOld.Length, pbNew, (short)pbNew.Length))
                {
                    return(true);
                }
                else
                {
                    System.Console.Out.WriteLine("SunkeyLastErr = " + new SunKeyException().FullMessage);
                }
            }
            return(false);
        }
Exemplo n.º 11
0
        public bool VerifyPIN(PinType PinType, string sPin)
        {
            if (IsOpen)
            {
                byte[] pbPin = System.Text.Encoding.Default.GetBytes(sPin);

                if (SunKeyAPI.Dev_SunKeyVerifyPIN(mSunKeyHandle, (byte)PinType, pbPin, (short)pbPin.Length, ref mPinCount))
                {
                    mIsVerifyPass = true;
                    return(true);
                }
                else
                {
                    mIsVerifyPass = false;
                    mPinCount     = 0;
                    System.Console.Out.WriteLine("SunkeyLastErr = " + new SunKeyException().FullMessage);
                }
            }
            return(false);
        }
Exemplo n.º 12
0
 public bool Open()
 {
     if (!IsOpen)
     {
         if (SunKeyAPI.Dev_SunKeyOpen(ref mSunKeyHandle))
         {
             mIsOpen = true;
             return(true);
         }
         else
         {
             System.Console.Out.WriteLine("SunkeyLastErr = " + new SunKeyException().FullMessage);
         }
         return(false);
     }
     else
     {
         return(true);
     }
 }
Exemplo n.º 13
0
 public bool Close()
 {
     if (IsOpen)
     {
         if (SunKeyAPI.Dev_SunKeyClose(mSunKeyHandle))
         {
             mPinCount     = 0;
             mIsVerifyPass = false;
             mIsOpen       = false;
             return(true);
         }
         else
         {
             System.Console.Out.WriteLine("SunkeyLastErr = " + new SunKeyException().FullMessage);
         }
         return(false);
     }
     else
     {
         return(true);
     }
 }