Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
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
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

 
Share this answer
 
Comments
Manfred Rudolf 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 Rudolf 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.
:)
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
 
Share this answer
 
v3
Comments
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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900