GPG encryption/decryption issue failing with Invalid header encountered

I want to encrypt and decrypt the Java JSON rest request using GPG but its not working. Getting Invalid header Encountered during decrypt method.
I am using below dependency in my Spring boot 2.3 project with Java 1.8

       <dependency>
            <groupId>org.bouncycastle</groupId>
            <artifactId>bcpg-jdk18on</artifactId>
            <version>1.78.1</version>
        </dependency>           
        <dependency>
            <groupId>org.bouncycastle</groupId>
            <artifactId>bcprov-jdk18on</artifactId>
            <version>1.78.1</version>
        </dependency>

Below is my encrypted data.

Encrypted Data is-----BEGIN PGP MESSAGE-----
Version: BCPG v@RELEASE_NAME@

wcFMAyRgUyQUFpOMAQ//VVtzEGltqEo90Fpmk/lq0KyjGu4bSu9Rp9qhK1cyLX1d
vyMrPreLfTBzbL37KKcGWF1lqc9StlRaqCUQW/vjEjpN0Nnxhm9vYrq3+zChF2qB
yKKAb0bc1uoWitxNROEkcQeKm6oWbGJ+WwG/MIFsg90RTer89Rtg0zJ5/CoAlNcg
yHNdAzlSmT2s36I6a4ctuO+VYKT+uNIXCnsHfW5kKZkD6Ypai7guu4lKu613gLnO
g7dFA7U9RzFiXxg7YJMwulA2imlx1etqQkzxuQPNj6BPXHW8g/1brG1XAXAhW3qO
zIzQZUia4VNVOhKXIC2rQtO+wYzXL9dif2iQ3vQ/QZkCYvhAwi9ktx/XPrSmreao
h9ZOCCgS4dTTKjcz7vTaTV3+mvL2H+DrkgmoGJB/NzF9jbOGvSsO5HlSmrpxLSr7
WDGrfxaNiSIxSbuyI2DHboZWtWVDXjAV87Ba9mbG0+sSBKkAGYTl40WAz+OXhoie
DoItm3IhPddPyasHR8kX578tla2nzKGfJo2UXjJs0wf6Z7LeidAw7hV9OvcuZavq
PLpmj77RpjlE6uIWSt5k8OjfkHAc9/DWTYBYMnf2hvYoTTBMBbkzzFZJ1Fp/U0g8
XcTOWfxOXZ8xnoj+TPg4bXxvCf9hlLYPEVWCXp/r/E6Z6LQpMG6h1UGax3l5ZQ7S
SgEO0c/HvANEFk0g8u+rHMtC/snSi07O8zaj/6KE68+dJRO6iUkEbrjQH6wQS6fT
qunDOc8kwCY3fHCiWGpvP3M0gAPLpr1DaHvd
=XZXh
-----END PGP MESSAGE-----

and during decryption its giving error as

java.io.IOException: invalid header encountered
at org.bouncycastle.bcpg.BCPGInputStream.readPacket(Unknown Source)
at org.bouncycastle.openpgp.PGPCompressedData.<init>(Unknown Source)

here my complete code for this task,

