暗号化されたファイルのパスワードを確認する
Contents
[
Hide
]
Excel(xlsx、xlsb、xls、xlsm)およびOpenOffice(ODS)ファイルがパスワードでロックされている場合、Aspose.Cells for Javaはファイルの特定のデータを解析せずに簡単なパスワード検証をサポートしています。
暗号化されたファイルのパスワードを確認します
暗号化されたファイルのパスワードを確認するために、Aspose.Cells for JavaはVerifyPasswordメソッドを提供します。これにより、ファイルストリームと確認するパスワードの2つのパラメータを受け入れます。 以下のコードスニペットは、提供されたパスワードが有効かどうかを確認するVerifyPasswordメソッドの使用を示しています。
サンプルコード:
This file contains hidden or 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); |