这里面包含了一百多个JAVA源文件

源代码在线查看: e198. generating a public private key pair.txt

软件大小: 551 K
上传用户: maple_78
关键词: JAVA
下载地址: 免注册下载 普通下载 VIP

相关代码

				This example generates a key pair for various public/private key algorithms. See also e197 Listing All Available Public/Private Key Generators. 
				    try {
				        // Generate a 1024-bit Digital Signature Algorithm (DSA) key pair
				        KeyPairGenerator keyGen = KeyPairGenerator.getInstance("DSA");
				        keyGen.initialize(1024);
				        KeyPair keypair = keyGen.genKeyPair();
				        PrivateKey privateKey = keypair.getPrivate();
				        PublicKey publicKey = keypair.getPublic();
				    
				        // Generate a 576-bit DH key pair
				        keyGen = KeyPairGenerator.getInstance("DH");
				        keyGen.initialize(576);
				        keypair = keyGen.genKeyPair();
				        privateKey = keypair.getPrivate();
				        publicKey = keypair.getPublic();
				    
				        // Generate a 1024-bit RSA key pair
				        keyGen = KeyPairGenerator.getInstance("RSA");
				        keyGen.initialize(1024);
				        keypair = keyGen.genKeyPair();
				        privateKey = keypair.getPrivate();
				        publicKey = keypair.getPublic();
				    } catch (java.security.NoSuchAlgorithmException e) {
				    }
				
							

相关资源