473,626 Members | 3,201 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4868
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.publi c.dotnet.genera l
microsoft.publi c.dotnet.langua ges.vb
microsoft.publi c.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.publi c.dotnet.framew ork
2. microsoft.publi c.dotnet.framew ork.interop
3. microsoft.publi c.dotnet.genera l
4. microsoft.publi c.dotnet.langua ges.vb
5. microsoft.publi c.vb.com
6. microsoft.publi c.vb.winapi
7. microsoft.publi c.vb.winapi.net works

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

Michael
"Rick Rothstein" <ri************ @NOSPAMcomcast. net> wrote in message
news:%2******** ********@tk2msf tngp13.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.publi c.dotnet.genera l
microsoft.publi c.dotnet.langua ges.vb
microsoft.publi c.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(ByV al data() As Byte, ByVal password As String)
As Byte()

' Create the 3DES service provider
Dim tdes As New TripleDESCrypto ServiceProvider

' Create a PasswordDeriveB ytes to derive the key
' from the password
Dim passderive As New PasswordDeriveB ytes(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.Cryp tDeriveKey("Tri pleDES", "MD5", 0, iv)
tdes.IV = iv

' Get the decryptor
Dim decryptor As ICryptoTransfor m = tdes.CreateDecr yptor

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

decryptor.Dispo se()

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.publi c.dotnet.framew ork
2. microsoft.publi c.dotnet.framew ork.interop
3. microsoft.publi c.dotnet.genera l
4. microsoft.publi c.dotnet.langua ges.vb
5. microsoft.publi c.vb.com
6. microsoft.publi c.vb.winapi
7. microsoft.publi c.vb.winapi.net works

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

Michael
"Rick Rothstein" <ri************ @NOSPAMcomcast. net> wrote in message
news:%2******** ********@tk2msf tngp13.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.publi c.dotnet.genera l
microsoft.publi c.dotnet.langua ges.vb
microsoft.publi c.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.publi c.dotnet.framew ork
2. microsoft.publi c.dotnet.framew ork.interop
3. microsoft.publi c.dotnet.genera l
4. microsoft.publi c.dotnet.langua ges.vb
5. microsoft.publi c.vb.com
6. microsoft.publi c.vb.winapi
7. microsoft.publi c.vb.winapi.net works

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

Michael
"Rick Rothstein" <ri************ @NOSPAMcomcast. net> wrote in message
news:%2******** ********@tk2msf tngp13.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.publi c.dotnet.genera l
microsoft.publi c.dotnet.langua ges.vb
microsoft.publi c.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(ByV al data() As Byte, ByVal password As String)
As Byte()

' Create the 3DES service provider
Dim tdes As New TripleDESCrypto ServiceProvider

' Create a PasswordDeriveB ytes to derive the key
' from the password
Dim passderive As New PasswordDeriveB ytes(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.Cryp tDeriveKey("Tri pleDES", "MD5", 0, iv)
tdes.IV = iv

' Get the decryptor
Dim decryptor As ICryptoTransfor m = tdes.CreateDecr yptor

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

decryptor.Dispo se()

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_m vps.org> wrote in message
news:um******** ******@TK2MSFTN GP12.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(ByV al data() As Byte, ByVal password As String) As Byte()

' Create the 3DES service provider
Dim tdes As New TripleDESCrypto ServiceProvider

' Create a PasswordDeriveB ytes to derive the key
' from the password
Dim passderive As New PasswordDeriveB ytes(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.Cryp tDeriveKey("Tri pleDES", "MD5", 0, iv)
tdes.IV = iv

' Get the decryptor
Dim decryptor As ICryptoTransfor m = tdes.CreateDecr yptor

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

decryptor.Dispo se()

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.publi c.dotnet.framew ork
2. microsoft.publi c.dotnet.framew ork.interop
3. microsoft.publi c.dotnet.genera l
4. microsoft.publi c.dotnet.langua ges.vb
5. microsoft.publi c.vb.com
6. microsoft.publi c.vb.winapi
7. microsoft.publi c.vb.winapi.net works

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

Michael
"Rick Rothstein" <ri************ @NOSPAMcomcast. net> wrote in message
news:%2******** ********@tk2msf tngp13.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.publi c.dotnet.genera l
microsoft.publi c.dotnet.langua ges.vb
microsoft.publi c.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

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

Similar topics

3
4266
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 appreciated: $handle = fopen("/home/public_html/testfolder/test.txt","r"); $buffer = fgets($handle, 4096); fclose($handle); // Encryption/decryption key $key = "twenty one years ago";
8
3008
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 a specific extension in a specific directory. The files are uploaded by FTP to this directory. The service then does the following steps: 1) Verify it can open the file (so we know it's fully uploaded). 2) Try to decrypt the file with known...
6
5667
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 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.
0
1762
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; $encrypted=encrypt($key,$random_number); $decrypted=decrypt($key,$encrypted);
8
1212
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 in VB6, I like to keep form code in the form and other code in a separate module so it is easier to reuse. As I understand it, regular modules do not exist in VB.net so I added a class to the project and called it MoreCode. It seemed to me...
1
1572
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 able to decrypt it. The only thing I can figure is that it is using the hash only on the key. Also, the ***************************************************** Public Shared Function TripleDESEncode(ByVal value As String, ByVal
3
8266
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 build with these methods, will appear to encrypt and decrypt, but the resulting decrypted file will be corrupted. I tried encrypting a .bmp file and then decrypting, the resulting decrypted file under .NET 2.0 is garbage, the .NET 1.1 build works...
0
8265
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8705
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8637
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8364
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8504
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7193
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5574
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2625
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1511
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.