Recently, while working on a project we needed a component in .Net which can encrypt/decrypt user password using Blowfish algorithm with a encryption key. We searched hard to get a ready made free .Net component to accomplish this task but found none! Finally we found a implementation hint from a article posted on igniterealtime. We took the blowfish.java file from Spark IM project and ported it to a .NET dll using ikvm, a jvm for .Net. We then referenced the dlls and used the encrypt and decrypt methods to do the required tasks.
Its very easy to implement this algorithm using attached Dlls. Download the
zip file which contains three dlls - 'Blowfish.dll', 'IKVM.OpenJDK.Core.dll', and 'IKVM.Runtime.dll'. Add reference to these three dlls in your project.
Declare the namespace on the top of the class file:
using org.jivesoftware.util;
Next, declare an instance of the Blowfish class:
Blowfish algo = new Blowfish(encryptionKey);
Next, call the appropriate method to encrypt/decrypt the text:
string encryptedTxt = algo.encryptString("this is my test string");
string decryptedTxt = algo.decryptString(encryptedTxt);
Thats it! Thats all that we have to do to implement this algorithm.
History - First publish - 03 Aug 2011.