|
1 | 1 | package org.bouncycastle.openpgp.examples;
|
2 | 2 |
|
| 3 | +import java.io.BufferedInputStream; |
| 4 | +import java.io.BufferedOutputStream; |
| 5 | +import java.io.File; |
| 6 | +import java.io.FileInputStream; |
| 7 | +import java.io.FileOutputStream; |
| 8 | +import java.io.IOException; |
| 9 | +import java.io.InputStream; |
| 10 | +import java.io.OutputStream; |
| 11 | +import java.security.SecureRandom; |
| 12 | +import java.security.Security; |
| 13 | + |
3 | 14 | import org.bouncycastle.bcpg.ArmoredOutputStream;
|
4 | 15 | import org.bouncycastle.bcpg.CompressionAlgorithmTags;
|
5 | 16 | import org.bouncycastle.bcpg.SymmetricKeyAlgorithmTags;
|
|
20 | 31 | import org.bouncycastle.openpgp.operator.jcajce.JcePGPDataEncryptorBuilder;
|
21 | 32 | import org.bouncycastle.util.io.Streams;
|
22 | 33 |
|
23 |
| -import java.io.BufferedInputStream; |
24 |
| -import java.io.BufferedOutputStream; |
25 |
| -import java.io.File; |
26 |
| -import java.io.FileInputStream; |
27 |
| -import java.io.FileOutputStream; |
28 |
| -import java.io.IOException; |
29 |
| -import java.io.InputStream; |
30 |
| -import java.io.OutputStream; |
31 |
| -import java.security.SecureRandom; |
32 |
| -import java.security.Security; |
33 |
| - |
34 | 34 | /**
|
35 | 35 | * A simple utility class that encrypts/decrypts password based
|
36 | 36 | * encryption files.
|
@@ -155,8 +155,8 @@ private static void encryptToStream(
|
155 | 155 | // Encryption
|
156 | 156 | PGPDataEncryptorBuilder dataEncBuilder = new JcePGPDataEncryptorBuilder(SymmetricKeyAlgorithmTags.AES_256)
|
157 | 157 | .setProvider("BC")
|
158 |
| - .setWithIntegrityPacket(true) |
159 |
| - .setSecureRandom(new SecureRandom()); |
| 158 | + .setSecureRandom(new SecureRandom()) |
| 159 | + .setWithIntegrityPacket(true); |
160 | 160 | PGPEncryptedDataGenerator encGen = new PGPEncryptedDataGenerator(dataEncBuilder);
|
161 | 161 | encGen.addMethod(new JcePBEKeyEncryptionMethodGenerator(passPhrase).setProvider("BC"));
|
162 | 162 | OutputStream encOut = encGen.open(out, new byte[8192]);
|
|
0 commit comments