Click here to Skip to main content
12,886,913 members (36,128 online)
Click here to Skip to main content
Add your own
alternative version


76 bookmarked
Posted 24 Oct 2012

XCrypt - encryption & decryption class wrapper

, 25 Oct 2012 CPOL
Rate this:
Please Sign up or sign in to vote.
This is an alternative for "XCrypt - encryption & decryption class wrapper"
This is an old version of the currently published article.


This article is built on top of 'XCrypt' -- the legendary cryptography wrapper which had been around in CodeProject for a while.   Unfortunately the original author of the article has left the same unattended for several years.  I brought the same to the attention of CP Team vide and as per the guidance I am submitting this alternative branch. 

XCrypt helps as a generic encryption and decryption wrapper for .NET applications. Besides the same, it adds the following two algorithms (which are not part of .NET Base Class Library):

  • Blowfish
  • Twofish 
 As of this writing, I did have an observation of another algorithm called 'Blakesharp' ( I have taken a humble initiative to get XCrypt update in having able to use this algorithm too. 


  1. Basic Concepts, BlowFish, TwoFish:  Credits to the parent XCrypt
  2. Blakesharp: 

Using the code

The sample code initializes the engine to 3DES, you also can call InitializeEngine again to reset the engine to a different algorithm. 

<pre lang="cs" id="pre0" style="white-space: pre-wrap; word-wrap: break-word; margin-removed 0px; ">XCryptEngine xe = new XCryptEngine();

enc_str = xe.Encrypt(src_str);
dec_str = xe.Decrypt(enc_str);


Points of Interest

  1. XCrypt earns the credit of making me learn different encryption algorithms besides kindling interest to explore on the same. 
  2. .NET has a good cryptography library but the paucity of documentation in MSDN as an end-to-end solution makes you run pillar to post whilst trying to decide on a particular algorithm. XCrypt endeavors to fulfill the gap. 


The following are the changes from its parent (XCrypt): 

  1. Included the two BlakeSharp algorithm into XCrypt as I had highlighted. 
  2. The Test Application had hard-coded 'This is a test string' as the initial value'. To make it a  bit more realistic I have replaced that with srcText.Text = Environment.UserName.Length > 0 ? Environment.UserName : "Hello World";
  3. The Test Application had bloated piece of code that the Algorithm Names were repeatedly hard-bound. I have tried replacing the same with a quick and small reflection code (LoadEnumMembers())
  4. The Test Application had a bug that for Hash where decryption would not be possible. Hence I have changed this by exposing two more public methods disabling Decrypt button for the same.  
  5. I have removed the setup and other project which might not be of utility value for lot of users. 


  1. First Update Built on XCrypt in a humble endeavor to make it a one-stop lookup for cryptography library in .NET 
  2. Added a quick clipboard support to the application. 


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Vasudevan Deepak Kumar
Software Developer
India India
Vasudevan Deepak Kumar is from Chennai, India who has been in the programming career since 1994, when he was 15 years old. He has his Bachelors of Engineering (in Computer Science and Engineering) from Vellore Engineering College. He also has a MBA in Systems from Alagappa University, Karaikudi, India.
He started his programming career with GWBasic and then in his college was involved in developing programs in Fortran, Cobol, C++. He has been developing in Microsoft technologies like ASP, SQLServer 2000.
His current focus is ASP.NET, C#, VB.NET, PHP, SQL Server and MySQL. In his past-time, he listens to polite Carnatic Music. But the big question is that with his current Todolist backlog, does he get some past time?

You may also be interested in...

Comments and Discussions

Discussions posted for the Published version of this article. Posting a message here will take you to the publicly available article in order to continue your conversation in public.
PraiseThank you! Fills my needs perfectly. I did make one change, though... Pin
Mark Miller15-Feb-17 11:02
memberMark Miller15-Feb-17 11:02 
QuestionDoes not work if you need Blowfish ECB mode Pin
angusmf29-Jan-16 9:48
memberangusmf29-Jan-16 9:48 
GeneralMy vote of 4 Pin
Ashutosh Phoujdar24-Jun-13 23:19
memberAshutosh Phoujdar24-Jun-13 23:19 
GeneralMy vote of 5 Pin
VitorHugoGarcia21-Mar-13 6:22
memberVitorHugoGarcia21-Mar-13 6:22 
GeneralMy vote of 4 Pin
Prasad Khandekar20-Mar-13 22:08
memberPrasad Khandekar20-Mar-13 22:08 
GeneralMy vote of 4 Pin
Shubham Choudhary20-Mar-13 20:26
memberShubham Choudhary20-Mar-13 20:26 
GeneralMy vote of 5 Pin
adriancs26-Jan-13 17:19
mvpadriancs26-Jan-13 17:19 
GeneralMy vote of 5 Pin
Edo Tzumer25-Oct-12 1:51
memberEdo Tzumer25-Oct-12 1:51 
Questionwhere is the project? Pin
Fabio Malpezzi24-Oct-12 23:29
memberFabio Malpezzi24-Oct-12 23:29 
AnswerRe: where is the project? Pin
Vasudevan Deepak Kumar25-Oct-12 0:05
memberVasudevan Deepak Kumar25-Oct-12 0:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170424.1 | Last Updated 25 Oct 2012
Article Copyright 2012 by Vasudevan Deepak Kumar
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid