# Changeset 1236 for trunk/Documentation

Ignore:
Timestamp:
Mar 10, 2010, 4:49:36 PM (12 years ago)
Message:

HowTo: reworked first Chapter, added some new screenshots, and started fixing smaller things in Chapter 2.

Location:
trunk/Documentation/Developer/PluginHowTo
Files:
5 edited

### Legend:

Unmodified
 r1231 \label{DeveloperGuidelines} CrypTool 2.0 uses state-of-the-art technologies like .NET 3.5 and WPF. In order to make your first steps towards developing something in the context of this project, a few things need to be considered. First of all, please follow the instructions in this document so that you do not get stuck. If you encouter a problem or error that is not described here, please let us know so we can add the appropriate information to this guide. CrypTool 2.0 is built upon state-of-the-art technologies such as .NET 3.5 and the Windows Presentation Foundation. Before you can start writing code and adding to the development of the project, a few things need to be considered. To make this process easier, please read through this document and follow the instructions closely. This document exists to help get you started by showing you how CrypTool 2 plugins are built in order to succesfully interact with the application core. We have tried to be very thorough, but if you encouter a problem or error that is not described here, please let us know. Not only do we want to help get you up and running, but we also want to add the appropriate information to this guide for the benefit of other future developers. In the following sections we will describe all steps necessary in order to compile CrypTool 2.0 on your own. This is always the first thing you need to do before you can begin developing your own plugins and extensions. The basic steps are: In this first chapter we will describe all steps necessary in order to compile CrypTool 2.0 on your own computer. This is always the first thing you need to do before you can begin developing your own plugins and extensions. The basic steps are: \begin{itemize} \item Getting all prerequisites and installing them \item Accessing and downloading the source code with SVN \item Compiling the current source code for the first time \item Compiling the latest version of the source code \end{itemize} \label{Prerequisites} Since CrypTool 2.0 is based on Microsoft .NET 3.5, you will need a Microsoft Windows environment. (Currently no plans exist for porting this project to mono or to other platforms.) We have successfully tested with \textbf{Windows XP}, \textbf{Windows Vista} and \textbf{Windows 7}. Since CrypTool 2.0 is based on Microsoft .NET 3.5, you will need a Microsoft Windows environment. (Currently no plans exist for porting this project to Mono or other platforms.) We have successfully tested with \textbf{Windows XP}, \textbf{Windows Vista} and \textbf{Windows 7}. Since you are reading the developer guidelines, you probably want to develop something. Hence, you will need a development environment. In order to compile our sources you need \textbf{Microsoft Visual Studio 2008 Professional}. Please always install the latest service packs for Visual Studio. Unfortunately, our sources do not work (smoothly) with the freely available Visual Studio Express (C\#) versions. This is due to the fact that CrypWin uses a commercial component and is therefore distributed only as binary, and the current version of C\# Express cannot handle a binary as a start project, which makes debugging cumbersome. This will be resolved later in 2010 when the project is moved to Visual Studio 2010. Since you are reading the developer guidelines, you probably want to develop something. Hence, you will need a development environment. In order to compile our sources you need \textbf{Microsoft Visual Studio 2008 Professional}. Make sure to always install the latest service packs for Visual Studio. Unfortunately, our sources do not work smoothly with the freely available Visual C\# Express. This is due to the fact that a major part of the application core, CrypWin, uses a commercial component and is therefore distributed only as a binary. The current version of Visual C\# Express does not accept a binary file as a start-up project, and thus debugging is quite cumbersome. We hope to resolve this issue later in 2010 when the project is ported to Visual Studio 2010, but until then, we recommend using the full Visual Studio 2008 Professional version. Usually the installation of Visual Studio also installs the .NET framework. In order to run or compile our source code you will need (at the time of writing) at least \textbf{Microsoft .NET 3.5 with Service Pack 1 (SP1)}. You can get this for free from Microsoft's \href{http://download.microsoft.com/download/2/0/e/20e90413-712f-438c-988e-fdaa79a8ac3d/dotnetfx35.exe}{webpage}. Once that has been installed, your development environment should be ready for our source code. In order to run or compile our source code you will need at least the \textbf{Microsoft .NET 3.5 framework with Service Pack 1 (SP1)}. Usually the installation of Visual Studio also installs the .NET framework, but if you do not have the latest version, you can get it for free from \href{http://download.microsoft.com/download/0/6/1/061F001C-8752-4600-A198-53214C69B51F/dotnetfx35setup.exe}{Microsoft's website}. Once the framework has been installed, your development environment should be ready for our source code. \clearpage \section{Accessing Subversion (SVN)} \section{Accessing the Subversion (SVN) repository} \label{AccessingSubversion} Now you will need a way of accessing and downloading the source code. In the CrypTool 2.0 project we use Subversion (SVN) for version control, and hence you need an \textbf{SVN client}, e.g.\ \textbf{TortoiseSVN} or the \textbf{svn commandline from cygwin}. It does not matter which client you use, but if you have never worked with SVN before, we suggest using \href{http://www.tortoisesvn.net/}{TortoiseSVN}, since it offers a nice Windows Explorer integration of SVN. \clearpage Next you will need a way of accessing and downloading the source code. For the CrypTool 2.0 project we use Subversion (SVN) for version control, and hence you will need an \textbf{SVN client}, i.e.\ \textbf{TortoiseSVN} or the \textbf{svn commandline from cygwin}, to access our repository. It does not matter which client you use, but if SVN is new to you, we suggest using \href{http://www.tortoisesvn.net/}{TortoiseSVN}, since it offers a handy, straightforward Windows Explorer integration. We will guide you through how to use TortoiseSVN, although you should be able to use any SVN client in a similar fashion. \subsection{The CrypTool2 SVN URL} \label{TheCrypTool2SVNURL} \subsection{Checking out the sources} \label{CheckingOutTheSources} Our code repository is accessable at the following URL: \url{https://www.cryptool.org/svn/CrypTool2/} To access the repository, you must provide a username and password. If you are a guest and just want to download our source code, you can use anonymous'' as the username and an empty password. If you are a registered developer, just use your provided username and password (which should be the same as for the wiki). \subsection{Accessing the repository with TortoiseSVN} \label{AccessingTheRepositoryWithTortoiseSVN} As mentioned above, in order to access the SVN repository one of the best options is \href{http://www.tortoisesvn.net/}{TortoiseSVN}. We will describe here how to use the basics of the program, although you should be able to use any SVN client in a similar fashion. First, download and install TortoiseSVN. This will require you to reboot your computer, but once it is back up and running, create a directory (for instance, \textit{CrypTool2}) somewhere on your computer for storing the local working files. Right-click on this directory; now that TortoiseSVN has been installed, you should see a few new items in the context menu. Select \textit{SVN Checkout}: \begin{figure}[h!] \centering \includegraphics[width=0.40\textwidth]{figures/tortoise_svn_checkout.jpg} \caption{Selecting SVN Checkout'' from the context menu after installing TortoiseSVN.} \caption{Selecting \textit{SVN Checkout} from the context menu after installing TortoiseSVN.} \label{fig:tortoise_svn_checkout} \end{figure} \clearpage First install TortoiseSVN (which unfortunately requires you to reboot your computer) and then create a directory (for instance CrypTool2'') for storing the local working files somewhere on your computer. Right-click on this directory and select SVN Checkout'' from the context menu. A window will appear in which you will be asked for the URL of the repository; use the address given above, as seen in Figure \ref{fig:tortoise_svn_checkout2}. The Checkout directory'' should already be filled in correctly with your new folder. Then just hit OK'', accept the certificate (if necessary), and enter your login information as described above. Mark the checkbox for saving your credentials if you don't want to enter them every time you work with the repository. Then hit OK'', and now the whole CrypTool2 repository should be checked out into your chosen directory. \clearpage A window will now appear that will ask you for the URL of the repository that you would like to access. Our code repository is stored at \url{https://www.cryptool.org/svn/CrypTool2/}, and this is what you should enter in the appropriate field. The \textit{Checkout directory} should already be filled in correctly with your new folder, and you shouldn't need to change any other options. \begin{figure}[h!] \centering \includegraphics[width=0.60\textwidth]{figures/tortoise_svn_checkout2.jpg} \caption{Checking out the CrypTool2 repository.} \caption{Checking out the CrypTool 2 repository.} \label{fig:tortoise_svn_checkout2} \end{figure} Later on, if changes have been made in the repository and you want to update your working copy, you can do this by right-clicking on any directory within the working files and choosing SVN Update'' from the context menu. You should do this often to maintain a current version of the files. Then just hit \textit{OK}. You may be asked to accept a certificate (which you should accept), and you will certainly be asked for login information. If you are a registered developer, you should have already been given a username and password, and you should enter them here. (These are the same username and password that you can use for the \href{https://www.cryptool.org/trac/CrypTool2/wiki/WikiStart}{CrypTool 2 development wiki}). If you are a guest and just want to download the source code, you can use anonymous'' as the username and an empty password. Mark the checkbox for saving your credentials if you don't want to enter them every time you work with the repository. Finally, hit \textit{OK}, and the whole CrypTool 2 repository will begin downloading into your chosen local directory. A TortoiseSVN tutorial can be found \href{http://www.mind.ilstu.edu/research/robots/iris4/developers/svntutorial}{here}. Since CrypTool 2 is a collaborative project with many developers, changes are made to the repository rather frequently. You should maintain a current working copy of the files to ensure your interoperability with the rest of the project, and thus you should update to the latest version as often as possible. You can do this by right-clicking on any directory within the working files and choosing \textit{SVN~Update} from the context menu. \subsection{Committing your changes} \label{CommitingYourChanges} A TortoiseSVN tutorial can be found at \url{http://www.mind.ilstu.edu/research/robots/iris4/developers/svntutorial}. \clearpage If you are a registered developer, you can commit your file changes to the public CrypTool2 repository. Right-click on the directory within the working files that contains your changes and select SVN Commit'' from the context menu to upload your changes. Please always provide \textit{meaningful descriptions} of your updates. You should commit your sources to our SVN repository as often as you can to ensure your interoperability with the rest of the project, but only commit code that successfully compiles and runs! \subsection{Adjusting the SVN settings} \label{AdjustingTheSVNSettings} If you are a registered developer, you can commit your file changes to the public CrypTool 2 repository. However, before you do, you should edit your settings to make sure that you only check in proper source code. First, bring up the TortoiseSVN settings window: \begin{figure}[h!] \centering \includegraphics[width=0.40\textwidth]{figures/tortoise_svn_commit.jpg} \caption{Selecting SVN Commit'' from the context menu.} \label{fig:tortoise_svn_commit} \includegraphics[width=0.70\textwidth]{figures/tortoise_svn_accessing_settings.jpg} \caption{Getting to the TortoiseSVN settings.} \label{fig:tortoise_svn_accessing_settings} \end{figure} \clearpage \noindent The settings window will look something like this: \begin{figure}[h!] \centering \includegraphics[width=0.90\textwidth]{figures/tortoise_svn_ignore_patterns.jpg} \caption{The TortoiseSVN settings window with the proper ignore pattern.} \label{fig:tortoise_svn_ignore_patterns} \end{figure} You can use command words in the SVN comment to link your changes to a particular ticket. The command syntax is as follows: \begin{center} \fbox{\parbox{15cm} {\tt command \#1\newline command \#1, \#2\newline command \#1 \& \#2\newline command \#1 and \#2 }} \end{center} You can have more than one command in a message. The following commands are supported. There is more than one spelling for each command, to make this as user-friendly as possible. \begin{center} \fbox{\parbox{15cm} {\tt closes, fixes:\newline The specified issue numbers are closed with the contents of this commit message being added to it. references, refs, addresses, re:\newline The specified issue numbers are left in their current status, but the contents of this commit message are added to their notes. }} \end{center} A fairly complicated example of what you can do is with a commit message of: \begin{center} \fbox{\parbox{15cm} {\tt Changed blah and foo to do this or that.\ Fixes \#10 and \#12, and refs \#12. }} \end{center} This will close \#10 and \#12, and add a note to \#12. \subsection{Ignore patterns} \label{IgnorePatterns} Please only check in proper source code by using the following \textbf{ignore patterns}: \noindent Then in the \textit{Global ignore pattern} field, please enter the following text: \begin{center} \end{center} This basically means that you should never check in compiled and automatically generated files. For example, please do not check in the entire \textit{bin/} and \textit{obj/} directories that Visual Studio generates. Note that the server will reject your commits if you try to do so. If you want to submit a component (binary file) despite the ignore patterns you can still add \textit{*.dll} files by using the context menu and adding the file explicitly - but please be absolutely sure that you know what you are doing. Additionally, you need to provide an explicit list of file and directory names which should override the ignore pattern. For example, if you want to check in a file named someLib.dll, you must write a comment which looks like this: You are free to also leave in any default pattern text or to write your own additions; this pattern serves simply to tell TortoiseSVN what kinds of files to ignore. You can now click \textit{OK} to save your settings and close the window. \clearpage \subsection{Committing your changes} \label{CommitingYourChanges} Once you start writing code and developing your plugin, you should check your work into the project repository. If you are reading this document in sequence, you are probably not ready to do this, but while we are on the topic of SVN we will describe the process. To upload your changes, right-click on a directory within the working files that contains your changes and select \textit{SVN Commit} from the context menu: \begin{figure}[h!] \centering \includegraphics[width=0.40\textwidth]{figures/tortoise_svn_commit.jpg} \caption{Selecting \textit{SVN Commit} from the context menu.} \label{fig:tortoise_svn_commit} \end{figure} \clearpage When you commit your code, you can leave a comment to describe what you have changed. Please always provide \textit{meaningful descriptions} of your updates. You can also select exactly which files you want to check in. The ignore pattern that we recommended should prevent most undesirable files from being in the list, but double-check to make sure everything you want to upload is included but nothing more. In general, you should never check in compiled and automatically generated files. For example, do not check in the entire \textit{bin\textbackslash } and \textit{obj\textbackslash } directories that Visual Studio generates. The server will reject your commits if you try to do so. You should commit your sources to our SVN repository as often as you can, but only commit code that successfully compiles and runs! \begin{figure}[h!] \centering \includegraphics[width=0.70\textwidth]{figures/tortoise_svn_commit2.jpg} \caption{Providing comments for a commit.} \label{fig:tortoise_svn_commit2} \end{figure} You can use the SVN comments to link to your changes to a particular issue or bug ticket on the CrypTool 2 development wiki. (The list of active tickets can be found \href{https://www.cryptool.org/trac/CrypTool2/report/1}{here}.) The following commands are supported (note that there are multiple variations of each command that are functionally identical): \begin{center} \fbox{\parbox{15cm} { \texttt{closes, fixes:} The specified ticket will be closed and the contents of this commit message will be added to its notes.\\ \texttt{references, refs, addresses, re:} The contents of this commit message will be added to the specified ticket's notes, but the status will be left unaltered. }} \end{center} \clearpage You can apply the commands to multiple tickets simultaneously. The command syntax is as follows (again note that there are multiple variations that are functionally identical): \begin{center} \fbox{\parbox{15cm} {\tt The lib is required by all developers, so I am adding it explicitly to the repository. command \#1\\ command \#1, \#2\\ command \#1 \& \#2\\ command \#1 and \#2 }} \end{center} You can also use more than one command in a message if necessary. For example, if you want to close tickets \#10 and \#12, and add a note to \#17, you could type the following: \begin{center} \fbox{\parbox{15cm} {\tt Changed blah and foo to do this or that.\ Fixes \#10 and \#12, and refs \#17. }} \end{center} The comments can also be used to override the ignore pattern that the server is designed to block. However, please do not do this unless you are absolutely sure that you know what you are doing. If you are, you must use the \textit{override-bad-extension} command and provide an explicit list of the file and directory names that you want to upload that need to override the ignore pattern. For example, if you want to check in a library file named \textit{someLib.dll}, you must write something like the following: \begin{center} \fbox{\parbox{15cm} {\tt This library is required by all developers, so I am adding it explicitly to the repository.\\\\ override-bad-extension:\ someLib.dll }} \end{center} Please note that any text after the colon and the whitespace will be treated as the file name. Therefore, do not use quotation marks and do not write any text after the file name. \clearpage Note that any text after the colon and the whitespace will be treated as the file name. Therefore, do not use quotation marks and do not write any text after the file name. \section{Compiling the sources} \label{CompilingTheSources} By this point you should have checked out a copy of the entire CrypTool repository. Compiling is pretty easy; just go to the \textit{trunk/} directory and open the \textbf{\textit{CrypTool 2.0.sln}} Visual Studio solution. The Visual Studio IDE should open with all the working plugins components nicely arranged. In case you are now starting Visual Studio for the first time, you will have to choose your settings. Just select either most common'' or C\#'' --- you can change this at any time later. On the right side is the project explorer, where you can see all the subprojects included in the solution. Look for the project \textbf{\textit{CrypWin.exe}} there. Once you have found it, right-click on it and select Set as StartUp-Project'' from the context menu. Next, go to the menu bar and select Build'' $\rightarrow$ Build Solution''. By this point you should have checked out a copy of the entire CrypTool repository. Compiling is pretty easy; just go to the \textit{trunk\textbackslash } directory and open the \textbf{\textit{CrypTool 2.0.sln}} Visual Studio solution. The Visual Studio IDE should open with all the working plugin components nicely arranged. If you are now starting Visual Studio for the first time, you will have to choose your settings. Just select either \textit{most common} or \textit{C\#} --- you can change this at any time later. On the right side is the project explorer, where you can see all the subprojects included in the solution. Look for the project \textbf{\textit{CrypWin.exe}} there. Once you have found it, right-click on it and select \textit{Set as StartUp Project} from the context menu. Next, go to the menu bar and select \textit{Build $\rightarrow$ Build Solution}. Then go to Debug'' and select Start Debugging''. CrypTool 2.0 should now start for the first time with your own compiled code. Presumably you have not changed anything yet, but you now have your own build of all the components (with the exception of CrypWin and AnotherEditor, since they are available only as binaries). If the program does not compile or start correctly, please consult our \href{https://www.cryptool.org/trac/CrypTool2/wiki/FAQ}{FAQ} and let us know if you found a bug. You may have to wait a while for the program to compile. Once it is finished, select \textit{Debug $\rightarrow$ Start Debugging}. CrypTool 2.0 should now start for the first time with your own compiled code. Presumably you have not changed anything yet, but you now have your own build of all the components (with the exception of \textit{CrypWin} and \textit{AnotherEditor}, since they are available only as binaries). If the program does not compile or start correctly, please consult our \href{https://www.cryptool.org/trac/CrypTool2/wiki/FAQ}{FAQ} and let us know if you found a bug. If you are a \textbf{core developer}, hence somebody who can also compile CryWin and AnotherEditor, you should use the \textbf{\textit{CrypTool 2.0.sln}} solution from the \textit{trunk/CoreDeveloper/} directory (which will \textit{not} be visible to you if you are not a core developer). As a core developer, be aware that when you compile, you \textbf{change the \textit{CryWin.exe}} that is visible to everybody else. Thus, when doing a check-in, please make sure you \textit{really} want to check in a new binary. Core developers can also build a new setup and publish it as beta release on the website. This process is explained in the wiki at \url{https://www.cryptool.org/trac/CrypTool2/wiki/BuildSetup}. If you are a \textbf{core developer}, hence somebody who can also compile CryWin and AnotherEditor, you should use the \textbf{\textit{CrypTool 2.0.sln}} solution from the \textit{trunk\textbackslash CoreDeveloper\textbackslash } directory (which will \textit{not} be visible to you if you are not a core developer). As a core developer, be aware that when you compile, you \textbf{change the \textit{CryWin.exe}} that is visible to everybody else. Thus, when committing to the repository, please make sure you \textit{really} want to check in a new binary. Core developers can also build a new setup and publish it as beta release on the website. This process is explained in the wiki at \url{https://www.cryptool.org/trac/CrypTool2/wiki/BuildSetup}.
 r1231 \chapter{Plugin Implementation} \label{sec:PluginImplementation} In this chapter we provide step-by-step instructions for implementing your own CrypTool 2.0 plugin. The given instructions refer mostly to the usage of the Visual C\# Express and Visual Studio Professional 2008 editions, so before starting you should have a copy of \textbf{Microsoft Visual Studio 2008} (or \textbf{Microsoft Visual C\# 2008 Express Edition}) installed on your computer. We will use the \textbf{Caesar cipher} (also known as the \textbf{shift cipher}) for our example implemenation. In this chapter we provide step-by-step instructions for implementing your own CrypTool 2.0 plugin. The given instructions refer primarily to the usage of the Visual C\# Express and Visual Studio Professional 2008 editions, so before starting you should have a copy of \textbf{Microsoft Visual Studio 2008} (or \textbf{Microsoft Visual C\# 2008 Express Edition}) installed on your computer. We will use the \textbf{Caesar cipher} (also known as the \textbf{shift cipher}) as an example throughout this chapter. \section{Creating a new project} \label{sec:CreatingANewProject} To begin, open Visual Studio, go to the menu bar and select File''~$\rightarrow$ New'' $\rightarrow$ Project\ldots ''. The following window will appear: To begin, open Visual Studio, go to the menu bar and select \textit{File~$\rightarrow$ New $\rightarrow$ Project\ldots }. The following window will appear: \begin{figure}[h!] \end{figure} \noindent If you are using Visual Studio 2008, select \textbf{.NET-Framework 3.5''} as the target framework; the Express Edition will automatically choose the target framework. Then choose \textbf{Class Library''} as the default template, as this will build the project for your plugin as a DLL file. Give the project a unique and meaningful name (such as Caesar'' in our case), and choose a location to save it to. (The Express Edition will ask for a save location later when you close your project or environment). Select the subdirectory CrypPlugins'' from your SVN trunk as the location. Finally, confirm by pressing the OK'' button. Note that creating a new project in this manner also creates a new solution into which the project is placed. \noindent If you are using Visual Studio 2008, select \textbf{\textit{.NET-Framework 3.5}} as the target framework; the Express Edition will automatically choose the target framework. Then choose \textit{Class Library} as the default template, as this will build the project for your plugin as a DLL file. Give the project a unique and meaningful name (such as \textit{Caesar} in our case), and choose a location to save it to. (The Express Edition will ask for a save location later when you close your project or environment). Select the subdirectory \textit{CrypPlugins} from your SVN trunk as the location. Finally, confirm by pressing the \textit{OK} button. Note that creating a new project in this manner also creates a new solution into which the project is placed. \begin{figure}[h!] \centering \includegraphics[width=0.80\textwidth]{figures/save_solution_csharp_express.JPG} \caption{The Visual Studio C\# Express Edition Save Project'' dialog window.} \caption{The Visual Studio C\# Express Edition \textit{Save Project} dialog window.} \label{fig:save_solution_csharp_express} \end{figure} \noindent At this point, your Visual Studio\slash C\# Express solution should look like this: \noindent At this point, your Visual Studio solution should look like this: \begin{figure}[h!] \label{sec:InterfaceSelection} To include our new plugin in the CrypTool program, we must first add a reference to the CrypTool library, \textbf{\textit{CrypPluginBase.dll}}, where all the necessary CrypTool plugin interfaces are declared. To include our new plugin in the CrypTool 2 application, we must first add a reference to the CrypTool 2 library \textbf{\textit{CrypPluginBase.dll}}, where all the necessary CrypTool 2 plugin interfaces are declared. \begin{figure}[h!] \end{figure} \noindent Right-click in the Solution Explorer on the Reference'' item and choose Add Reference''. A window like the following should appear: \noindent Right-click in the Solution Explorer on the \textit{Reference} item and choose \textit{Add Reference}. A window like the following should appear: \begin{figure}[h!] \centering \includegraphics{figures/add_pluginbase_source.jpg} \caption{Adding a reference to the PluginBase source code.} \caption{Adding a reference to the CrypPluginBase source code.} \label{fig:add_pluginbase_source} \end{figure} \clearpage \noindent Unless you have created your new project in the same CrypTool 2.0 solution, you probably will not be able to select the library directly as seen above in Figure \ref{fig:add_pluginbase_source}; instead you can browse for the binary DLL as seen below in Figure \ref{fig:browse_reference}. Click on the Browse'' tab and navigate to the folder in which you downloaded the CrypTool 2 project. Within that folder, go to \textit{\textbackslash CrypPluginBase\textbackslash bin\textbackslash Debug} and select the file CryptPluginBase.dll''. The library reference can then be added by double clicking the file or pressing the OK'' button. Unless you have created your new project in the same CrypTool 2.0 solution, you probably will not be able to select the library directly as seen above in Figure \ref{fig:add_pluginbase_source}; instead you can browse for the binary DLL as seen below in Figure \ref{fig:browse_reference}. Click on the \textit{Browse} tab and navigate to the folder in which you downloaded the CrypTool 2 project. Within that folder, go to \textit{\textbackslash CrypPluginBase\textbackslash bin\textbackslash Debug} and select the file \textit{CrypPluginBase.dll}. The library reference can then be added by double clicking the file or pressing the \textit{OK} button. \begin{figure}[h!] \end{figure} \noindent Besides CrypPluginBase you will need to add three Windows assembly references to provide the necessary namespaces for the \textbf{user control} functions Presentation'' and QuickWatchPresentation''. This can be done in a similar manner as before with the CrypPluginBase'' reference, but by selecting the .NET'' tab and searching for the references there. Select the following .NET components: Besides CrypPluginBase you will need to add three Windows assembly references to provide the necessary namespaces for the user control functions \textit{Presentation} and \textit{QuickWatchPresentation}. This can be done in a similar manner as before with the \textit{CrypPluginBase} reference, but by selecting the \textit{.NET} tab and searching for the references there. Select the following .NET components: \textit{ \begin{itemize} \item PresentationCore \item PresentationFramework \item WindowsBase \end{itemize} \clearpage \noindent Afterwards your reference tree view should look like this: \end{itemize}} \clearpage \noindent After these additions, your reference tree view should look like this: \begin{figure}[h!] \end{figure} \noindent If your plugin will be based on other additional libraries, you can add them in the same way. \noindent If your plugin will require other additional libraries, you can add them in the same way. \section{Modifing the project properties} \label{sec:ModifyTheProjectProperties} It is important to make two small changes to your plugin's assembly data to make sure that it will be imported correctly into CrypTool 2. Go to the Solution Explorer and open AssemblyInfo.cs'', which can be found in the Properties'' folder. Make the following two changes: It is important to make two small changes to your plugin's assembly data to make sure that it will be imported correctly into CrypTool 2. Go to the Solution Explorer and open \textit{AssemblyInfo.cs}, which can be found in the \textit{Properties} folder. Make the following two changes: \begin{itemize} \item Change the attribute AssemblyVersion'' to have the value 2.0.*'', and \item Comment out the attribute AssemblyFileVersion''. \item Change the attribute \textit{AssemblyVersion} to have the value "2.0.*", and \item Comment out the attribute \textit{AssemblyFileVersion}. \end{itemize} \label{sec:CreatingClassesForTheAlgorithmAndItsSettings} In the next step we will create two classes. The first class will be the main driver; we will call ours Caesar'' since that is the name of the cipher that it will implement. In our case, this class has to inherit from IEncryption because it will be an encryption plugin. If it was instead a hash plugin, this class should inherit from IHash. The second class will be used to store setting information for the plugin, and thus we will name ours CaesarSettings''. It will need to inherit from ISettings. In the next step we will create two classes. The first class will be the main driver; we will call ours \textit{Caesar} since that is the name of the cipher that it will implement. In our case, this class has to inherit from \textit{IEncryption} because it will be an encryption plugin. If it was instead a hash plugin, this class should inherit from \textit{IHash}. The second class will be used to store setting information for the plugin, and thus we will name ours \textit{CaesarSettings}. It will need to inherit from \textit{ISettings}. \clearpage \label{sec:CreatingAClassForTheAlgorithm} When starting a new project, Visual Studio automatically creates a class which has the name Class1.cs''.  Since this is a rather non-descriptive name, we will change it. In our example, it should be Caesar.cs''. There are two ways to change the name: When starting a new project, Visual Studio automatically creates a class named \textit{Class1.cs}. Since this is a rather non-descriptive name, we will change it. In our example, it will be \textit{Caesar.cs}. There are two ways to change the name: \begin{itemize} %\clearpage \noindent Both options will achieve the same results. We will guide you through the second method. First, delete Class1.cs''. \noindent Both options will achieve the same results. We will guide you through the second method. First, delete \textit{Class1.cs}. \begin{figure}[h!] \clearpage \noindent Then right-click on the project item (in our case, Caesar'') and select Add $\rightarrow$ Class\ldots '': \noindent Then right-click on the project item (in our case, \textit{Caesar}) and select \textit{Add $\rightarrow$ Class\ldots }: \begin{figure}[h] \clearpage \noindent Finally, give your class a unique name. We will call our class Caesar.cs'' and define it as public so that it will be available to other classes. \noindent Finally, give your class a unique name. We will call our class \textit{Caesar.cs} and define it as public so that it will be available to other classes. \begin{figure}[h!] \end{figure} \noindent Visual Studio will automatically generate a basic code outline for the new class. In our example, we will not use the all the namespaces that are automatically imported, so you can delete the lines \texttt{using System;} and \texttt{using System.Linq;}. Note that Visual Studio will automatically generate a very basic code outline for the new class. In our example, we will not use the all the namespaces that are automatically imported, so you can delete the lines \texttt{using System;} and \texttt{using System.Linq;}. \subsection{Creating a settings class} \label{sec:CreatingASettingsClass} Add a second public class in the same way. We will call the class CaesarSettings''. The settings class stores the necessary information about controls, captions, descriptions and default parameters (e.g.\ for key settings, alphabets, key length and type of action) to build the \textbf{TaskPane} in the CrypTool application. Add a second public class in the same way. We will call the class \textit{CaesarSettings}. The settings class will store the necessary information about controls, captions, descriptions and default parameters (e.g.\ for key settings, alphabets, key length and type of action) to build the \textbf{TaskPane} in the CrypTool application. \clearpage \label{sec:AddingTheNamespacesAndInheritanceSourcesForTheCaesarClass} Open the Caesar.cs'' file by double clicking on it in the Solution Explorer. To include the necessary namespaces in the class header, use the using'' statement followed by the name of the desired namespace. The CrypTool 2.0 API provides the following namespaces: Open the \textit{Caesar.cs} file by double clicking on it in the Solution Explorer. To include the necessary namespaces in the class header, use the \texttt{using} statement followed by the name of the desired namespace. The CrypTool 2 API provides the following namespaces: \begin{itemize} \item Cryptool.PluginBase --- contains interfaces such as IPlugin, IHash, and ISettings, as well as attributes, enumerations, delegates and extensions. \item Cryptool.PluginBase.Analysis --- contains interfaces for cryptanalysis plugins (such as Stream Comparator''). \item Cryptool.PluginBase.Control --- contains global interfaces for the IControl feature for defining custom controls. \item Cryptool.PluginBase.Cryptography --- contains interfaces for encryption and hash algorithms such as AES, DES and MD5. \item Cryptool.PluginBase.Editor --- contains interfaces for editors that can be implemented in CrypTool 2.0, such as the default editor. \item Cryptool.PluginBase.Generator --- contains interfaces for generators, including the random input generator. \item Cryptool.PluginBase.IO --- contains interfaces for input, output and the CryptoolStream. \item Cryptool.PluginBase.Miscellaneous --- contains assorted helper classes, including \textit{GuiLogMessage} and \textit{PropertyChanged}. \item Cryptool.PluginBase.Resources --- used only by CrypWin and the editor; not necessary for plugin development. \item Cryptool.PluginBase.Tool --- contains an interface for all external tools implemented by CrypTool 2.0 that do not entirely support the CrypTool 2.0 API. \item Cryptool.PluginBase.Validation --- contains interfaces for validation methods, including regular expressions. \item \textit{Cryptool.PluginBase} --- contains interfaces such as \textit{IPlugin}, \textit{IHash}, and \textit{ISettings}, as well as attributes, enumerations, delegates and extensions. \item \textit{Cryptool.PluginBase.Analysis} --- contains interfaces for cryptanalysis plugins (such as \textit{Stream Comparator}). \item \textit{Cryptool.PluginBase.Control} --- contains global interfaces for the \textit{IControl} feature for defining custom controls. \item \textit{Cryptool.PluginBase.Cryptography} --- contains interfaces for encryption and hash algorithms such as AES, DES and MD5. \item \textit{Cryptool.PluginBase.Editor} --- contains interfaces for editors that can be implemented in CrypTool 2, such as the default editor. \item \textit{Cryptool.PluginBase.Generator} --- contains interfaces for generators, including the random input generator. \item \textit{Cryptool.PluginBase.IO} --- contains interfaces for input, output and the \textit{CryptoolStream}. \item \textit{Cryptool.PluginBase.Miscellaneous} --- contains assorted helper classes, including \textit{GuiLogMessage} and \textit{PropertyChanged}. \item \textit{Cryptool.PluginBase.Resources} --- used only by CrypWin and the editor; not necessary for plugin development. \item \textit{Cryptool.PluginBase.Tool} --- contains an interface for all external tools implemented by CrypTool~2 that do not entirely support the CrypTool 2 API. \item \textit{Cryptool.PluginBase.Validation} --- contains interfaces for validation methods, including regular expressions. \end{itemize} \begin{itemize} \item Cryptool.PluginBase --- to implement ISettings in the CaesarSettings class. \item Cryptool.PluginBase.Cryptography --- to implement IEncryption in the Caesar class. \item Cryptool.PluginBase.IO --- to use CryptoolStream for data input and output. \item Cryptool.PluginBase.Miscellaneous --- to use the CrypTool event handler. \item \textit{Cryptool.PluginBase} --- to implement \textit{ISettings} in the CaesarSettings class. \item \textit{Cryptool.PluginBase.Cryptography} --- to implement \textit{IEncryption} in the Caesar class. \item \textit{Cryptool.PluginBase.IO} --- to use CryptoolStream for data input and output. \item \textit{Cryptool.PluginBase.Miscellaneous} --- to use the CrypTool event handler. \end{itemize} \noindent It is important to define a new default namespace for our public class (Caesar''). In CrypTool 2.0  the standard namespace convention is \textit{Cryptool.[name of class]}. Therefore our namespace will be defined as \textit{Cryptool.Caesar}.\clearpage \noindent It is important to define a new default namespace for our public class (\textit{Caesar}). In CrypTool 2  the standard namespace convention is \textit{Cryptool.[name of class]}. Therefore our namespace will be defined as \textit{Cryptool.Caesar}.\clearpage \noindent At this point, the source code should look like the following: \ \\ % ugly but functional \noindent Next we should let the Caesar'' class inherit from IEncryption by making the following alteration: \noindent Next we should let the \textit{Caesar} class inherit from \textit{IEncryption} by making the following alteration: \begin{lstlisting} \label{sec:AddingControlsToTheCaesarSettingsClass} The settings class is used to populate the TaskPane in the CrypTool 2 application so that the user can modify settings at will. To meet these ends we will need to implement some controls such as buttons and text boxes. If you will be implementing an algorithm that does not have any user-defined settings (e.g. a hash function), then this class can be left empty; you will, however, still have to modify the HasChanges'' property to avoid a NotImplementedException''. The following code demonstrates the modifications necessary to create the backend for the TaskPane for our Caesar algorithm. You can also look at the source code of other algorithms in the subversion repository for examples of how to create the TaskPane backend.\\ The settings class is used to populate the TaskPane in the CrypTool 2 application so that the user can modify settings at will. To meet these ends we will need to implement some controls such as buttons and text boxes. If you will be implementing an algorithm that does not have any user-defined settings (i.e.\ a hash function), then this class can be left empty; you will, however, still have to modify the HasChanges'' property to avoid a NotImplementedException''. The following code demonstrates the modifications necessary to create the backend for the TaskPane for our Caesar algorithm. You can also look at the source code of other algorithms in the subversion repository for examples of how to create the TaskPane backend.\\ \begin{lstlisting} /// /// Returns true if any settings have been changed. /// This value should be set externally to false e.g. /// This value should be set externally to false, i.e. /// when a project is saved. /// These attributes can be defined anywhere within the Cryptool.Caesar'' namespace, but customarily they are defined right before the class declaration. \subsection{The \textit{[Author]} attribute} \subsection{The \protect\textit{[Author]} attribute} \label{sec:TheAuthorAttribute} %\end{figure} \subsection{The \textit{[PluginInfo]} attribute} \subsection{The \protect\textit{[PluginInfo]} attribute} \label{sec:ThePluginInfoAttribute} \begin{itemize} \item Resource File --- defines where to find the associated resource file, if one is to be implemented. These are used, for example, to provide multilingual support for the plugin. This element is optional. \item Startable --- a flag that should be set to true only if the plugin is an input generator plugin (i.e. if your plugin only has outputs and no inputs). In all other cases this should be set to false. This flag is important --- setting it incorrectly will result in unpredictable results. This element is mandatory. \item Startable --- a flag that should be set to true only if the plugin is an input generator plugin (i.e.\ if your plugin only has outputs and no inputs). In all other cases this should be set to false. This flag is important --- setting it incorrectly will result in unpredictable results. This element is mandatory. \item Caption --- the name of the plugin or, if the caption is specified in a resource file, the name of the appropriate field in the resource file. This element is mandatory. \item ToolTip --- a description of the plugin or, if the tool tip is specified in a resource file, the name of the appropriate field in the resource file. This element is optional. \item DescriptionURL --- defines where to find the description file (e.g. XAML file). This element is optional. \item Icons --- an array of strings to define all the paths for the icons to be used in the plugin (i.e. the plugin icon described in section \ref{sec:AddingAnIconToTheCaesarClass}). This element is mandatory. \item DescriptionURL --- defines where to find the description file (e.g.\ XAML file). This element is optional. \item Icons --- an array of strings to define all the paths for the icons to be used in the plugin (i.e.\ the plugin icon described in Section \ref{sec:AddingAnIconToTheCaesarClass}). This element is mandatory. \end{itemize} If your plugin will use additional icons, you should define the paths to each of them by adding the path strings to the \textit{[PluginInfo]} attribute parameter list, each separated by a comma. We have added two further icons for the context menu in the CrypTool 2 workspace. (If you do choose to add more icons, don't forget to add the icons to your solution.) \subsection{The \textit{[EncryptionType]} attribute} \subsection{The \protect\textit{[EncryptionType]} attribute} \label{sec:TheEncryptionTypeAttribute} \begin{itemize} \item Asymmetric --- for asymmetrical encryption algorithms, such as RSA. \item SymmetricBlock --- for block cipher algorithms, such as DES, AES and Twofish. \item SymmetricStream --- for stream cipher algorithms, such as RC4, Rabbit and SEAL. \item Hybrid --- for algorithms which are actually a combination of several algorithms, such as algorithms in which the data is encrypted symmetrically and the encryption key asymmetrically. \item Classic --- for classical encryption or hash algorithms, such as Caesar or MD5. \item Hybrid --- for algorithms which are actually a combination of several algorithms, such as algorithms in which the data is encrypted symmetrically and the encryption key asymmetrically. \item SymmetricBlock --- for block cipher algorithms, such as DES, AES and Twofish. \item SymmetricStream --- for stream cipher algorithms like RC4, Rabbit and SEAL. \end{itemize} \ \\ % ugly but functional If your algorithm works with longs strings of code, it is recommended to use the CryptoolStream'' data type. This was designed for input and output between plugins and to handle large amounts of data. To use the native CrypTool stream type, include the namespace Cryptool.PluginBase.IO'' with a using'' statement as explained in section \ref{sec:AddingTheNamespacesAndInheritanceSourcesForTheCaesarClass}. If your algorithm works with longs strings of code, it is recommended to use the CryptoolStream'' data type. This was designed for input and output between plugins and to handle large amounts of data. To use the native CrypTool stream type, include the namespace Cryptool.PluginBase.IO'' with a using'' statement as explained in Section \ref{sec:AddingTheNamespacesAndInheritanceSourcesForTheCaesarClass}. The following private variables will be used in our example: \begin{itemize} \item direction --- defines whether this property is an input or output property, i.e., whether it reads input data or writes output data. The possible values are: \item direction --- defines whether this property is an input or output property, e.g.\ whether it reads input data or writes output data. The possible values are: \begin{itemize} \item Direction.Input \item mandatory --- this flag determines whether an input must be attached by the user to use the plugin. If set to true, an input connection will be required or else the plugin will not be executed in the workflow chain. If set to false, connecting an input is optional. As this only applies to input properties, if the direction has been set to output'', this flag will be ignored. \item hasDefaultValue --- if this flag is set to true, CrypTool 2 will assume that the property has a default input value that does not require user input. \item displayLevel --- determines in which display levels your property will be shown in CrypTool 2. These are used to hide more advanced item from less-experienced users; a Beginner will not see the properties marked as any other level, but a Professional will have access to everything. The display levels are as follows: \item displayLevel --- determines in which display levels your property will be shown in CrypTool 2. These are used to hide more advanced item from less-experienced users; a beginner using the corresponding display level will not see the properties marked as any other level, but a professional using the appropriate display level will have access to everything. These levels are as follows: \begin{itemize} \textit{username: anonymous\\ password:} (not required)\\ \htmladdnormallink{https://www.cryptool.org/svn/CrypTool2/trunk/CrypPlugins/Caesar/}{https://www.cryptool.org/svn/CrypTool2/trunk/CrypPlugins/Caesar/}\\\\ \url{https://www.cryptool.org/svn/CrypTool2/trunk/CrypPlugins/Caesar/}\\\\ We have also created a Visual Studio plugin template to help with the development of new plugins. This can be found here:\\\\ \htmladdnormallink{http://cryptool2.vs.uni-due.de/downloads/template/encryptionplugin.zip}{http://cryptool2.vs.uni-due.de/downloads/template/encryptionplugin.zip} \url{http://cryptool2.vs.uni-due.de/downloads/template/encryptionplugin.zip} \clearpage