Free Support Forum - aspose.com

Password not protecting - i tested code- conversion Docx to Doc

Hi Aspose,

I have code which converting from Docx to Doc, which working with password protection, but when i apply Aspose, password protection getting lost, why any one can tell me

i test protectiontype which show only readonly,

why i am sure that aspose loosing , becoz if i dont use aspose code it work.

letter.CreatePackage(stream);

//Docx to Doc Conversion

Aspose.Words.SaveFormat outputFormat = Aspose.Words.SaveFormat.Doc;

Aspose.Words.Document doc = new Aspose.Words.Document(stream);

Aspose.Words.ProtectionType protectionType = doc.ProtectionType;

doc.Save(stream, outputFormat);

// Convert to byte array for saving to database

byte[] byteArray = stream.ToArray();

//Aspose.Words.Document doc1 = new Aspose.Words.Document(stream);

//NUnit.Framework.Assert.AreEqual(protectionType, doc.ProtectionType);

////

// Create Deal Attachment

decimal dealAttachmentId = CreateAttachment(dealId, byteArray, GetFileName(dealId, (int)letterType, dealFacilityId), loginId, dealFacilityId, letterType, true);

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. Could you please attach your input document here for testing? I will check the problem on my side and provide you more information.

Best regards,

Hi Attaching Code and Docx file, which get lost password protection.

please let me know, this thread is already but i did not see attachment

private void button1_Click(object sender, EventArgs e)

{

//Example

FileStream fs = new FileStream(@"C:\ASPOSEpassowrddoc.docx", FileMode.OpenOrCreate, FileAccess.Read);

Byte[] mydata = new Byte[fs.Length]; // This is what is commited to the db.

fs.Read(mydata, 0, (int)fs.Length);

fs.Close();

//Reading the data from the db into a stream.

MemoryStream stream = new MemoryStream();

stream.Write(mydata, 0, mydata.Length);

string extension = string.Empty;

SaveFormat outputFormat = SaveFormat.Doc ;

Aspose.Words.Document doc = new Aspose.Words.Document(stream);

Aspose.Words.ProtectionType protectionType = doc.ProtectionType;

doc.Save(stream, outputFormat);

//Check format

MessageBox.Show(doc.OriginalLoadFormat.ToString());

Aspose.Words.Document doc1 = new Aspose.Words.Document(stream);

MessageBox.Show(doc1.OriginalLoadFormat.ToString());

// Create the new aspose document

byte[] mergedData = stream.ToArray();

stream.Close();

// Now use this data to create a new docx file

MemoryStream newDocumentStream = new MemoryStream();

newDocumentStream.Write(mergedData, 0, mergedData.Length);

newDocumentStream.Seek(0, SeekOrigin.Begin);

using (FileStream fileStream = File.Create(@"c:\output.doc"))

{

int size = 4096;

byte[] buffer = new byte[4096];

while (true)

{

size = newDocumentStream.Read(buffer, 0, buffer.Length);

if (size > 0) fileStream.Write(buffer, 0, size);

else break;

}

fileStream.Close();

}

newDocumentStream.Close();

}

i did not see any attached button here so why i am posting new post, please refer and get code and docx from there, i attached code and Docx file with password

password protection lost while conversion Docx to Doc

Attachment is there name

ASPOSEpassowrddoc.Docx but again i am sending , if you scroll question on top of question you can see this doc file

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for additional information. You are right, protection password is lost. I managed to reproduce the problem on my side. Your request has been linked to the appropriate issue. You will be notified as soon as it is fixed.

Best regards,

Thanks a lot, so what is resolution, and if there is solution from Aspose, when i can expect, because without this feature our task is not going to completed,

are Aspose going to provide this feature ??

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. Unfortunately, I cannot provide you any reliable estimate regarding this issue at the moment. Please expect a reply before next hotfix (within 4-5 weeks). We might just fix the problem or provide you more information.

Best regards,

if you can give me short time solution or patch i ll appricate,

if you could give me some solution , which i can see as proof of concept , and later you can release your patch, but (4-5 week) without this solution is critical for us,

our bussiness team is totally depend on this functionlity, they are just stuck without this feature,

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. Unfortunately, currently, I cannot provide you any workaround of this issue. You should just wait the fix of the original issue. You will be notified as soon as it is fixed.

Best regards,

Hi,


Do Aspose have some progress with this issue? I’ve faced with the same issue using latest aspose component that I’ve downloaded today (02.28.2013).

Thanks,
Alex

Hi Alex,


Thanks for your inquiry.

Our development team has completed the work on the issue (WORDSNET-3109) and has come to a conclusion that this issue and the undesired behaviour you’re observing is actually not a bug in Aspose.Words. So, we’ve closed this issue as ‘Not a Bug’. This is because it is impossible to preserve protection password after converting DOCX to DOC because different hashing algorithms are used. Microsoft Word also does not preserve protection password after converting DOCX to DOC. If we can help you with anything else, please feel free to ask.

Best regards,

Thank you for your reply,


I just checked that password to modify is not lost when I convert from doc -> docx. But I assume it should be lost due “different hashing algorithms are used”.
Could you please clarify this.

Best regards,
Alex Shloma

Hi Alex,


Thanks for your inquiry.

Yes, you are right; it is possible to preserve password during converting DOC to DOCX because DOCX hashis calculated as shown below:

[Original Password] -> [Calculating DOC hash] -> [Performing additional actions on DOC hash to calculate DOCX hash]

So it is possible to get hash code stored in the DOC file and calculate hash code for DOCX document, but it is impossible to perform inverse actions to calculate DOC hash from DOCX hash.

Best regards,

Thank you for clarification.


Best regards,
Alex Shloma