Document.IsEncrypted

IsEncrypted(Stream, LoadOptions, out Document)

Checks whether a document from a stream is encrypted. To check it we need to completely load this document. So this method can lead to performance penalty.

public static bool IsEncrypted(Stream stream, LoadOptions options, out Document document)
ParameterTypeDescription
streamStreamThe stream.
optionsLoadOptionsThe load options.
documentDocument&The loaded document.

Return Value

Returns true if the document is encrypted otherwise false.

Examples

Shows how to check if a document is password-protected.

// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string fileName = Path.Combine(dataDir, "Aspose.one");

Document document;
if (!Document.IsEncrypted(fileName, out document))
{
    Console.WriteLine("The document is loaded and ready to be processed.");
}
else
{
    Console.WriteLine("The document is encrypted. Provide a password.");
}

Shows how to check if a document is password-protected by specific password.

// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string fileName = Path.Combine(dataDir, "Aspose.one");

Document document;
if (Document.IsEncrypted(fileName, "VerySecretPassword", out document))
{
    if (document != null)
    {
        Console.WriteLine("The document is decrypted. It is loaded and ready to be processed.");
    }
    else
    {
        Console.WriteLine("The document is encrypted. Invalid password was provided.");
    }
}
else
{
    Console.WriteLine("The document is NOT encrypted. It is loaded and ready to be processed.");
}

See Also


IsEncrypted(Stream, string, out Document)

Checks whether a document from a stream is encrypted. To check it we need to completely load this document. So this method can lead to performance penalty.

public static bool IsEncrypted(Stream stream, string password, out Document document)
ParameterTypeDescription
streamStreamThe stream.
passwordStringThe password to decrypt a document.
documentDocument&The loaded document.

Return Value

Returns true if the document is encrypted otherwise false.

Examples

Shows how to check if a document is password-protected.

// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string fileName = Path.Combine(dataDir, "Aspose.one");

Document document;
if (!Document.IsEncrypted(fileName, out document))
{
    Console.WriteLine("The document is loaded and ready to be processed.");
}
else
{
    Console.WriteLine("The document is encrypted. Provide a password.");
}

Shows how to check if a document is password-protected by specific password.

// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string fileName = Path.Combine(dataDir, "Aspose.one");

Document document;
if (Document.IsEncrypted(fileName, "VerySecretPassword", out document))
{
    if (document != null)
    {
        Console.WriteLine("The document is decrypted. It is loaded and ready to be processed.");
    }
    else
    {
        Console.WriteLine("The document is encrypted. Invalid password was provided.");
    }
}
else
{
    Console.WriteLine("The document is NOT encrypted. It is loaded and ready to be processed.");
}

See Also


IsEncrypted(Stream, out Document)

Checks whether a document from a stream is encrypted. To check it we need to completely load this document. So this method can lead to performance penalty.

public static bool IsEncrypted(Stream stream, out Document document)
ParameterTypeDescription
streamStreamThe stream.
documentDocument&The loaded document.

Return Value

Returns true if the document is encrypted otherwise false.

Examples

Shows how to check if a document is password-protected.

// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string fileName = Path.Combine(dataDir, "Aspose.one");

Document document;
if (!Document.IsEncrypted(fileName, out document))
{
    Console.WriteLine("The document is loaded and ready to be processed.");
}
else
{
    Console.WriteLine("The document is encrypted. Provide a password.");
}

Shows how to check if a document is password-protected by specific password.

// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string fileName = Path.Combine(dataDir, "Aspose.one");

Document document;
if (Document.IsEncrypted(fileName, "VerySecretPassword", out document))
{
    if (document != null)
    {
        Console.WriteLine("The document is decrypted. It is loaded and ready to be processed.");
    }
    else
    {
        Console.WriteLine("The document is encrypted. Invalid password was provided.");
    }
}
else
{
    Console.WriteLine("The document is NOT encrypted. It is loaded and ready to be processed.");
}

