views:

1593

answers:

6

Hello,

I need to encrypt a byte array in VB6 and decrypt it in C# (NET 2.0). And viceversa (C# to VB6).

In C# I used RijndaelManaged class. In VB6 I used free pieces of from Internet. The best seems to be http://www.frez.co.uk/freecode.htm#rijndael But the two implementations generate different outputs starting from the same input :(

Perhaps it's a problem with the IV vector in RijndaelManaged ... I don't understand...

Any solution / experience using Rijndael / AES between VB6 and NET ? Or TripleDes....

thank you

UPDATE: IMPORTANT: The machine where vb6 app runs, has not NET framework. So I cannot use Interop and/or a NET wrapper class exposed as COM. :(

+6  A: 

You could use interop from .NET to call the C# implementation from VB6. That way both sides would be using the same library.

Here's some additional info: http://msdn.microsoft.com/en-us/library/hfzzah2c(vs.71).aspx

Neil Barnwell
A: 

Maybe I'll give you some informations regarding IV.

Initialization Vector is a clear-text sent data that should be generated randomly for each encryption to make stereotype headers attack harder or imposible to perform. Of course both encrypter and decrypter MUST have same value set.

Also there are some modes in which encryption and decryption may run. Have a look at this page: Wikipedia: Block cipher modes of operation. You should also ensure that this mode is same for both of them.

Migol
A: 

I just grabbed SlowAES, a Javascript implementation of AES, and embedded it into a Windows Script Component, which makes it accessible via COM. I was then able to call into the component from COM clients. I didn't try VB6 because i don't have Visual Studio 6. But for the COM clients I tried, I found the encryption to be completely compatible with .NET and the RijndaelManaged() class, when I use the same key, IV, mode, and keysize.

SlowAES is sort of limited; i didn't see an ECB mode for example. But the stuff I tested is compatible with .NET.

The source for the WSC file is available. That source also includes a RFC2898-compliant PBKDF2 usable from VB6. So you can set the key from a password. It is compatible with the Rfc2898DeriveBytes class in .NET.

See also, a related question.

Cheeso
A: 

DID you find the solution ??? i am also stuck in same problem

abhijeet
The problem has been answered and solved. http://stackoverflow.com/questions/751759/rijndael-aes-from-c-to-vb6/858228#858228
Cheeso
A: 

Take a look at :

http://www.frez.co.uk/freecode.htm

omid
A: 

VbCorLib now supports cryptography, included Rijndael.

It's free and .NET-like. Link: http://vbcorlib.blogspot.com/

Alex Bagnolini