本文整理汇总了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());
}
示例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;
}
示例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());
}
示例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);
}