public void CryptoBlob_BasicUsage()
        {
            try
            {
                byte[] bytes = new ByteGenerator().GenerateBytes(10);

                // Create Credentials
                CryptoCredentials credentials = new CryptoCredentials
                {
                    Passphrase = new CryptoString("My Passphrase"),
                    Pin        = 2222
                };

                // Create the Blob object and assign Encrypt some Bytes
                CryptoBlob blob = new CryptoBlob(credentials, bytes);

                // Retrieve the Decrypted Bytes
                byte[] decryptedBytes = blob.Decrypt();

                // Get the Encrypted Data - Perhaps you want to store it in a Database for example
                byte[] encryptedBytes = blob.GetEncryptedBytes();

                // Set the Encrypted Bytes - Perhaps you pulled them from a Database or in another file
                blob.SetEncryptedBytes(encryptedBytes);

                // Validates the Checksum of the blob and throws an exception if the Blob fails the integrity check
                blob.ValidateChecksum();
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
                throw;
            }
        }
        /// <summary>
        /// Loads the File from the FileSystem based on the FileName property
        /// </summary>
        public virtual void Load()
        {
            byte[] bytes;

            if (EncryptFile)
            {
                CryptoCredentials credentials    = GetCredentials();
                byte[]            encryptedBytes = File.ReadAllBytes(FullFileName);
                CryptoBlob        blob           = new CryptoBlob(credentials);
                blob.SetEncryptedBytes(encryptedBytes);
                bytes = blob.Decrypt(true);
            }
            else
            {
                bytes = File.ReadAllBytes(FullFileName);
            }
            LoadFromBytes(bytes);
        }
        public void CryptoBlob_StressTest()
        {
            int iterations = 200;
            int blocksize  = 100;

            byte[] bytes = new ByteGenerator().GenerateBytes(blocksize);


            for (int i = 0; i < iterations; i++)
            {
                try
                {
                    // Create Credentials
                    CryptoCredentials credentials = new CryptoCredentials
                    {
                        Passphrase = new CryptoString("My Passphrase"),
                        Pin        = 2222
                    };

                    // Create the Blob object and assign Encrypt some Bytes
                    CryptoBlob blob = new CryptoBlob(credentials, bytes);

                    // Retrieve the Decrypted Bytes
                    byte[] decryptedBytes = blob.Decrypt();

                    // Get the Encrypted Data - Perhaps you want to store it in a Database for example
                    byte[] encryptedBytes = blob.GetEncryptedBytes();

                    // Set the Encrypted Bytes - Perhaps you pulled them from a Database or in another file
                    blob.SetEncryptedBytes(encryptedBytes);

                    // Validates the Checksum of the blob and throws an exception if the Blob fails the integrity check
                    blob.ValidateChecksum();

                    Assert.IsTrue(decryptedBytes.SequenceEqual(bytes));
                }
                catch (Exception e)
                {
                    Debug.WriteLine(e.Message);
                    throw;
                }
            }
        }
        /// <summary>
        /// Saves the File to the FileSystem based on the FileName. If the EncryptFile property is set then this file will be encrypted with a checksum at the end.
        /// </summary>
        public virtual void Save()
        {
            byte[] bytesToWrite;
            if (EncryptFile)
            {
                byte[]     unencryptedBytes = SaveToBytes();
                CryptoBlob blob             = new CryptoBlob(GetCredentials(), unencryptedBytes);
                bytesToWrite = blob.GetEncryptedBytes();
            }
            else
            {
                bytesToWrite = SaveToBytes();
            }

            using (FileStream fileStream = new FileStream(FullFileName, FileMode.Create))
            {
                fileStream.Write(bytesToWrite, 0, bytesToWrite.Length);
            }
        }
        public void CryptoBlob_AdvancedUsage()
        {
            try
            {
                //byte[] bytes = new ByteGenerator().GenerateBytes(10);
                byte[] bytes = new byte[] { 0x00, 0x00 };

                // Create Credentials
                CryptoCredentials credentials = new CryptoCredentials
                {
                    Passphrase = new CryptoString("My Passphrase"),
                    Pin        = 2222
                };

                CryptoBlob blob           = new CryptoBlob(credentials, bytes);
                byte[]     encryptedBytes = blob.GetEncryptedBytes();
                blob.SetEncryptedBytes(encryptedBytes);
                byte[] decryptedBytes = blob.Decrypt(true);


                CryptoBlob blob2           = new CryptoBlob(credentials, decryptedBytes);
                byte[]     encryptedBytes2 = blob2.GetEncryptedBytes();
                byte[]     decryptedBytes2 = blob.Decrypt(true);

                bool diff = encryptedBytes.SequenceEqual(encryptedBytes2);


                //byte[] decryptedBytes = blob.Decrypt();
                //byte[] encryptedBytes = blob.GetEncryptedBytes();
                //blob.SetEncryptedBytes(encryptedBytes);

                // Validates the Checksum of the blob and throws an exception if the Blob fails the integrity check
                blob.ValidateChecksum();
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
                throw;
            }
        }