Nevron Open Vision Documentation
Framework / Cryptography / Cryptography Overview
In This Topic
    Cryptography Overview
    In This Topic

    Portable Class Libraries doesn't include any encryption algorithms or APIs, but Nevron Open Vision solves this issue by implementing the PK ZIP Classic encryption algorithm. This is the algorithm used when creating password protected zip archives. You can use it to encrypt any data via the EncryptPkzipClassic and DecryptPkzipClassic static methods of the NCryptography static class.

    The example below demonstrates how to encrypt a string with a password and how to decrypt it using the PK ZIP Classic algorithm:

    Encrypt and decrypt text to bytes
    Copy Code
    string textToEncrypt = "This is some text to encrypt.";
    string password = "password";
    
    // Encrypt the text
    byte[] encryptedBytes = NCryptography.EncryptPkzipClassic(NEncoding.UTF8.GetBytes(textToEncrypt), password);
    
    // Decrypt the encrypted bytes
    string decryptedText = NEncoding.UTF8.GetString(NCryptography.DecryptPkzipClassic(encryptedBytes, password));
    

    If you need a text representation of the encrypted bytes, you can use the method overloads that accept string arguments as shown in the following example:

    Encrypt and decrypt text to string
    Copy Code
    string textToEncrypt = "This is some text to encrypt.";
    string password = "password";
    
    // Encrypt the text
    string encryptedText = NCryptography.EncryptPkzipClassic(textToEncrypt, password);
    
    // Decrypt the encrypted text
    string decryptedText = NCryptography.DecryptPkzipClassic(encryptedBytes, password);