private string DecryptText(string encText) { DATA_BLOB data_blob; DATA_BLOB data_blob2; DATA_BLOB data_blob3; string str; if ((encText == null) || (encText.Length < 1)) { return encText; } SafeNativeMemoryHandle handle = new SafeNativeMemoryHandle(); SafeNativeMemoryHandle handle2 = new SafeNativeMemoryHandle(true); SafeNativeMemoryHandle handle3 = new SafeNativeMemoryHandle(); data_blob.pbData = data_blob2.pbData = data_blob3.pbData = IntPtr.Zero; data_blob.cbData = data_blob2.cbData = data_blob3.cbData = 0; try { RuntimeHelpers.PrepareConstrainedRegions(); try { } finally { data_blob = PrepareDataBlob(Convert.FromBase64String(encText)); handle.SetDataHandle(data_blob.pbData); data_blob2 = PrepareDataBlob(this._KeyEntropy); handle3.SetDataHandle(data_blob2.pbData); } CRYPTPROTECT_PROMPTSTRUCT promptStruct = PreparePromptStructure(); uint flags = 1; if (this.UseMachineProtection) { flags |= 4; } bool flag = false; RuntimeHelpers.PrepareConstrainedRegions(); try { } finally { flag = Microsoft.Win32.UnsafeNativeMethods.CryptUnprotectData(ref data_blob, IntPtr.Zero, ref data_blob2, IntPtr.Zero, ref promptStruct, flags, ref data_blob3); handle2.SetDataHandle(data_blob3.pbData); } if (!flag || (data_blob3.pbData == IntPtr.Zero)) { data_blob3.pbData = IntPtr.Zero; Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error()); } byte[] destination = new byte[data_blob3.cbData]; Marshal.Copy(data_blob3.pbData, destination, 0, destination.Length); str = Encoding.Unicode.GetString(destination); } finally { if ((handle2 != null) && !handle2.IsInvalid) { handle2.Dispose(); data_blob3.pbData = IntPtr.Zero; } if ((handle3 != null) && !handle3.IsInvalid) { handle3.Dispose(); data_blob2.pbData = IntPtr.Zero; } if ((handle != null) && !handle.IsInvalid) { handle.Dispose(); data_blob.pbData = IntPtr.Zero; } } return str; }