From aed06fc83205e3b3d8db9707d8b0af85e74b56f8 Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Wed, 27 Oct 2021 15:54:34 +0200 Subject: [PATCH] Add MessageInspector.determineEncryptionInfo(String) --- .../decryption_verification/MessageInspector.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pgpainless-core/src/main/java/org/pgpainless/decryption_verification/MessageInspector.java b/pgpainless-core/src/main/java/org/pgpainless/decryption_verification/MessageInspector.java index e8b04afb..5883163a 100644 --- a/pgpainless-core/src/main/java/org/pgpainless/decryption_verification/MessageInspector.java +++ b/pgpainless-core/src/main/java/org/pgpainless/decryption_verification/MessageInspector.java @@ -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.