See Also


IsEncrypted(string, LoadOptions, out Document)

Checks whether a document from a file is encrypted. To check it we need to completely load this document. So this method can lead to performance penalty.

public static bool IsEncrypted(string filePath, LoadOptions options, out Document document)
ParameterTypeDescription
filePathStringThe file path.
optionsLoadOptionsThe load options.
documentDocument&The loaded document.

Return Value

Returns true if the document is encrypted otherwise false.

Examples

Shows how to check if a document is password-protected.

// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string fileName = Path.Combine(dataDir, "Aspose.one");

Document document;
if (!Document.IsEncrypted(fileName, out document))
{
    Console.WriteLine("The document is loaded and ready to be processed.");
}
else
{
    Console.WriteLine("The document is encrypted. Provide a password.");
}

Shows how to check if a document is password-protected by specific password.

// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string fileName = Path.Combine(dataDir, "Aspose.one");

Document document;
if (Document.IsEncrypted(fileName, "VerySecretPassword", out document))
{
    if (document != null)
    {
        Console.WriteLine("The document is decrypted. It is loaded and ready to be processed.");
    }
    else
    {
        Console.WriteLine("The document is encrypted. Invalid password was provided.");
    }
}
else
{
    Console.WriteLine("The document is NOT encrypted. It is loaded and ready to be processed.");
}

See Also


IsEncrypted(string, out Document)

Checks whether a document from a file is encrypted. To check it we need to completely load this document. So this method can lead to performance penalty.

public static bool IsEncrypted(string filePath, out Document document)
ParameterTypeDescription
filePathStringThe file path.
documentDocument&The loaded document.

Return Value

Returns true if the document is encrypted otherwise false.

Examples

Shows how to check if a document is password-protected.

// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string fileName = Path.Combine(dataDir, "Aspose.one");

Document document;
if (!Document.IsEncrypted(fileName, out document))
{
    Console.WriteLine("The document is loaded and ready to be processed.");
}
else
{
    Console.WriteLine("The document is encrypted. Provide a password.");
}

Shows how to check if a document is password-protected by specific password.

// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string fileName = Path.Combine(dataDir, "Aspose.one");

Document document;
if (Document.IsEncrypted(fileName, "VerySecretPassword", out document))
{
    if (document != null)
    {
        Console.WriteLine("The document is decrypted. It is loaded and ready to be processed.");
    }
    else
    {
        Console.WriteLine("The document is encrypted. Invalid password was provided.");
    }
}
else
{
    Console.WriteLine("The document is NOT encrypted. It is loaded and ready to be processed.");
}

See Also


IsEncrypted(string, string, out Document)

Checks whether a document from a file is encrypted. To check it we need to completely load this document. So this method can lead to performance penalty.

public static bool IsEncrypted(string filePath, string password, out Document document)
ParameterTypeDescription
filePathStringThe file path.
passwordStringThe password to decrypt a document.
documentDocument&The loaded document.

Return Value

Returns true if the document is encrypted otherwise false.

Examples

Shows how to check if a document is password-protected.

// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string fileName = Path.Combine(dataDir, "Aspose.one");

Document document;
if (!Document.IsEncrypted(fileName, out document))
{
    Console.WriteLine("The document is loaded and ready to be processed.");
}
else
{
    Console.WriteLine("The document is encrypted. Provide a password.");
}

Shows how to check if a document is password-protected by specific password.

// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string fileName = Path.Combine(dataDir, "Aspose.one");

Document document;
if (Document.IsEncrypted(fileName, "VerySecretPassword", out document))
{
    if (document != null)
    {
        Console.WriteLine("The document is decrypted. It is loaded and ready to be processed.");
    }
    else
    {
        Console.WriteLine("The document is encrypted. Invalid password was provided.");
    }
}
else
{
    Console.WriteLine("The document is NOT encrypted. It is loaded and ready to be processed.");
}

See Also