C # encrypt, decrypt, and reset the password of the PPT document,

Source: Internet
Author: User
Tags password protection

C # encrypt, decrypt, and reset the password of the PPT document,

In our work, we will use a variety of documents, among which PPT plays an indispensable role. A ppt document may contain important business plans, Enterprise Operation materials, or company management materials. Therefore, in a competitive environment, confidentiality of important enterprise data is particularly important. For important data, we can choose to add a password for document protection. This article describes how to use C # To add a password to the PPT. You can also change or remove the password as needed. The three methods are described below.

Tools used: Spire. Presentation for. NET

Visual Studio 2013

Tool instructions: Spire. presentation. NET supports generation, writing, modification, conversion, and PPT printing. Here, I use the free version, which needs to be downloaded and installed before use, after adding the referenced dll file to the Assembly, you must also add the using command.

1.Add Password

1 using Spire. presentation; 2 3 namespace Security_PPT 4 {5 class Program 6 {7 static void Main (string [] args) 8 {9 // create a Presentation class instance, load the file 10 Presentation presentation = new Presentation (); 11 presentation. loadFromFile (@ "C: \ Users \ Administrator \ Desktop \ test.pptx"); 12 // encrypt the file, set the password, and save the file 13 presentation. encrypt ("test"); 14 presentation. saveToFile ("encrypt.pptx", FileFormat. pptx2007); 15} 16} 17}

Debug and run the project to generate a file, as shown in figure

 

To open the file, you need to embed the password. Enter the correct password to open the file.

 

2.Reset Password

1 using Spire. presentation; 2 3 namespace ResetPassword_PPT 4 {5 class Program 6 {7 static void Main (string [] args) 8 {9 // create a Presentation class instance and load the encrypted document 10 Presentation presentation = new Presentation (); 11 presentation. loadFromFile (@ "C: \ Users \ Administrator \ Desktop \ encrypt.pptx", FileFormat. pptx2010, "test"); 12 13 // remove the original password and add the new password 14 presentation. removeEncryption (); 15 presentation. protect ("newtest"); 16 17 // save document 18 presentation. saveToFile ("newresult.pptx", FileFormat. pptx2010); 19 20} 21} 22}

Similarly, debug and run the program to generate a file.

 

Enter the new password. You can modify the password or view the file in read-only mode.

3.Unbind Password

In the password change method described above, if you only want to remove the password without setting a new password, you only need to delete the new password, that is, presentation. the line of Protect ("newtest") Code, after debugging and running, the generated document will not have password protection.

 

The preceding operations encrypt, decrypt, and reset the password of the PPT document. If it is useful to you, you are welcome to repost it (for reprinting, please indicate the source ).

Thank you for browsing!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.