[英]Login into Asp.net Web application with Finerprint using asp.net C# Javascript
I want to login to my asp.net web application using fingerprint. 我想使用指纹登录到我的asp.net Web应用程序。 That means I don't want to use any login id and password. 这意味着我不想使用任何登录ID和密码。 I just want to login with my fingerprint. 我只想用我的指纹登录。 I have got a 3m cogent device and the device works fine but I don't know how to integrate the device with my software. 我有一个3m的cogent设备,该设备运行良好,但我不知道如何将该设备与我的软件集成。 I am using ActiveX. 我正在使用ActiveX。
My Javascript code is: 我的Javascript代码是:
<script type="text/javascript">
$(document).ready(function () {
$('#scan').click(function () {
$('#dicscan').addClass('scanning');
setTimeout(function () {
$('#dicscan').removeClass('scanning');
}, 20 * 1000);
});
});
</script>
<script type="text/javascript">
function OpenActiveX() {
var port = document.getElementById("Comport");
port.Conopen = 1;
if (port.error > 0) //Display errors if found
alert(port.ErrorDescription);
}
function Matching() {
var retval = 0;
var port = document.getElementById("Comport");
port.Ksserialnumber = 1;
port.KsCapture = 1;
port.KsAuthenticationMatch = 1;
retval = port.KsMatchretvalue;
if (retval > 0) {
alert("Two fingers are Matched...");
window.open('ResultPage.html', '_self');
}
else {
alert("Finger Not Matched...");
}
if (port.error > 0) //Display errors if found
alert(port.ErrorDescription);
}
</script>
I am getting undefined in port.KsMatchretvalue. 我在port.KsMatchretvalue中变得不确定。
I am using 3M Cogent CSD 200 model Finger Print reader device 我正在使用3M Cogent CSD 200型号指纹读取器设备
Hope you have SDK already Below is a little code for this device to capture and match details to allow log in . 希望您已经有了SDK。下面是该设备的一些代码,用于捕获和匹配详细信息以允许登录。
Two function here 这里有两个功能
1.] Capture - to save fingerprint 1.]捕获-保存指纹
2.] Match - to match fingetprint at the time of log in 2.]匹配-在登录时匹配fingetprint
Note : its a code block from my application , you have to made adjustment according to your application 注意:它是我的应用程序的代码块,您必须根据您的应用程序进行调整
byte[] bTemplateDataOne;
byte[] bTemplateDataTwo;
byte[] isoTemplateBytes;
bool ErroFlag = false;
int nTempltSizeOne;
int nTempltSizeTwo;
MMMCogentCSD200APIs csd200Obj = null;
CSD200Wrapper wr = null;
private void btnCapture_Click(object sender, EventArgs e)
{
try
{
int nRc = -1;
byte[] fpRawBytes = null;
int m_Width = 0, m_Height = 0;
isoTemplateBytes = null;
int nfiq = 0;
pictCaptureImg.Image = null;
pictCaptureImg.Refresh();
if (true == chkbCaptureOnly.Checked)
{
pbClaimed.Image = null;
pbClaimed.Refresh();
bTemplateDataOne = null;
nTempltSizeOne = -1;
bTemplateDataTwo = null;
nTempltSizeTwo = -1;
rbClaimed.Checked = true;
nRc = csd200Obj.captureFP(30000, ref fpRawBytes, ref m_Width, ref m_Height);
if (nRc == CSD200APICodes.SUCCESS && fpRawBytes != null)
{
bmp = CreateGreyscaleBitmap(fpRawBytes, m_Width, m_Height);
pictCaptureImg.Image = bmp;
MessageBox.Show("Fingerprint Capture Successful.");
}
else if (nRc == CSD200APICodes.ERROR_TIMEOUT)
{
MessageBox.Show("Fingerprint Capture Timeout");
}
else
{
MessageBox.Show("Fingerprint Capture Failed. ErrorCode: " + nRc);
}
}
else
{
nRc = csd200Obj.captureFP(30000, ref fpRawBytes, ref m_Width, ref m_Height, ref nfiq, ref isoTemplateBytes);
if (nRc == CSD200APICodes.SUCCESS && fpRawBytes != null)
{
bmp = CreateGreyscaleBitmap(fpRawBytes, m_Width, m_Height);
pictCaptureImg.Image = bmp;
if (rbClaimed.Checked == true)
{
pbClaimed.Image = bmp;
if (isoTemplateBytes != null)
{
bTemplateDataOne = isoTemplateBytes;
nTempltSizeOne = isoTemplateBytes.Length;
}
}
else
{
MessageBox.Show("Try Again , Some error occured");
}
MessageBox.Show("Fingerprint Capture Successful.\n NFIQ: " + nfiq);
}
else if (nRc == CSD200APICodes.ERROR_TIMEOUT)
{
MessageBox.Show("Fingerprint Capture Timeout");
}
else
{
MessageBox.Show("Fingerprint Capture Failed. ErrorCode: " + nRc);
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void btnMatch_Click(object sender, EventArgs e)
{
if (bTemplateDataOne != null )
{
//DataTable dt = new DataTable();
//dt.Columns.Add("value");
//for (int i = 0; i < bTemplateDataOne.Length; i++)
//{
// DataRow dr = dt.NewRow();
// dr["value"] = bTemplateDataOne[i];
// dt.Rows.Add(dr);
//}
bool isMatch = false;
int matched = 0;
int index = 0; ;
string strAppPath = Path.GetDirectoryName(Application.ExecutablePath);
try
{
string result1 = Convert.ToBase64String(bTemplateDataOne, 0, bTemplateDataOne.Length);
string connectionstring = ConfigurationManager.ConnectionStrings["Constr"].ConnectionString.ToString();
SqlConnection con = new SqlConnection(connectionstring);
con.Open();
SqlCommand cmd = new SqlCommand("select Biometric,Name,id from Details ", con);
DataSet ds = new DataSet();
SqlDataAdapter ad = new SqlDataAdapter(cmd);
ad.Fill(ds);
con.Close();
if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
{
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
bTemplateDataTwo = null;
bTemplateDataTwo = Convert.FromBase64String(ds.Tables[0].Rows[i][0].ToString());
nTempltSizeTwo = bTemplateDataTwo.Length;
//DataTable dt1 = new DataTable();
//dt1.Columns.Add("value");
//for (int ii = 0; ii < bTemplateDataTwo.Length; ii++)
//{
// DataRow dr = dt1.NewRow();
// dr["value"] = bTemplateDataTwo[ii];
// dt1.Rows.Add(dr);
//}
isMatch = csd200Obj.matchTemplates(bTemplateDataOne, bTemplateDataTwo);
if (isMatch == true)
{
index = i;
matched++;
}
}
if (matched > 0)
{
string msg = "Fingers are Matched." + Environment.NewLine;
msg += "Welcome: " + ds.Tables[0].Rows[index]["Name"];
msg +="( id : " + ds.Tables[0].Rows[index]["id"] + ")" + Environment.NewLine + "matched value : " + matched;
MessageBox.Show(msg);
WriteFMRFile(nTempltSizeOne, bTemplateDataOne, strAppPath + "\\One.fmr");
WriteFMRFile(nTempltSizeTwo, bTemplateDataTwo, strAppPath + "\\Two.fmr");
}
else
{
MessageBox.Show("Not Matched." + Environment.NewLine + "matched value : " + matched);
}
}
else
{
MessageBox.Show("There is no fingerprint saved in the system"+Environment.NewLine+"Register someone first .");
}
}
catch (BioSDK710Exception cgtEx)
{
MessageBox.Show(cgtEx.ShowError(), "CogentBioSDK710 Error");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
//else if(chkbCaptureOnly.Checked == true && (bTemplateDataOne == null || bTemplateDataTwo == null))
else if (chkbCaptureOnly.Checked == true && (bTemplateDataOne == null))
{
MessageBox.Show("Please uncheck 'Capture Only' and recapture.", "Warning");
}
//else if (chkbCaptureOnly.Checked == false && (bTemplateDataOne == null || bTemplateDataTwo == null))
else if (chkbCaptureOnly.Checked == false && (bTemplateDataOne == null))
{
MessageBox.Show("Please capture fingerprints.", "Warning");
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.