Error: Specified key is not a valid size for this algorithm. (TripleDES)
I built a Cryptography application by using TripleDES. But I got an error:
System.Security.Cryptography.CryptographicException: Specified key is not a valid size for this algorithm.
The key I used was in an incorrect length, it should 16 bytes length.
For example:
Code
PasswordDeriveBytes pwd = new PasswordDeriveBytes("password", salt); | |
TripleDES alg = TripleDES.Create(); | |
| |
alg.Key = pwd.GetBytes(16); | |
alg.IV = new byte[alg.BlockSize / 8];; |
Visual Studio 2013 Express is ok so far
I am running out of licenses for Visual Studio Professional. Solution 1 is asking for more budget this year in IT. Another option is using Express version. I know this version doesn't come with automated testing and class diagrams, those sorts of developers' support tools.However, we don't use those tools a lot. We just build MVC website. So far, Visual Studio 2013 Express is ok for us, it supports NuGet, MVC and EF. I felt that is even faster then the Professional version.
MenuItem Icon - WPF
I tried the icon attribute in MenuItem. It doesn't work.Actually, you need to modify the header element like this:
XML
<MenuItem | |
Name="GridButton" Visibility="Collapsed" Click="GridButton_Click"> | |
<MenuItem.Header> | |
<StackPanel> | |
<Image Source="../Images/open.png" Width="16" Height="16"/> | |
</StackPanel> | |
</MenuItem.Header> | |
</MenuItem> |
WPF TextBlock Click Event
Actually, for WPF TextBlock Component, there is no click event. The best replacement is Mouse Down Event,
Like this:
Code
text1.MouseDown += text1_MouseDown; |
Adding a WPF control into a panel programmatically
The best way to design an interface for WPF is using xaml. However, in some situation, we need to change the layout in code. For example, we select a category view, we need to add a new block in a stack panel.
For example:
Code
TextBlock text1 = new TextBlock(); | |
text1.Text = grid.HeaderText; | |
LinearGradientBrush style = this.FindResource("LeftHeaderBrush") as LinearGradientBrush ; | |
text1.Background= style; | |
text1.Height = 100; | |
inactivePanels.Children.Add(text1); |