Class SymmetricEncryptorDecryptor
- java.lang.Object
-
- org.pgpainless.symmetric_encryption.SymmetricEncryptorDecryptor
-
public class SymmetricEncryptorDecryptor extends java.lang.Object
Stolen from Bouncycastle examples.
-
-
Constructor Summary
Constructors Constructor Description SymmetricEncryptorDecryptor()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static byte[]
symmetricallyDecrypt(byte[] data, Passphrase password)
Decrypt and decompress some symmetrically encrypted data using a password.static byte[]
symmetricallyEncrypt(byte[] data, Passphrase password, SymmetricKeyAlgorithm encryptionAlgorithm, CompressionAlgorithm compressionAlgorithm)
Encrypt somedata
symmetrically using anencryptionAlgorithm
and a givenpassword
.
-
-
-
Method Detail
-
symmetricallyEncrypt
public static byte[] symmetricallyEncrypt(@Nonnull byte[] data, @Nonnull Passphrase password, @Nonnull SymmetricKeyAlgorithm encryptionAlgorithm, @Nonnull CompressionAlgorithm compressionAlgorithm) throws java.io.IOException, org.bouncycastle.openpgp.PGPException
Encrypt somedata
symmetrically using anencryptionAlgorithm
and a givenpassword
. The input data will be compressed using the givencompressionAlgorithm
and packed in a modification detection package, which is then encrypted.- Parameters:
data
- bytes that will be encryptedpassword
- password that will be used to encrypt the dataencryptionAlgorithm
- symmetric algorithm that will be used to encrypt the datacompressionAlgorithm
- compression algorithm that will be used to compress the data- Returns:
- encrypted data
- Throws:
java.io.IOException
- IO is dangerousorg.bouncycastle.openpgp.PGPException
- OpenPGP is brittle
-
symmetricallyDecrypt
public static byte[] symmetricallyDecrypt(@Nonnull byte[] data, @Nonnull Passphrase password) throws java.io.IOException, org.bouncycastle.openpgp.PGPException
Decrypt and decompress some symmetrically encrypted data using a password. Note, that decryption will fail if the given data is not integrity protected with a modification detection package.- Parameters:
data
- encrypted datapassword
- password to decrypt the data- Returns:
- decrypted data
- Throws:
java.io.IOException
- IO is dangerousorg.bouncycastle.openpgp.PGPException
- OpenPGP is brittle
-
-