// This method will demand CryptographicPermissionFlags.Encrypt = true private void ProtectMemory() { if (m_length == 0) { return; } ProtectedMemory.Protect(m_buffer, MemoryProtectionScope.SameProcess); }
private void UnProtectMemory() { if (m_length == 0) { return; } // This is an internal operation so stop the Decrypt Demand new CryptographicPermission(CryptographicPermissionFlags.Decrypt).Assert(); ProtectedMemory.Unprotect(m_buffer, MemoryProtectionScope.SameProcess); }