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


Java PGPPublicKey.encode方法代码示例

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


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

示例1: serializePublicKey

import org.bouncycastle.openpgp.PGPPublicKey; //导入方法依赖的package包/类
/**
 * Serialize a PGPPublicKey
 *
 * <p>The reason we're not using {@link PGPPublicKey#getEncoded()} is to use {@link
 * ArmoredOutputStream}.
 */
public static byte[] serializePublicKey(PGPPublicKey publicKey) throws IOException {
  try (ByteArrayOutputStream byteStream = new ByteArrayOutputStream()) {
    // NOTE: We have to close the ArmoredOutputStream before calling the underlying OutputStream's
    // "toByteArray". Failing to do so would result in a truncated serialization as we took the
    // byte array before the ArmoredOutputStream wrote all the data.
    //
    // Even "flushing" the ArmoredOutputStream isn't enough - as there are parts that are only
    // written by the ArmoredOutputStream when it is closed: the "-----END PGP PRIVATE KEY
    // BLOCK-----" (or similar) footer.
    try (ArmoredOutputStream out = new ArmoredOutputStream(byteStream)) {
      publicKey.encode(out);
    }
    return byteStream.toByteArray();
  }
}
 
开发者ID:google,项目名称:nomulus,代码行数:22,代码来源:KeySerializer.java

示例2: exportAscii

import org.bouncycastle.openpgp.PGPPublicKey; //导入方法依赖的package包/类
/**
 * *********************************************************************************** Exports given public key as
 * ASCII armored text.
 *
 * @param pgpKey key to export
 *
 * @return ASCII armored key text
 */
public static String exportAscii( PGPPublicKey pgpKey ) throws PGPException
{
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    try ( OutputStream os = new ArmoredOutputStream( out ) )
    {
        pgpKey.encode( os );
    }
    catch ( IOException ex )
    {
        throw new PGPException( "Failed to export PGP key", ex );
    }
    return out.toString();
}
 
开发者ID:subutai-io,项目名称:base,代码行数:22,代码来源:PGPKeyUtil.java

示例3: getPublicKey

import org.bouncycastle.openpgp.PGPPublicKey; //导入方法依赖的package包/类
public Content getPublicKey() throws IOException, PGPException {
  PGPSecretKey signKey = readSecretKey();
  PGPPublicKey publicKey = signKey.getPublicKey();
  ByteArrayOutputStream buffer = new ByteArrayOutputStream();
  try (BCPGOutputStream os = new BCPGOutputStream(new ArmoredOutputStream(buffer))) {
    publicKey.encode(os);
  }
  return new Content(new BytesPayload(buffer.toByteArray(), AptMimeTypes.PUBLICKEY));
}
 
开发者ID:sonatype-nexus-community,项目名称:nexus-repository-apt,代码行数:10,代码来源:AptSigningFacet.java


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