public SunKeyException(string message) : base(0, message) { int code = SunKeyAPI.GetUkeyLastErr(); SetCode(code); }
public SunKeyException() : base(0, "") { int code = SunKeyAPI.GetUkeyLastErr(); SetCode(code); }
public SunKeyException(int code, string message) : base(code, message) { if (code == 0) { code = SunKeyAPI.GetUkeyLastErr(); SetCode(code); } }
public SunKeyException(int code) : base(code, "") { if (code == 0) { code = SunKeyAPI.GetUkeyLastErr(); SetCode(code); } }
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); }
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(""); }
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); }
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(""); }
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); }
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); }
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); }
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); } }
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); } }