Article View: microsoft.public.dotnet.framework.compactframework
Article #1Blowfish encryption between languages and platforms
From: Zief
Date: Tue, 08 Aug 2006 15:50
Date: Tue, 08 Aug 2006 15:50
48 lines
3089 bytes
3089 bytes
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
Technical Details
Message-ID:
<1155052216.205586.301090@b28g2000cwb.googlegroups.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!postnews.google.com!b28g2000cwb.googlegroups.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: f46f5,96fde92e6c2915f4,start X-Google-Thread: f894d,96fde92e6c2915f4,start X-Google-Attributes: gidf46f5,gidf894d,public X-Google-Language: ENGLISH,ASCII-7-bit Path: arc1-ca.pugleaf.net!g2news2.google.com!postnews.google.com!b28g2000cwb.googlegroups.com!not-for-mail From: "Zief" <zieftech@gmail.com> Newsgroups: microsoft.public.dotnet.framework.compactframework,borland.public.delphi Subject: Blowfish encryption between languages and platforms Date: 8 Aug 2006 08:50:16 -0700 Organization: http://groups.google.com Lines: 49 Message-ID: <1155052216.205586.301090@b28g2000cwb.googlegroups.com> NNTP-Posting-Host: 84.92.26.185 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1155052221 26388 127.0.0.1 (8 Aug 2006 15:50:21 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 8 Aug 2006 15:50:21 +0000 (UTC) User-Agent: G2/0.2 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.6) Gecko/20060728 Firefox/1.5.0.6,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: b28g2000cwb.googlegroups.com; posting-host=84.92.26.185; posting-account=bqNMFw0AAADTJfGyn8ep2eL1K_1gxoM-