I have already retrieved the bytes of arrays stored in a SQL Server database for verification purposes.
The problem is, when I convert from Base64String
this error message shows up.
The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters.
This is my code.
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Data;
//imports
using DHELTASSys.Modules;
namespace Enrollment
{
/* NOTE: This form is inherited from the CaptureForm,
so the VisualStudio Form Designer may not load it properly
(at least until you build the project).
If you want to make changes in the form layout - do it in the base CaptureForm.
All changes in the CaptureForm will be reflected in all derived forms
(i.e. in the EnrollmentForm and in the VerificationForm)
*/
public class VerificationForm : CaptureForm
{
AttendanceModuleBL attendance = new AttendanceModuleBL();
delegate void Function();
public void Verify()
{
ShowDialog();
}
protected override void Init()
{
base.Init();
base.Text = "Fingerprint Verification";
DPFP.Verification.Verification Verificator = new DPFP.Verification.Verification(); // Create a fingerprint template verificator
UpdateStatus(0);
}
protected override void Process(DPFP.Sample Sample)
{
int i = 0;
int x = 3;
DataTable dt = attendance.GetEmployeeFingerprint();
do
{
string converted = dt.Rows[x][1].ToString();
converted.Replace('-', '+');
converted.Replace('_', '/');
byte[] fingerprint = Convert.FromBase64String(converted);
DPFP.Template Template = new DPFP.Template();
Template.DeSerialize(fingerprint);
DPFP.Verification.Verification Verificator = new DPFP.Verification.Verification();
base.Process(Sample);
// Process the sample and create a feature set for the enrollment purpose.
DPFP.FeatureSet features = ExtractFeatures(Sample, DPFP.Processing.DataPurpose.Verification);
// Check quality of the sample and start verification if it's good
// TODO: move to a separate task
if (features != null)
{
// Compare the feature set with our template
DPFP.Verification.Verification.Result result = new DPFP.Verification.Verification.Result();
Verificator.Verify(features, Template, ref result);
UpdateStatus(result.FARAchieved);
if (result.Verified)
{
MakeReport("The fingerprint was VERIFIED.\n" + dt.Rows[x][0].ToString());
}
else
{
MakeReport("The fingerprint was NOT VERIFIED.");
x++;
}
}
} while (i == 0);
}
private void UpdateStatus(int FAR)
{
// Show "False accept rate" value
SetStatus(String.Format("False Accept Rate (FAR) = {0}", FAR));
}
}
}
I have stored the fingerprint template to SQL Server earlier using this code:
MemoryStream fingerprintData = new MemoryStream();
Template.Serialize(fingerprintData);
fingerprintData.Position = 0;
BinaryReader br = new BinaryReader(fingerprintData);
byte[] bytes = br.ReadBytes((Int32)fingerprintData.Length);
I don't seem to know a workaround in this issue.
Thanks in advance!