Help 3DES File Encrypt in VB6 to 3DES File Decrypt In VB.NET

U

underwmd

Hello,

My problem is two fold.

1) I must support a deployed legacy application written in VB6 SP5. I
need to export data from a database, compress it and the encrypt the data
using 3DES (to prevent tampering) data gets transmitted at night to the home
office of my company. Rewriting this application in .NET is not an option as
the application was 5 years in development.

2) After I receive the data from the outlying offices, I need to Decrypt
the data using VB.NET 2003 and the Cryptography namespace prior to
transforming the data into an AS/400.

I have successfully written VB6 code which encrypts and decryptes the data
through calls to advapi32.dll. Unfortunately, any attempts to decrypt these
files using VB.NET's Cryptography namespace results in a error and the
attempt always fails.

Can someone give me some examples or guidance in VB6 to VB.NET data 3DES
encryption/decryption??? I am really stumped on this topic. Sample code
would be nice!!! Remember the conditions - Encypt Under VB6 / Decrypt Under
VB.NET 2003.

Thanks
underwmd
 
R

Rick Rothstein

Almost everybody in this newsgroup is using VB6 or lower. While you may get
a stray answer to VB.NET questions here, you should ask them in newsgroups
devoted exclusively to .NET programming. Look for newsgroups with either the
word "dotnet" or "vsnet" in their name.

For the microsoft news server, try these newsgroups...

microsoft.public.dotnet.general
microsoft.public.dotnet.languages.vb
microsoft.public.vsnet.general

There are some others, but these should get you started.

Rick - MVP
 
U

underwmd

Rick,

If you were to take note, I posted this to a total of 7 groups encompassing
both VB Classic and VB.NET. With this, I hoped to stir up someone whom is
in a unique situation such as myself whom has to support both platforms

1. microsoft.public.dotnet.framework
2. microsoft.public.dotnet.framework.interop
3. microsoft.public.dotnet.general
4. microsoft.public.dotnet.languages.vb
5. microsoft.public.vb.com
6. microsoft.public.vb.winapi
7. microsoft.public.vb.winapi.networks

This is not the first time I have posted to the USENET.

Michael
 
E

Eduardo A. Morcillo [MS MVP VB]

If you use this to encrypt the data in VB6 (using MD5 and 3DES):

Encrypting data with CryptoAPI
http://www.mvps.org/emorcillo/vb6/crypto/encrypt.shtml

You can then decrypt it in vb.net using this function:

Private Function DecryptData(ByVal data() As Byte, ByVal password As String)
As Byte()

' Create the 3DES service provider
Dim tdes As New TripleDESCryptoServiceProvider

' Create a PasswordDeriveBytes to derive the key
' from the password
Dim passderive As New PasswordDeriveBytes(password, Nothing)
Dim iv As Byte() = New Byte() {0, 0, 0, 0, 0, 0, 0, 0}

' Derive the key from the password
tdes.Key = passderive.CryptDeriveKey("TripleDES", "MD5", 0, iv)
tdes.IV = iv

' Get the decryptor
Dim decryptor As ICryptoTransform = tdes.CreateDecryptor

' Decrypt the data
DecryptData = decryptor.TransformFinalBlock(data, 0, data.Length)

decryptor.Dispose()

End Function
 
R

Rick Rothstein

Sorry, I missed the multi-post when I responded. However, for future
reference, VB Classic and VB.NET are, for all practical purposes, different
languages (as you no doubt are aware). I would submit that you will find
those supporting both languages (such as yourself) will be located in the
dotnet newsgroups along with those who only support VB.NET... if they are
participants in a non-dotnet newsgroup, then they are surely participants in
a dotnet group also. For the **vast** majority of users here in the
non-dotnet newsgroups, postings about VB.NET amount to nothing more than
noise.

Rick - MVP
 
U

underwmd

Eduardo

I'll try your recommendations and get back with you.

In the mean time to enlighten me on this issue further:

Can you refence a document to me to give me an idea of how to combine the
hashing with the encryption technique, how would I have known without your
reply to use a zeroed byte array for the IV array. The security and
encryption of VB classic and VB.NET is all new to me.

Thank you for your time

Michael Underwood
 
B

Bob O`Bob

underwmd said:
This is not the first time I have posted to the USENET.

That's obviously correct ... but only accidentally.

microsoft.* is not USENET.



Bob
--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top