public class EncryptionDecryptionUtils {
static {
    Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
}

public static byte[] encrypt(String plaintext, PGPPublicKey publicKey) throws IOException, PGPException {
    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    try (OutputStream armoredOutputStream = new ArmoredOutputStream(byteArrayOutputStream)) {
        PGPEncryptedDataGenerator encryptedDataGenerator = new PGPEncryptedDataGenerator(
            new JcePGPDataEncryptorBuilder(PGPEncryptedData.AES_256)
                .setWithIntegrityPacket(true)
                .setSecureRandom(new SecureRandom())
                .setProvider("BC"));
        encryptedDataGenerator.addMethod(new JcePublicKeyKeyEncryptionMethodGenerator(publicKey)
            .setProvider("BC"));
        try (OutputStream outputStream = encryptedDataGenerator.open(armoredOutputStream, new byte[4096])) {
            outputStream.write(plaintext.getBytes());
        }
    }
    return byteArrayOutputStream.toByteArray();

}

public static String decrypt(byte[] encryptedData, InputStream privateKeyInputStream, char[] passphrase)
    throws IOException, PGPException, NoSuchProviderException {
    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(encryptedData);
    try (InputStream armoredInputStream = new ArmoredInputStream(byteArrayInputStream)) {
        PGPObjectFactory pgpObjectFactory = new PGPObjectFactory(armoredInputStream,
            new JcaKeyFingerprintCalculator());
        Object pgpObject = pgpObjectFactory.nextObject();
        if (pgpObject instanceof PGPEncryptedDataList) {
            PGPEncryptedDataList encryptedDataList = (PGPEncryptedDataList) pgpObject;
            PGPSecretKeyRingCollection secretKeyRingCollection = new PGPSecretKeyRingCollection(
                PGPUtil.getDecoderStream(privateKeyInputStream), new JcaKeyFingerprintCalculator());
            PGPPublicKeyEncryptedData encryptedDataObject = null;
            PGPSecretKey secretKey = null;
            for (int i = 0; i < encryptedDataList.size() && encryptedDataObject == null; i++) {
                encryptedDataObject = (PGPPublicKeyEncryptedData) encryptedDataList.get(i);
                secretKey = secretKeyRingCollection.getSecretKey(encryptedDataObject.getKeyID());
                if (secretKey != null) {
                    break;
                }
            }
            if (secretKey == null) {
                throw new PGPException("No secret key found for decryption.");
            }
            InputStream decryptedStream = encryptedDataObject.getDataStream(
                new JcePublicKeyDataDecryptorFactoryBuilder().setProvider("BC")
                    .build(secretKey.extractPrivateKey(
                        new JcePBESecretKeyDecryptorBuilder().setProvider("BC").build(passphrase))));
            pgpObjectFactory = new PGPObjectFactory(decryptedStream, new JcaKeyFingerprintCalculator());
            pgpObject = pgpObjectFactory.nextObject();

            if (pgpObject instanceof PGPCompressedData) {
                PGPCompressedData compressedData = (PGPCompressedData) pgpObject;
                pgpObjectFactory = new PGPObjectFactory(compressedData.getDataStream(),
                    new JcaKeyFingerprintCalculator());
                pgpObject = pgpObjectFactory.nextObject();
            }
            if (pgpObject instanceof PGPLiteralData) {
                PGPLiteralData literalData = (PGPLiteralData) pgpObject;
                InputStream literalDataStream = literalData.getInputStream();
                StringBuilder plaintext = new StringBuilder();
                byte[] buffer = new byte[4096];
                int bytesRead;
                while ((bytesRead = literalDataStream.read(buffer)) != -1) {
                    plaintext.append(new String(buffer, 0, bytesRead));
                }
                return plaintext.toString();
            } else {
                throw new PGPException("Message is not a simple encrypted file - type unknown.");
            }
        } else {
            throw new PGPException("Expected PGPEncryptedDataList, found " + pgpObject.getClass().getName());
        }
    }

}

private static PGPPublicKey getPublicKey(InputStream publicKeyInputStream) throws IOException, PGPException {
    PGPPublicKeyRingCollection pgpPublicKeyRingCollection = new PGPPublicKeyRingCollection(
        PGPUtil.getDecoderStream(publicKeyInputStream), new JcaKeyFingerprintCalculator());
    Iterator<PGPPublicKeyRing> keyRingIterator = pgpPublicKeyRingCollection.getKeyRings();
    while (keyRingIterator.hasNext()) {
        PGPPublicKeyRing keyRing = keyRingIterator.next();
        Iterator<PGPPublicKey> publicKeyIterator = keyRing.getPublicKeys();
        while (publicKeyIterator.hasNext()) {
            PGPPublicKey publicKey = publicKeyIterator.next();
            if (publicKey.isEncryptionKey()) {
                return publicKey;
            }
        }
    }
    throw new IllegalArgumentException("No encryption key found in the public key ring.");

}

public static void main(String args[]) {

    try {
        String publicKeyPath = "C:/Users/rest/src/main/resources/keys/dev/publicKey.asc";
        String privateKeyPath = "C:/Users/rest/src/main/resources/keys/dev/privateKey.asc";
        InputStream publicKeyStream = new FileInputStream(publicKeyPath);
        InputStream privateKeyStream = new FileInputStream(privateKeyPath);
        String testdata = "Hello man encrypt it then decrypt";
        PGPPublicKey publicKey = getPublicKey(publicKeyStream);
        byte[] encryptedData = encrypt(testdata, publicKey);
        System.out.println("Encrypted Data is" + new String(encryptedData, StandardCharsets.UTF_8));
        String decrypt = decrypt(encryptedData, privateKeyStream, "May@2024".toCharArray());
        System.out.println("Decrypted Data is" + decrypt);
    } catch (Exception e) {
        System.out.println("Exception is " + e.getMessage());
    }
}
}

Can any one please let me know what can be issue, instead of JSONObject i tried with simple string but its still failing.
Any suggestion must be apprecaited.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật