Error Found During Encryption/Decryption (Invalid Header Marker)

Discussion related to AES Crypt, the file encryption software for Windows, Linux, Mac, and Java.
Post Reply
NirajKumar
Posts: 1
Joined: Thu May 03, 2018 4:26 pm

Error Found During Encryption/Decryption (Invalid Header Marker)

Post by NirajKumar » Thu May 03, 2018 4:28 pm

Hi,

I am using the "AES Crypt" in my Application to Encrypt the PDF and Mysql Database Files Like "FRM, MYD and MYI" Files.

My Application is Windows based and application is developed in C# Environment.
During running the Application I found that, Encrypted Files could not Decrypt due to "Invalid Header Marker/File Length is Invalid". When I opened the Encrypted Files in Edit Mode. The Files are blank or it contains some junk Character"

I am using the same Code, which is available on Internet and my Program is given below

public static bool Encrypt_only_pdf(string Decrypted_file, string Encrypted_file)

{

bool retVal = true;

ParallelOptions po = new ParallelOptions();

po.MaxDegreeOfParallelism = maxThreadCount;

try

{

using (Stream inputstream = (Decrypted_file != null) ? File.OpenRead(Decrypted_file) : Console.OpenStandardInput())

{

using (Stream outputstream = (Encrypted_file != null) ? File.Create(Encrypted_file) : Console.OpenStandardOutput())

{

SharpAESCrypt.SharpAESCrypt.Encrypt(inputstream, outputstream, maxThreads);

}

}

}

catch (Exception ex)

{

if (ex is SharpAESCrypt.SharpAESCrypt.WrongPasswordException)

Environment.ExitCode = 4;

if (ex is SharpAESCrypt.SharpAESCrypt.HashMismatchException)

Environment.ExitCode = 3;

else

Environment.ExitCode = 1;

retVal = false;

}

return retVal;

}

I am also sharing the Files where I am facing the Problem.
where in *.dpe file is Encrypted file and ot

kenkendk
Posts: 5
Joined: Tue Jan 03, 2012 11:04 am

Re: Error Found During Encryption/Decryption (Invalid Header Marker)

Post by kenkendk » Fri May 04, 2018 7:23 am

The problem is this line:

Code: Select all

SharpAESCrypt.SharpAESCrypt.Encrypt(inputstream, outputstream, maxThreadCount);
Not sure what you want, but somewhere you need to supply the passphrase, which is not present in your code.
I guess you can change your code to include a passphrase argument like this:

Code: Select all

public static bool Encrypt_only_pdf(string passphrase, string Decrypted_file, string Encrypted_file)
{
    bool retVal = true;
    ParallelOptions po = new ParallelOptions();
    po.MaxDegreeOfParallelism = maxThreadCount;

    try
    {
        using (Stream inputstream = (Decrypted_file != null) ? File.OpenRead(Decrypted_file) : Console.OpenStandardInput())
            using (Stream outputstream = (Encrypted_file != null) ? File.Create(Encrypted_file) : Console.OpenStandardOutput())
                SharpAESCrypt.SharpAESCrypt.Encrypt(passphrase, inputstream, outputstream, maxThreadCount);
    }
    catch (Exception ex)
    {
        if (ex is SharpAESCrypt.SharpAESCrypt.WrongPasswordException)
            Environment.ExitCode = 4;

        if (ex is SharpAESCrypt.SharpAESCrypt.HashMismatchException)
            Environment.ExitCode = 3;
        else
            Environment.ExitCode = 1;

        retVal = false;
    }

    return retVal;
}

Post Reply

Return to “AES Crypt”