Click here to Skip to main content
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 3: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 OriginalGriff 480
1 Maciej Los 330
2 Richard MacCutchan 225
3 BillWoodruff 185
4 Suraj Sahoo | Coding Passion 155
0 OriginalGriff 8,759
1 Sergey Alexandrovich Kryukov 7,407
2 DamithSL 5,639
3 Maciej Los 5,269
4 Manas Bhardwaj 4,986


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