• 大小: 7KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-08-01
  • 语言: 其他
  • 标签:

资源简介

信息安全实习 基于Diffle-Human的密钥交换,实现了图形界面化,包含实习报告。

资源截图

代码片段和文件信息

package dh.a;

import java.io.FileInputStream;
import java.io.objectInputStream;
import java.security.PrivateKey;
import java.security.PublicKey;

import javax.crypto.KeyAgreement;
import javax.crypto.spec.SecretKeySpec;

public class KeyAgree {

/**
 * @param args
 * @throws Exception
 */
public static void main(String args[]) throws Exception {
// TODO Auto-generated method stub
// 读取DH私钥和对方公钥
FileInputStream f1 = new FileInputStream(“Skey_DH_pbk.dat“);
objectInputStream b1 = new objectInputStream(f1);
PublicKey pbk = (PublicKey) b1.readobject();

FileInputStream f2 = new FileInputStream(“Skey_DH_prk.dat“);
objectInputStream b2 = new objectInputStream(f2);
PrivateKey prk = (PrivateKey) b2.readobject();

// 创建私钥协定对象
KeyAgreement ka = KeyAgreement.getInstance(“DH“);
// 用自己的私钥初始化密钥协定对象
ka.init(prk);
// 执行私钥协定对象的doPhase()方法,其在第一个参数中传入对方公钥
ka.doPhase(pbk true);
// 生成共享信息
// 生成共享秘密并在新的缓冲区中返回它
byte[] sb = ka.generateSecret();
for (int i = 0; i < sb.length; i++) {
System.out.print(sb[i] + ““);
}
// 根据共享信息利用SecretKeySpec类创建密钥
@SuppressWarnings(“unused“)
SecretKeySpec k = new SecretKeySpec(sb “DESede“);

}

}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        232  2011-05-02 17:03  基于Diffle-Human的密钥交换\.classpath

     文件        380  2011-05-02 17:03  基于Diffle-Human的密钥交换\.project

     文件       1973  2011-05-02 20:06  基于Diffle-Human的密钥交换\bin\dh\a\KeyAgree.class

     文件       2842  2011-05-02 20:06  基于Diffle-Human的密钥交换\bin\dh\a\Key_DH.class

     文件        552  2011-05-02 20:04  基于Diffle-Human的密钥交换\Skey_DH_pbk.dat

     文件        489  2011-05-02 20:04  基于Diffle-Human的密钥交换\Skey_DH_prk.dat

     文件       1315  2011-05-02 20:06  基于Diffle-Human的密钥交换\src\dh\a\KeyAgree.java

     文件       3138  2011-05-02 20:06  基于Diffle-Human的密钥交换\src\dh\a\Key_DH.java

     目录          0  2011-05-02 20:07  基于Diffle-Human的密钥交换\bin\dh\a

     目录          0  2011-05-02 20:07  基于Diffle-Human的密钥交换\src\dh\a

     目录          0  2011-05-02 20:07  基于Diffle-Human的密钥交换\bin\dh

     目录          0  2011-05-02 20:07  基于Diffle-Human的密钥交换\src\dh

     目录          0  2011-05-02 20:07  基于Diffle-Human的密钥交换\bin

     目录          0  2011-05-02 20:07  基于Diffle-Human的密钥交换\src

     目录          0  2011-05-02 20:07  基于Diffle-Human的密钥交换

----------- ---------  ---------- -----  ----

                10921                    15


评论

共有 条评论