当前位置: 首页>>代码示例>>Java>>正文


Java OpenSSLKey.encrypt方法代码示例

本文整理汇总了Java中org.globus.gsi.OpenSSLKey.encrypt方法的典型用法代码示例。如果您正苦于以下问题:Java OpenSSLKey.encrypt方法的具体用法?Java OpenSSLKey.encrypt怎么用?Java OpenSSLKey.encrypt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.globus.gsi.OpenSSLKey的用法示例。


在下文中一共展示了OpenSSLKey.encrypt方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testEcryptedToString

import org.globus.gsi.OpenSSLKey; //导入方法依赖的package包/类
public void testEcryptedToString() throws Exception {
       KeyPair keyPair = getKeyPair();
OpenSSLKey inKey = new BouncyCastleOpenSSLKey(keyPair.getPrivate());
assertTrue(!inKey.isEncrypted());
inKey.encrypt(pwd);
assertTrue(inKey.isEncrypted());
       
       ByteArrayInputStream in = null;
       in = new ByteArrayInputStream(toString(inKey).getBytes());
       OpenSSLKey outKey = new BouncyCastleOpenSSLKey(in);
       assertTrue(outKey.isEncrypted());

       in = new ByteArrayInputStream(toString(outKey).getBytes());
       OpenSSLKey outKey2 = new BouncyCastleOpenSSLKey(in);
       assertTrue(outKey2.isEncrypted());
   }
 
开发者ID:NCIP,项目名称:cagrid-general,代码行数:17,代码来源:BouncyCastleOpenSSLKeyTest.java

示例2: writePrivateKey

import org.globus.gsi.OpenSSLKey; //导入方法依赖的package包/类
public static String writePrivateKey(PrivateKey key, String password)
		throws Exception {
	OpenSSLKey ssl = new BouncyCastleOpenSSLKey(key);
	if (password != null) {
		ssl.encrypt(password);
	}
	StringWriter sw = new StringWriter();
	ssl.writeTo(sw);
	sw.close();
	StringBuffer buf = sw.getBuffer();
	// strip out any windows-specific carriage return chars
	int winNlChar = -1;
	while ((winNlChar = buf.indexOf("\r")) != -1) {
	    buf.deleteCharAt(winNlChar);
	}
	String s = buf.toString();
	return s;
}
 
开发者ID:NCIP,项目名称:cagrid-core,代码行数:19,代码来源:KeyUtil.java

示例3: testEncrypt

import org.globus.gsi.OpenSSLKey; //导入方法依赖的package包/类
public void testEncrypt() throws Exception {
       KeyPair keyPair = getKeyPair();

OpenSSLKey key = new BouncyCastleOpenSSLKey(keyPair.getPrivate());

assertTrue(!key.isEncrypted());

key.encrypt(pwd);

assertTrue(key.isEncrypted());
   }
 
开发者ID:NCIP,项目名称:cagrid-general,代码行数:12,代码来源:BouncyCastleOpenSSLKeyTest.java

示例4: testEncryptAES

import org.globus.gsi.OpenSSLKey; //导入方法依赖的package包/类
public void testEncryptAES() throws Exception {
       KeyPair keyPair = getKeyPair();

OpenSSLKey key = new BouncyCastleOpenSSLKey(keyPair.getPrivate());

assertTrue(!key.isEncrypted());

       key.setEncryptionAlgorithm("AES-128-CBC");

key.encrypt(pwd);

assertTrue(key.isEncrypted());

       key.writeTo(System.out);
   }
 
开发者ID:NCIP,项目名称:cagrid-general,代码行数:16,代码来源:BouncyCastleOpenSSLKeyTest.java


注:本文中的org.globus.gsi.OpenSSLKey.encrypt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。