Click here to Skip to main content
11,718,589 members (83,802 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# VC++
i have vc++ code in blowfish algorthim(this will used to develop encription and decription window) and
iam having c# code in same
Problem
For example i used VC++ code window encrypt one string like "code" output will come "1D7C499AB79E32B6"
and same i used c# window here iam getting output is different "d915ac54475662c54ca2e6bcb3ce7ddb"

but i need both results same whats problem in my code.
Posted 28-Feb-13 2:08am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
Comments
Manfred R. Bihy at 28-Feb-13 8:37am
   
That's an implementation of Blowfish in C#, but not an explanation why OP is experiencing the issues OP is seeing.
Manfred R. Bihy at 28-Feb-13 9:03am
   
OP can try that implementation (if it isn't the one that was used) and see if the differences persist.
:)
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Obviously either 1st the algorithms are implemented differently from one another or 2nd the prerequisites differ.

In the first case there's nothing much to be done except making the algorithms operate exactly the same way.
The second is most likely due to the strings being represented by a different number of bytes. The C# variant of the encoded string for instance is twice as long as the VC++ encoded variant. This could lead one to assume that the input is twice as large (in bytes) as the other (Strings in C# are UTF and not ASCII).
The case can be strengthened by trying out further strings of differing length and comparing the length of the resulting encoding. Caveat: Adjacent increments of one in length don't necessarily have different length after encoding. This is due to the fact that these algorithms often work on blocks of bytes and if a block can't be filled for lack of more characters to encode a padding will be added. So be prepared that there will be sequences of source strings with lengths of n, n+1, n+2, n+3 that will all yield an encoded string of length m, albeit with different content.

Regards,

— Manfred
  Permalink  
v3
Comments
Menon Santosh at 28-Feb-13 8:40am
   
nice Explanation

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 651
1 OriginalGriff 210
2 F-ES Sitecore 185
3 Jochen Arndt 160
4 Maciej Los 130
0 OriginalGriff 535
1 Maciej Los 529
2 Richard MacCutchan 440
3 CHill60 415
4 F-ES Sitecore 415


Advertise | Privacy | Mobile
Web01 | 2.8.150901.1 | Last Updated 28 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100