Changeset 895 for trunk/CrypPlugins/MD5


Ignore:
Timestamp:
Nov 24, 2009, 3:00:20 PM (12 years ago)
Author:
pretzsch
Message:

+ MD5: Presentation controls and helpers

Location:
trunk/CrypPlugins/MD5
Files:
51 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrypPlugins/MD5/Algorithm/PresentableMD5.cs

    r870 r895  
    527527            // Remember that padding is done now
    528528            newState.IsPaddingDone = true;
     529
     530            // Update data length
     531            newState.DataLength += 8;
    529532        }
    530533
  • trunk/CrypPlugins/MD5/Algorithm/PresentableMD5State.cs

    r870 r895  
    165165
    166166        /// <summary>
     167        /// Returns the 64 byte block for the current iteration (downsizes the 128 byte Data array to 64 bytes)
     168        /// </summary>
     169        public byte[] CurrentDataBlock
     170        {
     171            get
     172            {
     173                uint currentBlockLength = Math.Min(DataLength, 64);
     174                byte[] result = new byte[currentBlockLength];
     175                Array.Copy(Data, DataOffset, result, 0, currentBlockLength);
     176                return result;
     177            }
     178        }
     179
     180        /// <summary>
    167181        /// Determines the length of data in the buffer
    168182        /// </summary>
  • trunk/CrypPlugins/MD5/MD5.csproj

    r870 r895  
    1515    <SignAssembly>true</SignAssembly>
    1616    <AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
     17    <ExpressionBlendVersion>3.0.1927.0</ExpressionBlendVersion>
     18    <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
    1719  </PropertyGroup>
    1820  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     
    6870    <Compile Include="Algorithm\PresentableMD5State.cs" />
    6971    <Compile Include="Presentation\Converters\BytesToStringConverter.cs" />
     72    <Compile Include="Presentation\Converters\MD5StateDescriptionToStringConverter.cs" />
     73    <Compile Include="Presentation\Converters\MD5StateToUserControlConverter.cs" />
     74    <Compile Include="Presentation\Converters\UintToLittleEndianHexStringConverter.cs" />
     75    <Compile Include="Presentation\Displays\DataBlockDisplay.xaml.cs">
     76      <DependentUpon>DataBlockDisplay.xaml</DependentUpon>
     77    </Compile>
     78    <Compile Include="Presentation\Displays\HashAccumulatorDisplay.xaml.cs">
     79      <DependentUpon>HashAccumulatorDisplay.xaml</DependentUpon>
     80    </Compile>
     81    <Compile Include="Presentation\Displays\LabelledIntegerDisplay.xaml.cs">
     82      <DependentUpon>LabelledIntegerDisplay.xaml</DependentUpon>
     83    </Compile>
     84    <Compile Include="Presentation\Displays\StateDescriptionDisplay.xaml.cs">
     85      <DependentUpon>StateDescriptionDisplay.xaml</DependentUpon>
     86    </Compile>
     87    <Compile Include="Presentation\Helpers\PresentationControlFactory.cs" />
    7088    <Compile Include="Presentation\PresentationContainer.xaml.cs">
    7189      <DependentUpon>PresentationContainer.xaml</DependentUpon>
     90    </Compile>
     91    <Compile Include="Presentation\States\AddedLengthPresentation.xaml.cs">
     92      <DependentUpon>AddedLengthPresentation.xaml</DependentUpon>
     93    </Compile>
     94    <Compile Include="Presentation\States\AddedPaddingBytesPresentation.xaml.cs">
     95      <DependentUpon>AddedPaddingBytesPresentation.xaml</DependentUpon>
     96    </Compile>
     97    <Compile Include="Presentation\States\AddingLengthPresentation.xaml.cs">
     98      <DependentUpon>AddingLengthPresentation.xaml</DependentUpon>
     99    </Compile>
     100    <Compile Include="Presentation\States\AddingPaddingBytesPresentation.xaml.cs">
     101      <DependentUpon>AddingPaddingBytesPresentation.xaml</DependentUpon>
     102    </Compile>
     103    <Compile Include="Presentation\States\FinishedCompressionPresentation.xaml.cs">
     104      <DependentUpon>FinishedCompressionPresentation.xaml</DependentUpon>
     105    </Compile>
     106    <Compile Include="Presentation\States\FinishedPaddingPresentation.xaml.cs">
     107      <DependentUpon>FinishedPaddingPresentation.xaml</DependentUpon>
     108    </Compile>
     109    <Compile Include="Presentation\States\FinishedPresentation.xaml.cs">
     110      <DependentUpon>FinishedPresentation.xaml</DependentUpon>
     111    </Compile>
     112    <Compile Include="Presentation\States\FinishedRoundPresentation.xaml.cs">
     113      <DependentUpon>FinishedRoundPresentation.xaml</DependentUpon>
     114    </Compile>
     115    <Compile Include="Presentation\States\FinishedRoundStepPresentation.xaml.cs">
     116      <DependentUpon>FinishedRoundStepPresentation.xaml</DependentUpon>
     117    </Compile>
     118    <Compile Include="Presentation\States\FinishingCompressionPresentation.xaml.cs">
     119      <DependentUpon>FinishingCompressionPresentation.xaml</DependentUpon>
     120    </Compile>
     121    <Compile Include="Presentation\States\InitializedPresentation.xaml.cs">
     122      <DependentUpon>InitializedPresentation.xaml</DependentUpon>
     123    </Compile>
     124    <Compile Include="Presentation\States\ReadDataPresentation.xaml.cs">
     125      <DependentUpon>ReadDataPresentation.xaml</DependentUpon>
     126    </Compile>
     127    <Compile Include="Presentation\States\ReadingDataPresentation.xaml.cs">
     128      <DependentUpon>ReadingDataPresentation.xaml</DependentUpon>
     129    </Compile>
     130    <Compile Include="Presentation\States\StartingCompressionPresentation.xaml.cs">
     131      <DependentUpon>StartingCompressionPresentation.xaml</DependentUpon>
     132    </Compile>
     133    <Compile Include="Presentation\States\StartingPaddingPresentation.xaml.cs">
     134      <DependentUpon>StartingPaddingPresentation.xaml</DependentUpon>
     135    </Compile>
     136    <Compile Include="Presentation\States\StartingRoundPresentation.xaml.cs">
     137      <DependentUpon>StartingRoundPresentation.xaml</DependentUpon>
     138    </Compile>
     139    <Compile Include="Presentation\States\StartingRoundStepPresentation.xaml.cs">
     140      <DependentUpon>StartingRoundStepPresentation.xaml</DependentUpon>
     141    </Compile>
     142    <Compile Include="Presentation\States\UninitializedPresentation.xaml.cs">
     143      <DependentUpon>UninitializedPresentation.xaml</DependentUpon>
    72144    </Compile>
    73145    <Compile Include="Properties\AssemblyInfo.cs" />
     
    98170  </ItemGroup>
    99171  <ItemGroup>
     172    <Page Include="Presentation\Displays\DataBlockDisplay.xaml">
     173      <SubType>Designer</SubType>
     174      <Generator>MSBuild:Compile</Generator>
     175    </Page>
     176    <Page Include="Presentation\Displays\HashAccumulatorDisplay.xaml">
     177      <SubType>Designer</SubType>
     178      <Generator>MSBuild:Compile</Generator>
     179    </Page>
     180    <Page Include="Presentation\Displays\LabelledIntegerDisplay.xaml">
     181      <Generator>MSBuild:Compile</Generator>
     182      <SubType>Designer</SubType>
     183    </Page>
     184    <Page Include="Presentation\Displays\StateDescriptionDisplay.xaml">
     185      <SubType>Designer</SubType>
     186      <Generator>MSBuild:Compile</Generator>
     187    </Page>
    100188    <Page Include="Presentation\PresentationContainer.xaml">
     189      <SubType>Designer</SubType>
     190      <Generator>MSBuild:Compile</Generator>
     191    </Page>
     192    <Page Include="Presentation\States\AddedLengthPresentation.xaml">
     193      <SubType>Designer</SubType>
     194      <Generator>MSBuild:Compile</Generator>
     195    </Page>
     196    <Page Include="Presentation\States\AddedPaddingBytesPresentation.xaml">
     197      <SubType>Designer</SubType>
     198      <Generator>MSBuild:Compile</Generator>
     199    </Page>
     200    <Page Include="Presentation\States\AddingLengthPresentation.xaml">
     201      <SubType>Designer</SubType>
     202      <Generator>MSBuild:Compile</Generator>
     203    </Page>
     204    <Page Include="Presentation\States\AddingPaddingBytesPresentation.xaml">
     205      <SubType>Designer</SubType>
     206      <Generator>MSBuild:Compile</Generator>
     207    </Page>
     208    <Page Include="Presentation\States\FinishedCompressionPresentation.xaml">
     209      <SubType>Designer</SubType>
     210      <Generator>MSBuild:Compile</Generator>
     211    </Page>
     212    <Page Include="Presentation\States\FinishedPaddingPresentation.xaml">
     213      <SubType>Designer</SubType>
     214      <Generator>MSBuild:Compile</Generator>
     215    </Page>
     216    <Page Include="Presentation\States\FinishedPresentation.xaml">
     217      <SubType>Designer</SubType>
     218      <Generator>MSBuild:Compile</Generator>
     219    </Page>
     220    <Page Include="Presentation\States\FinishedRoundPresentation.xaml">
     221      <SubType>Designer</SubType>
     222      <Generator>MSBuild:Compile</Generator>
     223    </Page>
     224    <Page Include="Presentation\States\FinishedRoundStepPresentation.xaml">
     225      <SubType>Designer</SubType>
     226      <Generator>MSBuild:Compile</Generator>
     227    </Page>
     228    <Page Include="Presentation\States\FinishingCompressionPresentation.xaml">
     229      <SubType>Designer</SubType>
     230      <Generator>MSBuild:Compile</Generator>
     231    </Page>
     232    <Page Include="Presentation\States\InitializedPresentation.xaml">
     233      <SubType>Designer</SubType>
     234      <Generator>MSBuild:Compile</Generator>
     235    </Page>
     236    <Page Include="Presentation\States\ReadDataPresentation.xaml">
     237      <SubType>Designer</SubType>
     238      <Generator>MSBuild:Compile</Generator>
     239    </Page>
     240    <Page Include="Presentation\States\ReadingDataPresentation.xaml">
     241      <SubType>Designer</SubType>
     242      <Generator>MSBuild:Compile</Generator>
     243    </Page>
     244    <Page Include="Presentation\States\StartingCompressionPresentation.xaml">
     245      <SubType>Designer</SubType>
     246      <Generator>MSBuild:Compile</Generator>
     247    </Page>
     248    <Page Include="Presentation\States\StartingPaddingPresentation.xaml">
     249      <SubType>Designer</SubType>
     250      <Generator>MSBuild:Compile</Generator>
     251    </Page>
     252    <Page Include="Presentation\States\StartingRoundPresentation.xaml">
     253      <SubType>Designer</SubType>
     254      <Generator>MSBuild:Compile</Generator>
     255    </Page>
     256    <Page Include="Presentation\States\StartingRoundStepPresentation.xaml">
     257      <SubType>Designer</SubType>
     258      <Generator>MSBuild:Compile</Generator>
     259    </Page>
     260    <Page Include="Presentation\States\UninitializedPresentation.xaml">
    101261      <SubType>Designer</SubType>
    102262      <Generator>MSBuild:Compile</Generator>
  • trunk/CrypPlugins/MD5/Presentation/Converters/BytesToStringConverter.cs

    r870 r895  
    99    class BytesToStringConverter : IValueConverter
    1010    {
    11         #region IValueConverter Member
    12 
    1311        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    1412        {
    1513            byte[] byteArray = (byte[])value;
     14
    1615            if (byteArray == null)
    17                 return String.Empty;
     16                return string.Empty;
    1817
    19             StringBuilder sb = new StringBuilder(byteArray.Length * 2);
    20             foreach (byte b in byteArray)
    21             {
    22                 sb.AppendFormat("{0:x2}", b);
    23             }
    24 
    25             return sb.ToString();
     18            return BitConverter.ToString(byteArray).Replace('-', ' ');
    2619        }
    2720
     
    3023            throw new NotImplementedException();
    3124        }
    32 
    33         #endregion
    3425    }
    3526}
  • trunk/CrypPlugins/MD5/Presentation/PresentationContainer.xaml

    r870 r895  
    22    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    33    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    4              xmlns:convert="clr-namespace:Cryptool.MD5.Presentation.Converters">
     4    xmlns:converters="clr-namespace:Cryptool.MD5.Presentation.Converters"
     5             xmlns:displays="clr-namespace:Cryptool.MD5.Presentation.Displays"
     6        Background="White" Height="435" Width="761">
    57    <UserControl.Resources>
    6         <convert:BytesToStringConverter x:Key="bytesToStringConverter"/>
     8        <converters:BytesToStringConverter x:Key="bytesToStringConverter"/>
     9        <converters:MD5StateToUserControlConverter x:Key="md5StateToUserControlConverter"/>
    710    </UserControl.Resources>
    811    <Grid>
    9         <Label Height="28" HorizontalAlignment="Left" Margin="12,12,0,0" Name="stateCaptionLabel" VerticalAlignment="Top" Width="94">State:</Label>
    10         <Label Height="28" Margin="64,12,0,0" Name="stateValueLabel" VerticalAlignment="Top" Content="{Binding CurrentState.State}" HorizontalAlignment="Left" Width="136" />
    11         <Button Height="23" Margin="122,0,0,12" Name="previousStepButton" VerticalAlignment="Bottom" Click="previousStepButton_Click" HorizontalAlignment="Left" Width="75">&lt;&lt; Previous</Button>
    12         <Button Height="23" Margin="203,0,0,12" Name="nextStepButton" VerticalAlignment="Bottom" Click="nextStepButton_Click" HorizontalAlignment="Left" Width="75">Next &gt;&gt;</Button>
    13         <Rectangle Height="60" Margin="12,46,12,0" Name="rectangle1" Stroke="Black" VerticalAlignment="Top" />
    14         <Label Height="28" Margin="12,46,12,0" Name="label1" VerticalAlignment="Top">Data</Label>
    15         <Label Height="28" Margin="12,80,12,0" Name="label2" VerticalAlignment="Top" Content="{Binding CurrentState.Data, Converter={StaticResource bytesToStringConverter}}"/>
    16         <Label Height="28" HorizontalAlignment="Left" Margin="12,114,0,0" Name="label3" VerticalAlignment="Top" Width="120">A</Label>
    17         <Label Height="28" HorizontalAlignment="Left" Margin="138,114,0,0" Name="label4" VerticalAlignment="Top" Width="120">B</Label>
    18         <Label Height="28" HorizontalAlignment="Right" Margin="0,114,12,0" Name="label5" VerticalAlignment="Top" Width="120">D</Label>
    19         <Label Height="28" HorizontalAlignment="Right" Margin="0,114,138,0" Name="label6" VerticalAlignment="Top" Width="120">C</Label>
    20         <Label HorizontalAlignment="Left" Margin="12,140,0,0" Name="label7" Width="120" Height="28" VerticalAlignment="Top" Content="{Binding CurrentState.A}"/>
    21         <Label Margin="138,140,0,0" Name="label8" Height="28" HorizontalAlignment="Left" VerticalAlignment="Top" Width="120" Content="{Binding CurrentState.B}"/>
    22         <Label HorizontalAlignment="Right" Margin="0,140,138,0" Name="label9" Width="120" Height="28" VerticalAlignment="Top" Content="{Binding CurrentState.C}"/>
    23         <Label Height="28" HorizontalAlignment="Right" Margin="0,140,12,0" Name="label10" VerticalAlignment="Top" Width="120" Content="{Binding CurrentState.D}"/>
    24         <Label Height="28" HorizontalAlignment="Left" Margin="12,0,0,138" Name="label11" VerticalAlignment="Bottom" Width="120">H1</Label>
    25         <Label Height="28" Margin="138,0,0,138" Name="label12" VerticalAlignment="Bottom" HorizontalAlignment="Left" Width="120">H2</Label>
    26         <Label Height="28" HorizontalAlignment="Right" Margin="0,0,138,138" Name="label13" VerticalAlignment="Bottom" Width="120">H3</Label>
    27         <Label Height="28" HorizontalAlignment="Right" Margin="0,0,12,138" Name="label14" VerticalAlignment="Bottom" Width="120">H4</Label>
    28         <Label Height="28" HorizontalAlignment="Left" Margin="12,0,0,104" Name="label15" VerticalAlignment="Bottom" Width="120" Content="{Binding CurrentState.H1}"/>
    29         <Label Height="28" HorizontalAlignment="Left" Margin="138,0,0,104" Name="label16" VerticalAlignment="Bottom" Width="120" Content="{Binding CurrentState.H2}"/>
    30         <Label Height="28" HorizontalAlignment="Right" Margin="0,0,138,104" Name="label17" VerticalAlignment="Bottom" Width="120" Content="{Binding CurrentState.H3}"/>
    31         <Label Height="28" HorizontalAlignment="Right" Margin="0,0,12,104" Name="label18" VerticalAlignment="Bottom" Width="120" Content="{Binding CurrentState.H4}"/>
    32         <Label Height="28" Margin="206,12,0,0" Name="label19" VerticalAlignment="Top" HorizontalAlignment="Left" Width="72">Round</Label>
    33         <Label Height="28" Margin="284,12,202,0" Name="label20" VerticalAlignment="Top" Content="{Binding CurrentState.Round}"/>
    34         <Label Height="28" HorizontalAlignment="Right" Margin="0,12,110,0" Name="label21" VerticalAlignment="Top" Width="86">Step</Label>
    35         <Label Height="28" HorizontalAlignment="Right" Margin="0,12,12,0" Name="label22" VerticalAlignment="Top" Width="92" Content="{Binding CurrentState.Step}"/>
    36         <Button Height="23" Margin="284,0,209,12" Name="endOfRoundButton" VerticalAlignment="Bottom" Click="endOfRoundButton_Click">End of Round &gt;&gt;&gt;</Button>
    37         <Button Height="23" HorizontalAlignment="Right" Margin="0,0,12,12" Name="endOfCompressionButton" VerticalAlignment="Bottom" Width="191" Click="endOfCompressionButton_Click">End of block compression &gt;&gt;&gt;&gt;</Button>
    38         <Label Height="28" HorizontalAlignment="Left" Margin="15,0,0,70" Name="label23" VerticalAlignment="Bottom" Width="120">H-Bytes:</Label>
    39         <Label Height="28" Margin="141,0,12,70" Name="label24" VerticalAlignment="Bottom" Content="{Binding HashValueBytes, Converter={StaticResource bytesToStringConverter}}"/>
     12        <displays:StateDescriptionDisplay Height="41" Margin="8,12,8,0" VerticalAlignment="Top" />
     13        <Button Height="23" Margin="0,0,480,66" Name="previousStepButton" VerticalAlignment="Bottom" Click="previousStepButton_Click" HorizontalAlignment="Right" Width="150">&lt;&lt; Previous</Button>
     14        <Button Height="23" Margin="0,0,324,66" Name="nextStepButton" VerticalAlignment="Bottom" Click="nextStepButton_Click" HorizontalAlignment="Right" Width="150">Next &gt;&gt;</Button>
     15        <Button Height="23" Margin="0,0,168,66" Name="endOfRoundButton" VerticalAlignment="Bottom" Click="endOfRoundButton_Click" Width="150" HorizontalAlignment="Right">End of Round &gt;&gt;&gt;</Button>
     16        <Button Height="23" HorizontalAlignment="Right" Margin="0,0,12,66" x:Name="endOfCompressionButton" VerticalAlignment="Bottom" Width="150" Click="endOfCompressionButton_Click" Content="End of Block &gt;&gt;&gt;&gt;"/>
     17        <UserControl Margin="8,59,8,95" Name="statePresentationContainer"  Content="{Binding CurrentState,Converter={StaticResource md5StateToUserControlConverter}}"/>
     18        <displays:HashAccumulatorDisplay Height="36" Margin="0,0,12,24" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="306" DataContext="{Binding CurrentState}" />
    4019    </Grid>
     20   
    4121</UserControl>
  • trunk/CrypPlugins/MD5/Presentation/PresentationContainer.xaml.cs

    r870 r895  
    1313using System.Windows.Shapes;
    1414using Cryptool.MD5.Algorithm;
     15using Cryptool.MD5.Presentation.States;
    1516
    1617namespace Cryptool.MD5.Presentation
     
    2526        public PresentationContainer(PresentableMD5 presentableMd5)
    2627        {
    27             md5 = presentableMd5;
    28             DataContext = presentableMd5;
     28            DataContext = md5 = presentableMd5;
    2929
    3030            InitializeComponent();
     31
     32            Height = double.NaN;
     33            Width = double.NaN;
    3134        }
    3235
     
    3437        {
    3538            md5.NextStep();
     39            new ReadDataPresentation();
    3640        }
    3741
  • trunk/CrypPlugins/MD5/Properties/AssemblyInfo.cs

    r883 r895  
    2424// [assembly: AssemblyVersion("2.0.*")]
    2525[assembly: AssemblyVersion("2.0.3594.00001")]
     26[assembly: System.Windows.ThemeInfo(System.Windows.ResourceDictionaryLocation.None, System.Windows.ResourceDictionaryLocation.SourceAssembly)]
Note: See TracChangeset for help on using the changeset viewer.