Blowfish encryption between languages and platforms

Z

Zief

Hi,

These may not be the correct places to post this message, but since I
am trying to make my Windows Mobile program decrypt strings from a
different PC Delphi program, I thought I'd start off here and if anyone
has any suggestions for posting elsewhere let me know.

Basically I have a Delphi program which is encrypting user passwords
using a blowfish algorithm taken from a free to use module called
LbCipher.pas that was originally used in TurboPower Lockbox (it seems
from the comment on the file, it is not from a project I have done).

This will take the password of "pass" (without the quotes) and return
"EEb+053WU2Q=" using the following lines of code in delphi and the key
shown:

function BlowFishString(UserStr : string) : string;
var
Key128 : TKey128;
begin
GenerateLMDKey(Key128, SizeOf(Key128), '1jkdjmc8743hj3euyd87');
Result := BFEncryptStringEx(UserStr, Key128, True);
end;

On the Windows Mobile side, I found Markus Hahn's page and am using his
BlowfishSimple class in C# to attempt to encrypt/decrypt strings. This
is where the problem appears, it may be a simple fix, but I am not
entirely sure how it all works.
The BlowfishSimple class using the following code:

// create the same key as used in the Delphi program
string tst = "1jkdjmc8743hj3euyd87";

BlowfishSimple test = new BlowfishSimple(tst);
string encrtest = test.Encrypt("pass");
string decr = test.Decrypt(encrtest);

encrtest is much bigger than "EEb+053WU2Q=" but on the last line it
decrypts fine back to "pass".

Does anyone have any idea how I can make the two compatible. Preferably
by changing the BlowfishSimple class in C# rather than the Delphi
program, as the Delphi program has already been rolled out and is in
use and would require much more effort to bring in line with the
Windows Mobile version.

Thanks in advance,
Zief
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top