dhkeyobject.java

来自「Application to generate Diffie-Hellman a」· Java 代码 · 共 44 行

JAVA
44
字号
package src;

import java.io.*;
import java.util.Date;
import java.math.BigInteger;
import java.security.*;

/*
* This object is used for Public Key Exchange. 
* The Crypto routines require it.  I haven't put the heavy
* duty methods in here because I want it to stay small
*/ 

class DHKeyObject implements Serializable {

	BigInteger n,g;    /* These two make up the public Key */
	
	String Description;
	Date created;
	
	DHKeyObject(BigInteger N, BigInteger G,String what) {
		
		n = N;
		g = G;
		
		Description = what;
		created = new Date();
	}
	
	/* You may wish to customize the following */

	public String toString() {
		
		StringBuffer scratch = new StringBuffer();
		
		scratch.append("Public Key(n): " + n.toString(32) + "\n" );
		scratch.append("Public Key(g): " + g.toString(32) + "\n" );
		scratch.append("Description: "   + Description  + "\n" );
		scratch.append("Created: "       + created );
		
		return scratch.toString();
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?