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.
This is how I'm encrypting in C#:
<pre>
private byte[] key = { 0x21, 0x23, 0x24, 0x61, 0x35, 0x34, 0x3F,
0x33 };
private byte[] IV = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD,
0xEF };
DESCryptoServiceProvider des = new DESCryptoServiceProvider();
byte[] inputByteArray = Encoding.UTF8.GetBytes("h"); // STRING TO
ENCRYPT !!!
MemoryStream ms = new MemoryStream();
CryptoStream cs = new CryptoStream(ms, des.CreateEncryptor(key, IV),
CryptoStreamMode.Write);
cs.Write(inputByteArray, 0, inputByteArray.Length);
cs.FlushFinalBlock();
</pre>
The resulting array is:
{Dimensions:[8]}
[0]: 75
[1]: 255
[2]: 52
[3]: 167
[4]: 230
[5]: 34
[6]: 45
[7]: 39
And this is how I'm using Crypto++ library:
<pre>
const byte key[] = {0x21, 0x23, 0x24, 0x61, 0x35, 0x34, 0x3f,
0x33}; // "!#$a54?3"
const byte iv[] = {0x12,0x34,0x56,0x78,0x90,0xab,0xcd,0xef};
byte plaintext[8];
memset(plaintext, 0, 8);
plaintext[0] = 'h'; // STRING TO ENCRYPT !!!
byte ciphertext[8];
CFB_FIPS_Mode<DES>::Encryption encryption_DES;
encryption_DES.SetKeyWithIV(key, sizeof(key), iv);
encryption_DES.ProcessString(ciphertext, plaintext, 8);
</pre>
The resulting array is:
{Dimensions:[8]}
[0]: 166
[1]: 62
[2]: 35
[3]: 66
[4]: 62
[5]: 68
[6]: 110
[7]: 8
As you see, radically different results. What is wrong? The more
frustrating thing is that when I decrypt, using the same library, for
example, Crypto++, I get the original string.
Any help will be greatly appreciated
Thanks
Jaime
--~--~---------~--~----~------------~-------~--~----~
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.
-~----------~----~----~----~------~----~------~--~---