static void csCrypt() { string sKey; sKey = Key.create64Key(); // Pinned memory for later secure removal GCHandle gch = GCHandle.Alloc(sKey, GCHandleType.Pinned); //Encrypt file. EncryptFile(@"C:\Data.txt", @"C:\Encrypted.txt", sKey); fileFunc.AddEncryption(@"C:\Encrypted.txt"); //Decrypt file. DecryptFile(@"C:\Encrypted.txt", @"C:\Decrypted.txt", sKey) fileFunc.RemoveEncryption(@"C:\Decrypted.txt") ZeroMemory(gch.AddOfPinnedObject(), sKey.Length * 2) gch.Free(); }