The encryption protects data and allows only authorized people to open the file. So, only those who have an encryption key (such as a password) can open and view a file.
Upload your file. If you are prompted to enter a password to open the file, it is encrypted.
Warning
It’s important to be cautious about uploading sensitive files to online services. For critical files, we recommend using a programmatic method.
Programmatically check for file encryption
Use the GetFileInfo() method that returns the file type and flag that indicates if the file is encrypted. The following code snippet shows how to check if a file is encrypted.
usingSystem;usingGroupDocs.Viewer;usingGroupDocs.Viewer.Results;// ...using(Viewerviewer=newViewer("protected.pdf")){// Get file information.FileInfofileInfo=viewer.GetFileInfo();// Display the file type and flag if the file is encrypted.Console.WriteLine("File type is: "+fileInfo.FileType);Console.WriteLine("File encrypted: "+fileInfo.Encrypted);}
ImportsSystemImportsGroupDocs.ViewerImportsGroupDocs.Viewer.Results' ...
ModuleProgramSubMain(argsAsString())UsingviewerAsViewer=NewViewer("protected.pdf")' Get file information.
DimfileInfoAsFileInfo=viewer.GetFileInfo()' Display the file type and flag if the file is encrypted.
Console.WriteLine("File type is: "&fileInfo.FileType.ToString())Console.WriteLine("File encrypted: "&fileInfo.Encrypted.ToString())EndUsingEndSubEndModule
Tip
Download a sample application written in C# that uses this code snippet. You can run the application locally using the dotnet run command. Ensure you have the .NET SDK installed beforehand.
The following image shows a sample console output: