private void btnBiometria_Click(object sender, EventArgs e) { if (txtUsername.Text == "") { MessageBox.Show("Favor, preencher o campo de usuário", "Projeto Biometria", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtUsername.Focus(); } else { uint reta = m_NBioAPI.OpenDevice(NBioAPI.Type.DEVICE_ID.AUTO); user = new User(); userC = new UserController(); user = userC.selectUser(txtUsername.Text); bool result; if (user != null) { NBioAPI.Type.HFIR bNewFIR = new NBioAPI.Type.HFIR(); NBioAPI.Type.FIR m_biFIR = new NBioAPI.Type.FIR(); NBioAPI.Type.FIR_PAYLOAD myPayload = new NBioAPI.Type.FIR_PAYLOAD(); m_biFIR.Format = (uint)user.Format; m_biFIR.Data = user.Digital; m_biFIR.Header.DataLength = (uint)user.DataLength; m_biFIR.Header.DataType = (ushort)user.DataType; m_biFIR.Header.Length = (uint)user.Length; m_biFIR.Header.Purpose = (ushort)user.Purpose; m_biFIR.Header.Quality = (ushort)user.Quality; m_biFIR.Header.Reserved = (uint)user.Reserved; m_biFIR.Header.Version = (ushort)user.Version; uint ret = m_NBioAPI.Verify(m_biFIR, out result, myPayload); if (result) { MessageBox.Show("Verificação bem Sucedida!!", "Projeto Biometria", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Hide(); this.ShowIcon = false; this.ShowInTaskbar = false; frmMain main = new frmMain(user); main.ShowDialog(); this.ShowIcon = true; this.ShowInTaskbar = true; this.Show(); } else { MessageBox.Show("Verificação Incorreta! Tente novamente", "´Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } m_NBioAPI.CloseDevice(NBioAPI.Type.DEVICE_ID.AUTO); } }
public bool VerificarDigitais(NBioAPI.Type.FIR userFRI) { uint ret; bool result; ret = nBioApi.Verify(userFRI, out result, null); if (ret != NBioAPI.Error.NONE) { throw new Exception(); } return(result); }
private void ISO2Check_Click(object sender, EventArgs e) { byte[] ISOBuf; listRet.Items.Clear(); listRet.Items.Add("ISO 19794-4 data check start..."); uint nRet = MakeISO4Data(out ISOBuf); if (nRet == NBioAPI.Error.NONE) { NBioAPI.Export.EXPORT_DATA exportData; nRet = ConvertISO4ToISO2(ISOBuf, out exportData); if (nRet == NBioAPI.Error.NONE) { NBioAPI.Type.HFIR hProcessedFIR; nRet = m_Export.ImportDataToNBioBSP(exportData, NBioAPI.Type.FIR_PURPOSE.VERIFY, out hProcessedFIR); if (nRet == NBioAPI.Error.NONE) { bool bRet; listRet.Items.Add("Match start..."); m_NBioAPI.OpenDevice(NBioAPI.Type.DEVICE_ID.AUTO); nRet = m_NBioAPI.Verify(hProcessedFIR, out bRet, null); m_NBioAPI.CloseDevice(NBioAPI.Type.DEVICE_ID.AUTO); if (nRet == NBioAPI.Error.NONE) { if (bRet) { MessageBox.Show("Match Success!!"); } else { MessageBox.Show("Match Fail!!"); } } hProcessedFIR.Dispose(); } } } }
public void Leitura(string Arquivo, string PathSalvamento) { NBioAPI HandleBio; uint Retorno = NBioAPI.Error.NONE; uint NenhumErro = NBioAPI.Error.NONE; NBioAPI.Type.MINCONV_DATA_TYPE importType; NBioAPI.Export m_Export; NBioAPI.Type.HFIR processedFIR; NBioAPI.Type.INIT_INFO_0 initInfo0; uint nSize = 0; byte[] minData = null; //----------------------- try { FileStream fs = new FileStream(PathSalvamento + Arquivo, FileMode.Open, FileAccess.Read); BinaryReader fr = new BinaryReader(fs); nSize = (uint)fs.Length; minData = new byte[nSize]; fr.Read(minData, 0, (int)nSize); fr.Close(); fs.Close(); } catch (FileNotFoundException e) { MessageBox.Show("Erro localizar arquivo biometrico\n" + e.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } HandleBio = new NBioAPI(); HandleBio.OpenDevice(NBioAPI.Type.DEVICE_ID.AUTO); if (Retorno != NenhumErro) { MessageBox.Show("Erro ao verificar digital", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); HandleBio.Dispose(); return; } importType = NBioAPI.Type.MINCONV_DATA_TYPE.MINCONV_TYPE_FDU; m_Export = new NBioAPI.Export(HandleBio); Retorno = m_Export.FDxToNBioBSPEx(minData, nSize, importType, NBioAPI.Type.FIR_PURPOSE.VERIFY, out processedFIR); if (Retorno != NenhumErro) { MessageBox.Show("Erro ao verificar digital", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); HandleBio.CloseDevice(NBioAPI.Type.DEVICE_ID.AUTO); HandleBio.Dispose(); return; } Retorno = HandleBio.GetInitInfo(out initInfo0); if (Retorno != NenhumErro) { MessageBox.Show("Erro ao coletar informações do dispositivo", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); HandleBio.Dispose(); return; } initInfo0.EnrollImageQuality = 90; initInfo0.VerifyImageQuality = 90; initInfo0.SecurityLevel = 7; Retorno = HandleBio.SetInitInfo(initInfo0); if (Retorno != NenhumErro) { MessageBox.Show("Erro ao setar informações iniciais do dispositivo", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); HandleBio.Dispose(); return; } Boolean bResult; Retorno = HandleBio.Verify(processedFIR, out bResult, null); if (Retorno != NenhumErro) { MessageBox.Show("Erro ao verificar digital", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { if (!bResult) { MessageBox.Show("Vendedor não autenticado", "Falha ao autenticar", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { try { MessageBox.Show("Autenticação realizada com sucesso", "Sucesso!!", MessageBoxButtons.OK, MessageBoxIcon.None); FileStream validacao = new FileStream(Path.GetTempPath() + "Result_" + Arquivo, FileMode.CreateNew, FileAccess.Write); BinaryWriter fw = new BinaryWriter(validacao); fw.Write("#$&%&$*%¨$*$¨%$*&($$)$)$¨$&¨%$*$&¨#%%(*%)"); fw.Close(); validacao.Close(); } catch (FileNotFoundException e) { MessageBox.Show("Erro localizar arquivo biometrico\n" + e.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } } HandleBio.CloseDevice(NBioAPI.Type.DEVICE_ID.AUTO); }