C # Excel file encryption, supporting xlsx, docx, pptx (C # \ Net \ Asp. Net ),
From now on, I have closed it! No access is allowed!
A man like a wind has the same character as a wind. The problem arises. When the wind encounters sand, you may not beWind child, I amSha ErOfTangle,. It may be the sky, yellow sand, flying grain stone. If we want to hide the dust of the sky, we must have a strong arm! Then, the Internet, the Internet, and the Internet! Let him close it down honestly,Always cuddling, Ala!
Read at the beginning:
1,Excel file encryption implementation. This article uses Microsoft Office 2007 as an example.
2. Microsoft Office 2007 Office is based on Open XML file (also known as OOXML or OpenXML or MOX ). IsXMLAndZIP CompressionElectronic File specifications, supportedDocuments, tables, memos, slidesFile Format)
3. This article implements C-end Excel encryption and S-end Excel encryption (no server components need to be installed,Say goodbye to all troubles).
4. encryption of this document can be used to encrypt files such as .docx,. xlsx, And. pptx.
So, let's take the sour food!
1. Download our dependent components
Download encryption component
2. Encryption! Starting work! Over!
The project introduces NPOI. POIFS. dll, NPOI. Util. dll, and OfficeOpenXmlCrypto. dll. The detailed implementation code is as follows:
using (OfficeCryptoStream stream = OfficeCryptoStream.Open(@"location"))
{
stream.Password = "password";
stream.Save();
}
Note:
1. Code Description: location: Encrypted File Path, password: encrypted password
2, encryption principle: Based on AES128, encryption key generation method: SHA1, specific encryption technology details see MS-OFFCRYPTO
3. Other encryption technology stacks: EPPlus class library, OpenXml 2.0 SDK. For more information, see explosion network-like encryption qa.
4. If it is deployed on iis, you must enable the 32-Bit mode of the application pool corresponding to the website.
5. Reference Link (all walls, self-built VPN ):
(1), http://www.lyquidity.com/devblog? P = 35
(2), https://msdn.microsoft.com/en-us/library/cc313071.aspx
(3), https://en.wikipedia.org/wiki/Office_Open_XML
(4), https://code.google.com/archive/p/ooxmlcrypto/
By: dolphin Bay-Feng