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
Error Found During Encryption/Decryption (Invalid Header Marker)
-
- Posts: 1
- Joined: Thu May 03, 2018 4:26 pm
Re: Error Found During Encryption/Decryption (Invalid Header Marker)
The problem is this line:
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
SharpAESCrypt.SharpAESCrypt.Encrypt(inputstream, outputstream, maxThreadCount);
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;
}