Encrypt file

Some presentations aren’t intended for public viewing and it makes sense to keep them that way. If your PowerPoint contains sensitive information or if its slides are intended for only a select audience, you may want to encrypt it with a password to keep it safe from prying eyes and prevent viewers from copying its contents.

By password protecting your presentation, you get to ensure that only authorized users (who know the password) get to open or modify the file. In this article, we will show you how to encrypt a PowerPoint in Python to enforce certain restrictions.

Python API to Encrypt and Decrypt PPT

To perform encryption and decryption tasks on a PowerPoint presentation, you need to get an API suitable for the job first.

Aspose.Slides for Python is a powerful API that enables developers and applications to create, read, edit, convert, and manipulate PowerPoint presentations (without Microsoft PowerPoint or Office).

To install Aspose.Slides for Python, go through the steps in this Installation guide.

Encrypt PowerPoint PPT with Password in Python

You can encrypt a PowerPoint presentation with a password to prevent people (who do not know the password) from opening and viewing it contents. This form of protection is generally used for presentations that contain sensitive information.

  1. Create an instance of the Presentation class and load the presentation you want to encrypt.
  2. Call the Encrypt method and pass your preferred password.
  3. Save the modified presentation.

Set Write Protection to Discourage Modification

If you want to dissuade users from making changes to the presentation, you can add a mark with the “Do not modify” message to the presentation. This form of write protection may come in handy in a situation where

  • you want to inform people you have provided the final copy of a presentation
  • do not want people to make changes to the presentation because they might break something in it.
  1. Create an instance of the Presentation class and load the presentation you want to encrypt.
  2. Call the SetWriteProtection method and pass your preferred password.
  3. Save the modified presentation.

In this case, a user (who wants to) will be able to modify the presentation and save it with a different name.

Decrypt PowerPoint PPT in Python

If you know the password to an encrypted PowerPoint presentation, you can use the password to decrypt the presentation and then work with it the same way you do with normal presentations.

  1. Create an instance of the LoadOptions class and pass the password for the presentation.
  2. Create an instance of the Presentation class and load the presentation you want to decrypt.
  3. Work with the presentation.

Remove Encryption to Disable Password Protection

To allow other users to open or access or modify the contents of a PowerPoint presentation (without restrictions), you can get rid of the password protection enforced on the presentation. In this case, too, you have to provide the password used to encrypt the presentation.

  1. Create an instance of the LoadOptions class and pass the password for the presentation.
  2. Create an instance of the Presentation class and load the presentation whose protection you want to remove.
  3. Call the RemoveEncryption method.
  4. Save the modified presentation.

Get a Free License

If you are looking to try Aspose.Slides features without limitations, we recommend you get a free temporary license.

Conclusion

At this point, you should be familiar with encryption and decryption operations on PowerPoint presentations in Python. To learn how to perform other protection or security-related tasks, see the Password Protected Presentation article in our documentation.

To learn more about Aspose.Slides features, see our documentation. If you have questions, you can post them on our forum.