Finally I have found what was happening.

By transforming using UTF8 doesn’t matter because the resulting array
was of type byte[] in C#, that is, each element was exactly 1 byte.

The problem was in Cipher Mode used and how the string was padded. I
checked that .NET DESCryptoServiceProvider was using CBC cipher mode
by default, and PKCS #7 padding mode.

By looking at the C++ code I realized that I was padding the string
with 0x00 and using CFB mode (CFB_FIPS_Mode<DES>::Encryption).

The problem was solved by using CBC_Mode<DES>::Encryption instead and
padding with the appropriate byte, according to .NET
DESCryptoServiceProvider defaults.

Cheers
Jaime



On 12 mayo, 11:45, The Psy <[email protected]> wrote:
> jstuardo a écrit :
>
> > Hello....
>
> Hello,
>
> > I have a ASP.NET page that sends an excrypted text to an ASP page
> > using DES algorithm. On the other hand, the ASP page needs to retrieve
> > that encrypted text and decrypt it.
>
> > In order to test encryption and decryption I am only encrypting a
> > simple text using .NET and using Crypto++ library, which I wrapped in
> > a COM+ component that is feasible to call from ASP.
>
> > The text I'm encrypting is only "h". The problem is that both
> > environments generate different outputs.
>
> I think that the input is different. You do that :
> Encoding.UTF8.GetBytes("h") in C#
> It encode h in UTF-8 form, but you don't know how the string is padded.
>
> Try to use the same input for both algorithm.
> (or try to print what you're encrypting).
>
> In C#, with the first alogorithm :
>
> byte inputByteArray[8];
> memset(inputByteArray, 0, 8);
> inputByteArray[0] = 'h'; // STRING TO ENCRYPT !!!
>
> ....
>
> cs.Write(inputByteArray, 0, 8);
>
> ...
>
> > Any help will be greatly appreciated
>
> Hope that will help you.
>
> Best
>
> --
> Florian.
>
> ___________________________________________________________________________
> Yahoo! Mail réinvente le mail ! Découvrez le nouveau Yahoo! Mail et son 
> interface révolutionnaire.http://fr.mail.yahoo.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the "Crypto++ Users" 
Google Group.
To unsubscribe, send an email to [email protected].
More information about Crypto++ and this group is available at 
http://www.cryptopp.com.
-~----------~----~----~----~------~----~------~--~---

Reply via email to