Click here to Skip to main content
13,191,400 members (81,594 online)
Rate this:
Please Sign up or sign in to vote.
See more:
i have vc++ code in blowfish algorthim(this will used to develop encription and decription window) and
iam having c# code in same
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
Please Sign up or sign in to vote.

Solution 1

Manfred R. Bihy 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 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
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.


— Manfred
Menon Santosh 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
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.171017.1 | Last Updated 28 Feb 2013
Copyright © CodeProject, 1999-2017
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