使用数字签名实现数据库记录防篡改(Java实现)

2019-12-30 16:12:08丽君

 

接口

 

 类名

描述

Signature

The Signature class is used to provide applications the functionality of a digital signature algorithm.

KeyPair

This class is a simple holder for a key pair (a public key and a private key)

KeyPairGenerator

The KeyPairGenerator class is used to generate pairs of public and private keys.

 

对于接口和类的描述,我直接引用了Oracle上的J2SE 7的API描述[3],就不翻译成中文了,以防词不达意。大家看英文应该能更精确的明白其意思。

利用上述的接口和类,就可以进行数字签名和验证了,下面分三部分进行基本步骤的描述。

第一部分:生成密钥并存储

生成KeyPairGenerator实例,并调用其genKeyPair()方法生成KeyPair对象。 利用ObjectOutputStream实例,将KeyPair对象写到文件中,从而把密钥保存到文件中。