Caliburn.Micro support for PasswordBox?

Here’s a much more simplified example, including a binding convention so that PasswordBox binding in Caliburn.Micro Just Works™: public static class PasswordBoxHelper { public static readonly DependencyProperty BoundPasswordProperty = DependencyProperty.RegisterAttached(“BoundPassword”, typeof(string), typeof(PasswordBoxHelper), new FrameworkPropertyMetadata(string.Empty, OnBoundPasswordChanged)); public static string GetBoundPassword(DependencyObject d) { var box = d as PasswordBox; if (box != null) { // this funny … Read more

C# – compare two SecureStrings for equality

This doesn’t have unsafe blocks and won’t display the password in plaintext: public static bool IsEqualTo(this SecureString ss1, SecureString ss2) { IntPtr bstr1 = IntPtr.Zero; IntPtr bstr2 = IntPtr.Zero; try { bstr1 = Marshal.SecureStringToBSTR(ss1); bstr2 = Marshal.SecureStringToBSTR(ss2); int length1 = Marshal.ReadInt32(bstr1, -4); int length2 = Marshal.ReadInt32(bstr2, -4); if (length1 == length2) { for (int x … Read more