在VB.NET中帮助VBES中的3DES文件加密到3DES文件解密 [英] Help 3DES File Encrypt in VB6 to 3DES File Decrypt In VB.NET

查看:87
本文介绍了在VB.NET中帮助VBES中的3DES文件加密到3DES文件解密的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


我的问题有两个。


1)我必须支持用VB6 SP5编写的已部署的遗留应用程序。我需要从数据库中导出数据,压缩它并使用3DES加密数据

(以防止篡改)数据在晚上传输到家中
我公司的办公室。在.NET中重写此应用程序不是一个选项,因为该应用程序已经开发了5年。


2)我从边远办公室收到数据后,我需要在使用VB.NET 2003和加密命名空间之前将数据解密为
,然后将数据转换为AS / 400.

我已成功编写VB6代码,通过调用advapi32.dll来加密和解密数据

。不幸的是,任何使用VB.NET的Cryptography命名空间解密这些

文件的尝试都会导致错误,并且

尝试总是会失败。

有人能给我一些VB6中的示例或指导到VB.NET数据3DES

加密/解密???我真的很难过这个话题。示例代码

会很好!!!记住条件 - Encypt Under VB6 / Decrypt

VB.NET 2003.


谢谢

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

推荐答案

这个新闻组中的每个人都使用VB6或更低版本。虽然你可能会在这里得到VB.NET问题的流行答案,但你应该在新闻组中询问他们

专门用于.NET编程。使用

单词dotnet查找新闻组。或vsnet以他们的名义。


对于微软新闻服务器,请尝试这些新闻组...


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

microsoft.public.vsnet.general


还有其他一些,但这些应该得到你开始了。


Rick - MVP


" underwmd" <无**** @ nospam.net>在消息中写道

新闻:aR *********************** @ news.easynews.com ..。
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.. .
你好,

我的问题有两个。

1)我必须支持用VB6 SP5编写的已部署的遗留应用程序。我需要从数据库导出数据,压缩数据并使用3DES加密数据(以防止篡改)数据在晚上传输到我公司的
家庭办公室。在.NET中重写此应用程序不是一个选项
,因为该应用程序已经开发了5年。

2)在我从边远办公室收到数据后,我需要
在将数据转换为AS / 400之前,使用VB.NET 2003和Cryptography命名空间解密数据。

我已经成功编写了加密和解密数据的VB6代码通过调用advapi32.dll。不幸的是,任何尝试使用VB.NET的Cryptography命名空间解密
这些文件都会导致错误并且
尝试总是失败。

有人可以给我一些例子或者VB6中指导VB.NET数据3DES
加密/解密???我真的很难过这个话题。示例代码
会很好!!!记住条件 - VB下的Encypt / Decrypt
在VB.NET 2003下。

谢谢
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



Rick,


如果你要注意,我把它发布到总共7组,包括

VB Classic和VB 。净。有了这个,我希望在一个独特的情况下挑起一个人b $ b,比如我自己必须支持这两个平台


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


这不是我第一次发布到USENET。


Michael

" Rick Rothstein" < RI ************ @ NOSPAMcomcast.net>在留言中写道

新闻:%2 **************** @ tk2msftngp13.phx.gbl ...
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...
几乎所有人在这个新闻组中使用的是VB6或更低版本。虽然你可能会在这里得到一个流行的VB.NET问题答案,你应该在新闻组中询问他们专门用于.NET编程。查找带有
单词dotnet的新闻组。或vsnet在他们的名字。

对于微软新闻服务器,请尝试这些新闻组...

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

还有其他一些,但这些应该可以让你开始。

Rick - MVP

underwmd <无**** @ nospam.net>在消息中写道
新闻:aR *********************** @ news.easynews.com ..。
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.. .
您好,

我的问题有两个。

1)我必须支持用VB6 SP5编写的已部署的遗留应用程序。
我需要从数据库导出数据,压缩它并使用3DES加密
数据(以防止篡改)数据在晚上传输到我家的
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
办公室公司。在.NET中重写此应用程序不是
选项,因为
office of my company. Rewriting this application in .NET is not an option as
该应用程序已开发5年。

2)我从边远办公室收到数据后,我需要
the application was 5 years in development.

2) After I receive the data from the outlying offices, I need to


在将数据转换为AS / 400之前,使用VB.NET 2003和Cryptography命名空间解密


Decrypt

数据。

我已经成功编写了VB6代码,通过调用advapi32.dll来加密和解密
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



数据。不幸的是,任何使用VB.NET的Cryptography命名空间解密


data through calls to advapi32.dll. Unfortunately, any attempts to decrypt


这些

文件的尝试都会导致错误并且
尝试总是失败。

有人可以给我一些VB6中的示例或指导到VB.NET数据3DES
加密/解密???我真的很难过这个话题。样本
代码会很好!!!记住条件 - Encypt Under VB6 / Decrypt
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


VB.NET 2003下。

谢谢
underwmd
VB.NET 2003.

Thanks
underwmd




如果您使用它来加密VB6中的数据(使用MD5和3DES):

使用CryptoAPI加密数据
http ://www.mvps.org/emorcillo/vb6/crypto/encrypt.shtml


然后您可以使用此函数在vb.net中解密它:


私函数DecryptData(ByVal data()As Byte,ByVal密码为字符串)

As Byte()


' '创建3DES服务提供商

Dim tdes As New TripleDESCryptoServiceProvider


''创建一个PasswordDeriveBytes来获得密钥

''来自密码

Dim passderive As New PasswordDeriveBytes(密码,无)

Dim iv As Byte()= New Byte(){0,0,0,0,0,0,0,0}


''从密码中导出密钥

tdes.Key = passderive.CryptDeriveKey(TripleDES,MD5,0,iv)

tdes.IV = iv


''获取解密器

Dim decryptor As ICryptoTransform = tdes.CreateDecryptor


''解密数据

DecryptData = decryptor.TransformFinalBlock(data,0,data.Length)


decryptor.Dispose()


结束函数

/>
-

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


这篇关于在VB.NET中帮助VBES中的3DES文件加密到3DES文件解密的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