Encryption

R

Robert Vabo

I have to make an Encrytion function that works for both VB.NEt and VB 6. I
use the System.Security.Cryptography in VB.NET and I want to use the same
type of functions in VB6.

I USE DPAPI to store some keys in registry and I want to use the same keys
both in VB6 and VB.NET. The DPAPI works fine in both. The problem is the
Encryprion/Decryption using advapi.dll

I have converted the classes from
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/SecNetHT10.asp
to VB and I want the same classes/methods in VB6.

Anyone who has the same problem ? Any tips, hints ?
 
T

Ting Liang

One easy way if you don't mind having your VB6 app relying on the presence
of .NET framework is by putting your VB.NET encryption code in a COM class
(ie instead of add a new class in VB.NET, you add a new COM class), build,
and add a reference in your VB6 app to that COM class. You will need both
sets of binaries (VB.NET and VB6) as well as .NET framework to run your VB6
app but it should work.
 
R

Robert Vabo

Thanks for the answer.
I have now made the component a COM component. I call it from VB6 but I get
this error message :
"Function or interface marked as restricted, or the function uses an
Automation type not supported in Visual Basic". Any suggestions.
I have made all the methods public.
 
T

Ting Liang

You should create a VB.net ClassLibrary project (named ClassLibrary1),
remove Class1 and create a new COM class (ComClass1). Implement your
encryption function in ComClass1, eg Public Function Encrypt(...). Build
ClassLibrary1 project. After building you should be able to find
ClassLibrary1 in VB6's Project->References dialog. Check it in the dialog.
You should then be able to write something like Dim x as New
ClassLibrary1.Class1, and make calls x.Encrypt(...) to it.
 

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