Package org.bouncycastle.openpgp

Examples of org.bouncycastle.openpgp.PGPCompressedDataGenerator


        final String licensePlain = getLicenseString();
        final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        final OutputStream armoredOutputStream = new ArmoredOutputStream(byteArrayOutputStream);
        final PGPSignatureGenerator signatureGenerator = createPGPSignatureGenerator(keyPassPhraseString.toCharArray());

        final PGPCompressedDataGenerator generator = createZlibCompressedDataGenerator();

        final BCPGOutputStream outputStream = new BCPGOutputStream(generator.open(armoredOutputStream));

        signatureGenerator.generateOnePassVersion(false).encode(outputStream);
        encode(licensePlain, using(signatureGenerator), to(outputStream));
        signatureGenerator.generate().encode(outputStream);
        generator.close();
        armoredOutputStream.close();
        return new String(byteArrayOutputStream.toByteArray());
    }
View Full Code Here


                                                                             setSecureRandom(new SecureRandom()).
                                                                             setProvider("BC"));
        encGen.addMethod(new JcePublicKeyKeyEncryptionMethodGenerator(key));
        OutputStream encOut = encGen.open(outputStream, new byte[BUFFER_SIZE]);

        PGPCompressedDataGenerator comData = new PGPCompressedDataGenerator(CompressionAlgorithmTags.ZIP);
        OutputStream comOut = new BufferedOutputStream(comData.open(encOut));

        PGPSignatureGenerator sigGen = createSignatureGenerator(exchange, comOut);

        PGPLiteralDataGenerator litData = new PGPLiteralDataGenerator();
        String fileName = exchange.getIn().getHeader(Exchange.FILE_NAME, String.class);
View Full Code Here

            out = new ArmoredOutputStream(out);
        }

        ByteArrayOutputStream   bOut = new ByteArrayOutputStream();

        PGPCompressedDataGenerator comData = new PGPCompressedDataGenerator(
                                                        PGPCompressedDataGenerator.ZIP);
        OutputStream cos = comData.open(bOut); // open it with the final destination
        PGPLiteralDataGenerator lData = new PGPLiteralDataGenerator();

        // we want to generate compressed data. This might be a user option later,
        // in which case we would pass in bOut.
        OutputStream  pOut = lData.open(cos, // the compressed output stream
                                        PGPLiteralData.BINARY,
                                        fileName,  // "filename" to store
                                        clearData.length, // length of clear data
                                        new Date()  // current time
                                       );
        pOut.write(clearData);

        lData.close();
        comData.close();

        PGPEncryptedDataGenerator   cPk = new PGPEncryptedDataGenerator(algorithm, new SecureRandom(), "BC");
        cPk.addMethod(passPhrase);
        byte[] bytes = bOut.toByteArray();
        OutputStream cOut = cPk.open(out, bytes.length);
View Full Code Here

TOP

Related Classes of org.bouncycastle.openpgp.PGPCompressedDataGenerator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.