Click here to Skip to main content
Click here to Skip to main content

Tagged as

Blowfish Encryption Implementation in .NET

, 21 May 2012 CPOL
Rate this:
Please Sign up or sign in to vote.
Blowfish encryption is very popular for encrypting data but its really hard to find a simple .net implementation of this algorithm. This articles tries to solve this problem.

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 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.


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


About the Author

Ravinder Singh, PMP
Technical Lead The Smart Cube, India
India India
Ravinder is an experienced software developer and project manager having around 8.5 years of experience in software development field. He has done Bachelor of Engineering and Post Graduate Diploma with Information Technology as major. He is PMP certified professional from PMI, USA. He likes to code in .Net specifically for window based applications. Currently he is associated with The Smart Cube, Noida, India as Associate Project Manager.

Comments and Discussions

Questiondear sir, have you tried to encrypt a text file using blowfish ? Pinmemberzhangdf1129-Apr-14 7:56 
AnswerRe: dear sir, have you tried to encrypt a text file using blowfish ? PinmemberRavinder Singh, PMP30-Apr-14 8:46 
GeneralRe: dear sir, have you tried to encrypt a text file using blowfish ? Pinmemberzhangdf1130-Apr-14 17:07 
Questioni got an error PinmemberMember 968398326-Dec-13 20:44 
QuestionError on using [modified] PinmemberMember 1037612110-Dec-13 5:22 
AnswerRe: Error on using PinmemberRavinder Singh, PMP10-Dec-13 7:10 
GeneralRe: Error on using [modified] PinprofessionalraoulFR10-Dec-13 8:38 
GeneralMy Vote 5 stars Pinmemberveski4a9216-Oct-13 23:02 
Questionproblem Pinmembercreativemujahid28-Apr-13 23:35 
AnswerRe: problem PinmemberRavinder Singh, PMP1-May-13 20:00 
Questionhaving trouble PinmemberAlvaro3197-Jan-13 10:24 
QuestionThank you so much ! PinmemberSamanph11-Sep-12 6:11 
Thank you so much for this tutorial. It was really easy to use and it works like a charm !
AnswerRe: Thank you so much ! PinmemberRavinder Singh, PMP11-Sep-12 7:30 
QuestionBlowfish output Pinmemberrautyog22-Jun-12 3:09 
AnswerRe: Blowfish output PinmemberRavinder Singh, PMP22-Jun-12 9:05 
Questionnot found the page PinmemberGrenseal20-May-12 22:17 
AnswerRe: not found the page PinmemberRavinder Singh, PMP21-May-12 6:39 
GeneralRe: not found the page PinmemberGrenseal21-May-12 18:15 
GeneralReason for my vote of 4 nice Pinmemberdineshkummarc18-Nov-11 0:46 
GeneralYes George, it may have been replaced but there are situatio... PinmemberRavinder Singh, PMP8-Aug-11 23:18 
GeneralHasn't Blowfish been replaced by the AES compliant ciphers s... PinmemberGeorge Swan8-Aug-11 21:21 
GeneralEdit reason: changed algo.encryptString(encryptedTxt); to al... PinmemberPraveen Kullu8-Aug-11 3:20 
GeneralReason for my vote of 5 Your tip helped me use Blowfish algo... PinmemberPraveen Kullu8-Aug-11 0:41 
GeneralRe: Thanks Praveen! Glad that it helped you. And thanks for upda... PinmemberRavinder Singh, PMP8-Aug-11 7:36 

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

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

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150331.1 | Last Updated 21 May 2012
Article Copyright 2011 by Ravinder Singh, PMP
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid