Thursday, 17 July 2014

Openfire BlowFish Encryption/Decryption Implementation Converted From Java to C#

Have you been using Openfire and requires to create XMPP users using C# but kind of unable to encrypt/decrypt the password? Openfire is actually using blowfish for encryption/decryption of password and you can pretty much find a few blowfish implementation on C# out there. But when you actually tried to decrypt the password obtained from the Openfire database, you will notice that you will not be able to obtain the original password. This is due to Openfire implementation of blowfish is different.

So to deal with this, I have converted the blowfish class from the Openfire source project, which is in java language and you can obtain from here http://www.igniterealtime.org/downloads/source.jsp.

It is actually pretty simple to use.

Initialize with key.
Blowfish blowfish = new Blowfish("Your Key Here");

Encrypt plain text.
string cipherText = blowfish.encryptString("Your Plain Text Here");

Decrypt cipher text.
string plainText = blowfish.decryptString("Your Cipher Text Here");

Do take note that the encrypted text will always be different, but it will still be able to decrypt back to the original text.

Here's the source file in C# https://onedrive.live.com/redir?resid=E6612168B803803D!353&authkey=!AA3SEAg16NdoiZ0&ithint=file%2czip




No comments:

Post a Comment