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


Java CompressionAlgorithmTags.UNCOMPRESSED属性代码示例

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


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

示例1: PGPCompressedDataGenerator

public PGPCompressedDataGenerator(
    int                    algorithm,
    int                    compression)
{
    switch (algorithm)
    {
        case CompressionAlgorithmTags.UNCOMPRESSED:
        case CompressionAlgorithmTags.ZIP:
        case CompressionAlgorithmTags.ZLIB:
        case CompressionAlgorithmTags.BZIP2:
            break;
        default:
            throw new IllegalArgumentException("unknown compression algorithm");
    }

    if (compression != Deflater.DEFAULT_COMPRESSION)
    {
        if ((compression < Deflater.NO_COMPRESSION) || (compression > Deflater.BEST_COMPRESSION))
        {
            throw new IllegalArgumentException("unknown compression level: " + compression);
        }
    }

    this.algorithm = algorithm;
    this.compression = compression;
}
 
开发者ID:NoYouShutup,项目名称:CryptMeme,代码行数:26,代码来源:PGPCompressedDataGenerator.java

示例2: doOpen

private void doOpen() throws IOException
{
    pkOut.write(algorithm);

    switch (algorithm)
    {
        case CompressionAlgorithmTags.UNCOMPRESSED:
            dOut = pkOut;
            break;
        case CompressionAlgorithmTags.ZIP:
            dOut = new SafeDeflaterOutputStream(pkOut, compression, true);
            break;
        case CompressionAlgorithmTags.ZLIB:
            dOut = new SafeDeflaterOutputStream(pkOut, compression, false);
            break;
        case CompressionAlgorithmTags.BZIP2:
            dOut = new SafeCBZip2OutputStream(pkOut);
            break;
        default:
            // Constructor should guard against this possibility
            throw new IllegalStateException();
    }
}
 
开发者ID:NoYouShutup,项目名称:CryptMeme,代码行数:23,代码来源:PGPCompressedDataGenerator.java

示例3: encrypt

public static byte[] encrypt(
        final byte[] secret,
        final PGPPublicKey... keys)
        throws CryptographyException {
    final ByteArrayOutputStream out;
    try (ByteArrayInputStream in = new ByteArrayInputStream(secret);
        ByteArrayOutputStream bOut = new ByteArrayOutputStream()) {
        final PGPLiteralDataGenerator literal = new PGPLiteralDataGenerator();
        final PGPCompressedDataGenerator comData = new PGPCompressedDataGenerator(CompressionAlgorithmTags.UNCOMPRESSED);
        final OutputStream pOut = literal.open(
                comData.open(bOut),
                PGPLiteralData.BINARY,
                "filename",
                in.available(),
                new Date());
        Streams.pipeAll(in, pOut);
        comData.close();
        final byte[] bytes = bOut.toByteArray();
        final PGPEncryptedDataGenerator generator = new PGPEncryptedDataGenerator(
                new JcePGPDataEncryptorBuilder(PGPEncryptedData.CAST5)
                        .setWithIntegrityPacket(true)
                        .setSecureRandom(new SecureRandom())
                    .setProvider(PROVIDER));
        for (final PGPPublicKey key : keys) {
            generator.addMethod(new JcePublicKeyKeyEncryptionMethodGenerator(key).setProvider(PROVIDER));
        }
        out = new ByteArrayOutputStream();
        final ArmoredOutputStream armor = new ArmoredOutputStream(out);
        final OutputStream cOut = generator.open(armor, bytes.length);
        cOut.write(bytes);
        cOut.close();
        armor.close();
    } catch (IOException | PGPException e) {
        throw new CryptographyException("Failed to encrypt.", e);
    }
    return out.toByteArray();
}
 
开发者ID:iZettle,项目名称:izettle-toolbox,代码行数:37,代码来源:PGP.java


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