hidglobal / digitalpersona-devices

DigitalPersona Security Devices support library
https://hidglobal.github.io/digitalpersona-devices/index.html
MIT License
64 stars 41 forks source link

fingerprint verification #32

Closed monicaardila closed 2 years ago

monicaardila commented 2 years ago

good morning, I have a problem with fingerprint verification... I don't know digitalpersona/devices has a library to verify fingerprints and if digital persona doesn't have this library I don't know how to make a function to buy two matrices since the fingerprints are taken in different positions and it would be almost impossible for me to make a condition for that. I just want a function that allows me to verify fingerprints `import { ChangeDetectorRef, Input, Component, OnInit, OnDestroy, ViewChild, } from '@angular/core';

import { FingerprintReader, SampleFormat, DeviceConnected, DeviceDisconnected, SamplesAcquired, AcquisitionStarted, AcquisitionStopped, } from '@digitalpersona/devices'; import './core/modules/WebSdk';

@Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css'], }) export class AppComponent implements OnInit, OnDestroy { title = 'demo-fingerprint-reader'; ListaFingerprintReader: any; InfoFingerprintReader: any; ListaSamplesFingerPrints: any; matches:any; currentImageFinger: any; ListaHuellas:String[]=[]; threshold:any; currentImageFingerFixed:any; resul:any;

private reader: FingerprintReader;

constructor() { this.reader = new FingerprintReader(); }

private onDeviceConnected = (event: DeviceConnected) => {}; private onDeviceDisconnected = (event: DeviceDisconnected) => {};

private onAcquisitionStarted = (event: AcquisitionStarted) => { console.log('En el evento:onAcquisitionStarted'); console.log(event); };

private onAcquisitionStopped = (event: AcquisitionStopped) => { console.log('En el evento:onAcquisitionStopped'); console.log(event); };

private onSamplesAcquired = (event: SamplesAcquired) => { console.log('en el evento:adquisicon de imagen'); console.log(event); this.ListaSamplesFingerPrints = event; }; ngOnInit() { this.reader = new FingerprintReader(); this.reader.on('DeviceConnected', this.onDeviceConnected); this.reader.on('DeviceDisconnected', this.onDeviceDisconnected); this.reader.on('AcquisitionStarted', this.onAcquisitionStarted); this.reader.on('AcquisitionStopped', this.onAcquisitionStopped); this.reader.on('SamplesAcquired', this.onSamplesAcquired); } ngOnDestroy() { this.reader.on('DeviceConnected', this.onDeviceConnected); this.reader.on('DeviceDisconnected', this.onDeviceDisconnected); this.reader.on('AcquisitionStarted', this.onAcquisitionStarted); this.reader.on('AcquisitionStopped', this.onAcquisitionStopped); this.reader.on('SamplesAcquired', this.onSamplesAcquired); } //Lista de dispositivos conectados fn_ListaDispositivos() { Promise.all([this.reader.enumerateDevices()]) .then((results) => { this.ListaFingerprintReader = results[0]; console.log('Dato Dispositivos'); console.log('this.listaFingerprintReader'); }) .catch((error) => { console.log(error); }); } //Obtener Informacion DE Dispositivo fn_DeviceInfo() { Promise.all([ this.reader.getDeviceInfo(this.ListaFingerprintReader[0]), ]).then((results) => { this.InfoFingerprintReader = results[0]; console.log('Info FingerReader'); console.log('this.InfoFingerprintReader'); }); } //Inicia Device para lectura fn_StartCapturaFP() { this.reader.startAcquisition(SampleFormat.PngImage , this.InfoFingerprintReader['DeviceID']) .then((response) => { console.log('Ud puede iniciar a capturar !!'); console.log(response); console.log(this.currentImageFingerFixed ); }) .catch((error) => { console.log(error); }); } //Detener Device para lectura fn_EndCapturaFP() { this.reader .stopAcquisition(this.InfoFingerprintReader['DeviceID']) .then((response) => { console.log('Se paro de capturar !!'); console.log(response); }) .catch((error) => { console.log(error); }); } //Mostar Captura fn_CapturaFP() { var ListImages = this.ListaSamplesFingerPrints['samples']; var lsize = Object.keys(ListImages).length; if (ListImages != null && ListImages != undefined) { if (lsize > 0) { this.currentImageFinger = ListImages[0]; this.currentImageFingerFixed = this.fn_fixFormatImageBase64(this.currentImageFinger); this.ListaHuellas.push(this.currentImageFingerFixed) console.log('ES LA LISTA DE HUELLA',this.ListaHuellas); this.fn_huellaigual(); } } } //Corregir Formato Base64 fn_fixFormatImageBase64(prm_imagebase:any) { var strImage = ""; strImage = prmimagebase; //Remplaza Caracteres no Validos 0 strImage = strImage.replace(//g, "/"); strImage = strImage.replace(/-/g, "+"); return strImage; } //verification fn_huellaigual(){ if((this.ListaHuellas[0])==this.ListaHuellas[1]){ console.log('son iguales') } console.log(' NO son iguales')

} } ` Captura

a-bronx commented 2 years ago

Hello,

This library performs only fingerprint capturing.

It is a bad practice to run fingerprint matching in a browser, because browsers are untrusted, and results of your verification can be easily replaced by a malicious JavaScript code. You should use a trusted authentication server instead.

Also it is a bad security practice to implement your own fingerprint matching engine, unless you do it for study or research. Fingerprint matching engines use hard math, proprietary algorithms and they are resource-demanding, so they are usually implemented in some native language "closer to the metal" (C, C++ etc), Best engines are certified by NIST or other trusted agency. We suggest to use some proven and certified fingerprint matching engine, like FingerJet (can be obtained as an SDK or as a part of the DigitalPersona Authentication Server) or similar.