473,385 Members | 2,044 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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

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
Jul 21 '05 #1
11 4833
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

"underwmd" <no****@nospam.net> wrote in message
news:aR***********************@news.easynews.com.. .
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

Jul 21 '05 #2
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
"Rick Rothstein" <ri************@NOSPAMcomcast.net> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
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

"underwmd" <no****@nospam.net> wrote in message
news:aR***********************@news.easynews.com.. .
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


Jul 21 '05 #3
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

--
Eduardo A. Morcillo [MS MVP VB]
http://www.mvps.org/emorcillo
Jul 21 '05 #4
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
"Rick Rothstein" <ri************@NOSPAMcomcast.net> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
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

"underwmd" <no****@nospam.net> wrote in message
news:aR***********************@news.easynews.com.. .
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


Jul 21 '05 #5
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
"underwmd" <no****@nospam.net> wrote in message
news:jo***********************@news.easynews.com.. .
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
"Rick Rothstein" <ri************@NOSPAMcomcast.net> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
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

"underwmd" <no****@nospam.net> wrote in message
news:aR***********************@news.easynews.com.. .
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



Jul 21 '05 #6
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

--
Eduardo A. Morcillo [MS MVP VB]
http://www.mvps.org/emorcillo
Jul 21 '05 #7
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

"Eduardo A. Morcillo [MS MVP VB]" <emorcillo_at_mvps.org> wrote in message
news:um**************@TK2MSFTNGP12.phx.gbl...
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

--
Eduardo A. Morcillo [MS MVP VB]
http://www.mvps.org/emorcillo

Jul 21 '05 #8
underwmd wrote:

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


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

microsoft.* is not USENET.

Bob
--
Jul 21 '05 #9
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
"underwmd" <no****@nospam.net> wrote in message
news:jo***********************@news.easynews.com.. .
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
"Rick Rothstein" <ri************@NOSPAMcomcast.net> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
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

"underwmd" <no****@nospam.net> wrote in message
news:aR***********************@news.easynews.com.. .
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



Jul 21 '05 #10
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

"Eduardo A. Morcillo [MS MVP VB]" <emorcillo_at_mvps.org> wrote in message
news:um**************@TK2MSFTNGP12.phx.gbl...
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

--
Eduardo A. Morcillo [MS MVP VB]
http://www.mvps.org/emorcillo

Jul 21 '05 #11
underwmd wrote:

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


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

microsoft.* is not USENET.

Bob
--
Jul 21 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Ralph Freshour | last post by:
I'm having trouble decrypting a file I encrypted and wrote to the server - the following code displays the $decrypted_string variable but the data is still encrypted - any help would be...
8
by: MattP | last post by:
Ok, with the help of some examples found on the web and some minor modifications on our own, we have a simple and working encrypt and decrypt solution. It runs as a service, watches for files with...
6
by: underwmd | last post by:
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...
0
by: Kelvin | last post by:
Dear all, I don't know how to write a asp/vb/c# program to decrypt PHP encrypted code. Here is attched my code in PHP $key = "ab"; $random_number = kelvin;...
8
by: iano | last post by:
I am trying to clone a VB6 app in Vb.Net as a learning exercise. For this effort I am not using Visual Studio.Net. So Far I have a form with a label, combobox and a command button. As I have done...
1
by: tshad | last post by:
I am trying to use 3DES to encrypt my keys and am using VS 2003. I am confused with some code I have that seems to use a hash (MD5) in the 3DES. But a Hash is one way. You are not suppose to be...
3
by: JDeats | last post by:
I have some .NET 1.1 code that utilizes this technique for encrypting and decrypting a file. http://support.microsoft.com/kb/307010 In .NET 2.0 this approach is not fully supported (a .NET 2.0...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.