Verify Password of Encrypted Files
Contents
[
Hide
]
If Excel (xlsx, xlsb, xls, xlsm) and Open office (ODS) files are locked with password, Aspose.Cells for Java supports simple password verification without parsing specific data of the files.
Verify the password of the encrypted file
To verify the password of the encrypted file, Aspose.Cells for Java provides the VerifyPassword method. The methods accepts two parameters, the file stream and the password that needs to be verified. The following code snippet demonstrates the use of the VerifyPassword method to verify whether the provided password is valid or not.
Sample Code:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getSharedDataDir(VerifyPassword.class) + "LoadingSavingConvertingAndManaging/"; | |
// Create a Stream object | |
FileInputStream fstream = new FileInputStream(dataDir + "EncryptedBook1.xlsx"); | |
boolean isPasswordValid = FileFormatUtil.verifyPassword(fstream, "1234"); | |
System.out.println("Password is Valid: " + isPasswordValid); |