Merge "Split PGPEncryptedDataGenerator creation out into a utility method"
This commit is contained in:
@@ -173,17 +173,23 @@ class EncryptedContactStore implements ContactStore {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
private final PGPEncryptedDataGenerator cpk()
|
||||||
|
throws NoSuchProviderException, PGPException {
|
||||||
|
PGPEncryptedDataGenerator cpk =
|
||||||
|
new PGPEncryptedDataGenerator(PGPEncryptedData.CAST5, true, prng, "BC");
|
||||||
|
cpk.addMethod(dest);
|
||||||
|
return cpk;
|
||||||
|
}
|
||||||
|
|
||||||
private byte[] encrypt(final String name, final Date date,
|
private byte[] encrypt(final String name, final Date date,
|
||||||
final byte[] rawText) throws NoSuchProviderException, PGPException,
|
final byte[] rawText) throws NoSuchProviderException, PGPException,
|
||||||
IOException {
|
IOException {
|
||||||
final byte[] zText = compress(name, date, rawText);
|
final byte[] zText = compress(name, date, rawText);
|
||||||
final PGPEncryptedDataGenerator cpk =
|
|
||||||
new PGPEncryptedDataGenerator(PGPEncryptedData.CAST5, true, prng, "BC");
|
|
||||||
cpk.addMethod(dest);
|
|
||||||
|
|
||||||
final ByteArrayOutputStream buf = new ByteArrayOutputStream();
|
final ByteArrayOutputStream buf = new ByteArrayOutputStream();
|
||||||
final ArmoredOutputStream aout = new ArmoredOutputStream(buf);
|
final ArmoredOutputStream aout = new ArmoredOutputStream(buf);
|
||||||
final OutputStream cout = cpk.open(aout, zText.length);
|
final OutputStream cout = cpk().open(aout, zText.length);
|
||||||
cout.write(zText);
|
cout.write(zText);
|
||||||
cout.close();
|
cout.close();
|
||||||
aout.close();
|
aout.close();
|
||||||
|
|||||||
Reference in New Issue
Block a user