暗号化されたファイルのパスワードをNode.js経由のC++で検証する
Contents
[
Hide
]
Excel(xlsx、xlsb、xls、xlsm)とOpen Office(ODS)ファイルがパスワードでロックされている場合、Asposeはファイルの特定のデータを解析せずに簡単なパスワード検証をサポートします。
暗号化されたファイルのパスワードを確認します
暗号化されたファイルのパスワードを検証するには、Aspose.Cells for Node.js via C++はFileFormatUtil.verifyPassword(Uint8Array, string)メソッドを提供します。このメソッドは2つのパラメータを受け取ります:ファイルストリームと検証するパスワード。
以下のコードスニペットは、提供されたパスワードが有効かどうかを確認するFileFormatUtil.verifyPassword(Uint8Array, string)メソッドの使用を示しています。
const path = require("path");
const AsposeCells = require("aspose.cells.node");
// The path to the documents directory.
const dataDir = path.join(__dirname, "data");
const filePath = path.join(dataDir, "EncryptedBook1.xlsx");
// Create a Stream object
const fs = require("fs");
const fstream = fs.readFileSync(filePath);
const isPasswordValid = AsposeCells.FileFormatUtil.verifyPassword(fstream, "1234");
console.log("Password is Valid: " + isPasswordValid);