source: trunk/CrypPlugins/TripleDES/TripleDESSettings.cs @ 2214

Last change on this file since 2214 was 230, checked in by Thomas Schmid, 13 years ago
  • prepared GUI update event
File size: 3.4 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.IO;
6using Cryptool.PluginBase;
7using System.Security.Cryptography;
8using System.ComponentModel;
9
10namespace Cryptool.Plugins.Cryptography.Encryption
11{
12    public class TripleDESSettings : ISettings
13    {
14        private bool hasChanges = false;
15        private int action = 0; //0=encrypt, 1=decrypt
16        private int mode = 0; //0="ECB", 1="CBC", 2="CFB", 3="OFB"
17        private int padding = 0; //0="Zeros"=default, 1="None", 2="PKCS7", 3="ANSIX923", 4="ISO10126
18
19        [ContextMenu("Action","Do you want the input data to be encrypted or decrypted?",1,DisplayLevel.Beginner,ContextMenuControlType.ComboBox,new int[] {1,2},"Encrypt","Decrypt")]
20        [TaskPane("Action", "Do you want the input data to be encrypted or decrypted?", null, 1, false, DisplayLevel.Beginner,ControlType.ComboBox, new string[] {"Encrypt","Decrypt"})]
21        public int Action
22        {
23            get { return this.action; }
24            set
25            {
26                if (((int)value) != action) hasChanges = true;
27                this.action = (int)value;
28                OnPropertyChanged("Action");
29            }
30        }
31
32        [ContextMenu("Chaining mode","Select the block cipher mode of operation.",2,DisplayLevel.Beginner,ContextMenuControlType.ComboBox, null, new string[] {"Electronic Code Book (ECB)","Cipher Block Chaining (CBC)","Cipher Feedback (CFB)"})]
33        [TaskPane("Chaining mode", "Select the block cipher mode of operation.","", 2, false, DisplayLevel.Experienced, ControlType.ComboBox, new string[] {"Electronic Code Book (ECB)","Cipher Block Chaining (CBC)","Cipher Feedback (CFB)"})]
34        public int Mode
35        {
36            get { return this.mode; }
37            set
38            {
39                if (((int)value) != mode) hasChanges = true;
40                this.mode = (int)value;
41                OnPropertyChanged("Mode");
42            }
43        }
44
45        [ContextMenu("Padding mode","Select a mode to fill partial data blocks.",3, DisplayLevel.Beginner, ContextMenuControlType.ComboBox, null,"Zeros","None","PKCS7","ANSIX923","ISO10126")]
46        [TaskPane("Padding mode", "Select a mode to fill partial data blocks.", "", 3, false, DisplayLevel.Experienced,ControlType.ComboBox, new String[]{"Zeros","None","PKCS7","ANSIX923","ISO10126"})]
47        public int Padding
48        {
49            get { return this.padding; }
50            set
51            {
52                if (((int)value) != padding) hasChanges = true;
53                this.padding = (int)value;
54                OnPropertyChanged("Padding");
55            }
56        }
57
58        public bool HasChanges
59        {
60            get { return hasChanges; }
61            set { hasChanges = value; }
62        }
63
64        #region INotifyPropertyChanged Members
65
66        public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
67
68        protected void OnPropertyChanged(string name)
69        {
70            if (PropertyChanged != null)
71            {
72                PropertyChanged(this, new PropertyChangedEventArgs(name));
73            }
74        }
75
76        #endregion
77
78        public event StatusChangedEventHandler OnPluginStatusChanged;
79
80        private void ChangePluginIcon(int Icon)
81        {
82            if (OnPluginStatusChanged != null) OnPluginStatusChanged(null, new StatusEventArgs(StatusChangedMode.ImageUpdate, Icon));
83        }
84    }
85}
Note: See TracBrowser for help on using the repository browser.