如何在java中将我的指纹图像存储在智能卡中 [英] How to store my finger print image in smart card in java

查看:68
本文介绍了如何在java中将我的指纹图像存储在智能卡中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

how to store my finger print image in smart card using java







我尝试过:



TerminalFactory factory = TerminalFactory.getDefault();

List terminals = factory.terminals()。list();

System.out.println(读者:+终端);

//使用第一个读卡器:

CardTerminal terminal = terminals.get( 0);

//与卡建立连接:

卡片卡= terminal.connect(T = 0);

System.out.println(卡片:+卡片);

CardChannel频道= card.getBasicChannel();





Iterator writers = ImageIO.getImageWritersByFormatName(bmp);

ImageWriter writer =(ImageWriter)writers.next();

File f = new File (Needed\\75.bmp);





MessageDigest messageDigest;

try {

messageDigest = MessageDigest.getInstance(MD5);

FileInputStream输入= new FileInputStream(f);

byte [] buffer = new byte [8192];

int length;

while((length = input.read(buffer))!= -1){

messageDigest.update(buffer,0,length);

}

byte [] raw = messageDigest.digest();



// 64位打印输出

BASE64Encoder encoder = new BASE64Encoder();

String base64 = encoder.encode(raw);





// System.out.print(base64。 toString());





String data = base64.toString();

byte [] offset = data.getBytes();

int length1 = data.length();



// System.out.print(offset) ;

尝试{

CommandAPDU commandAPDU = new CommandAPDU(0x00,0xB2,1,1,offset,0,length1);

byte [] commandBytes = commandAPDU.getBytes();

// System.out.print(commandBytes);

ResponseAPDU responseAPDU = null;

if(channel!= null){



responseAPDU = channel.transmit(commandAPDU);



byte [] result = responseAPDU.getBytes();

String s = new String(commandBytes);



System.out.println(Text Decryted:+ s.substring(5));







// System.out.print(responseAPDU);

}





}
catch(CardException e){

抛出新IOException(e);

}







//并显示结果

//JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),\"your file finger print是+ new String(base64.toString()));





//从运行其内部的给定文件计算

//计算摘要公式时

} catch(NoSuchAlgorithmException ex){

Logger.getLogger(JavaApplication1.class.getName())。log (Level.SEVERE,null,ex);

}





card.disconnect(false);




What I have tried:

TerminalFactory factory = TerminalFactory.getDefault();
List terminals = factory.terminals().list();
System.out.println("Reader: " + terminals);
// Use the first card reader:
CardTerminal terminal = terminals.get(0);
// Establish a connection with the card:
Card card = terminal.connect("T=0");
System.out.println("Card: " + card);
CardChannel channel = card.getBasicChannel();


Iterator writers = ImageIO.getImageWritersByFormatName("bmp");
ImageWriter writer = (ImageWriter)writers.next();
File f=new File("Needed\\75.bmp");


MessageDigest messageDigest;
try {
messageDigest = MessageDigest.getInstance("MD5");
FileInputStream input = new FileInputStream(f);
byte[] buffer = new byte[8192];
int length;
while( (length = input.read(buffer)) != -1 ) {
messageDigest.update(buffer, 0, length);
}
byte[] raw = messageDigest.digest();

//printout in 64 base
BASE64Encoder encoder = new BASE64Encoder();
String base64 = encoder.encode(raw);


// System.out.print(base64.toString());


String data=base64.toString();
byte[] offset=data.getBytes();
int length1=data.length();

// System.out.print(offset);
try {
CommandAPDU commandAPDU = new CommandAPDU(0x00, 0xB2, 1, 1, offset, 0, length1);
byte[] commandBytes = commandAPDU.getBytes();
// System.out.print(commandBytes);
ResponseAPDU responseAPDU = null;
if (channel != null) {

responseAPDU = channel.transmit(commandAPDU);

byte[] result=responseAPDU.getBytes();
String s = new String(commandBytes);

System.out.println("Text Decryted : " + s.substring(5));



// System.out.print(responseAPDU);
}


}
catch (CardException e) {
throw new IOException(e);
}



// and display the results
//JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"your file finger print is " + new String(base64.toString()));


// calculating from the given file running its inside
// while calculating the digest formula
} catch (NoSuchAlgorithmException ex) {
Logger.getLogger(JavaApplication1.class.getName()).log(Level.SEVERE, null, ex);
}


card.disconnect(false);

推荐答案

通常,您不会将指纹图像存储在智能卡中 - 您将在安全服务器上存储对指纹(和其他生物识别数据)的引用。这样,智能卡就会告诉您的系统需要哪种指纹,并将其与实际收到的数据进行比较。如果您将实际数据存储在智能卡中,它会通过提供要从不安全来源检查的数据来绕过安全性,因为犯罪分子可以用坏人的打印替换智能卡日期,您无法分辨!
Normally, you wouldn't store a fingerprint image in a smartcard - you'd store a reference to the fingerprint (and other biometric data) on your secured server. That way, the smartcard tells your system which fingerprint to expect, and you compare that to the data you actually receive. If you store the actual data in the smartcard, it bypasses the security by providing the data to check from an unsecured source as malefactors can replace the smartcard date with the bad guy's print and you can't tell!

您真的希望系统架构能够正常工作,因为它需要从卡读回。你期望这个冗长的卡片数据被读取多长时间?
Do you really hope system architecture would work as it requires to read back from card. How much time do you expect for this lengthy card data to be read??


这篇关于如何在java中将我的指纹图像存储在智能卡中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