Add MessageInspector.determineEncryptionInfo(String)

This commit is contained in:
Paul Schaub 2021-10-27 15:54:34 +02:00
parent abdc5c8fdd
commit aed06fc832
Signed by: vanitasvitae
GPG Key ID: 62BEE9264BF17311
1 changed files with 13 additions and 0 deletions

View File

@ -4,6 +4,7 @@
package org.pgpainless.decryption_verification;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
@ -69,6 +70,18 @@ public final class MessageInspector {
}
/**
* Parses parts of the provided OpenPGP message in order to determine which keys were used to encrypt it.
*
* @param message OpenPGP message
* @return encryption info
* @throws PGPException
* @throws IOException
*/
public static EncryptionInfo determineEncryptionInfoForMessage(String message) throws PGPException, IOException {
return determineEncryptionInfoForMessage(new ByteArrayInputStream(message.getBytes("UTF-8")));
}
/**
* Parses parts of the provided OpenPGP message in order to determine which keys were used to encrypt it.
* Note: This method does not rewind the passed in Stream, so you might need to take care of that yourselves.