VB Questions re C Programming

M

Murphy

I am new to .Net and am currently learning using vb in a project using
WebMatrix not Visual Studio.

I have found an article regarding password security that is written in C
code and I am unsure of how to implement it into my project.

I am able to create and compile .vb files and I understand how to include
code in the aspx and ascx files.

The article referred to is below and states "The class we presented in
today's article can be built into your own .NET projects - either directly
in C# projects or as an assembly in other programming languages." the only
question is how ?
http://www.aspheute.com/english/20040105.asp


Thanks


Murphy
 
M

Martin Dechev

Hi, Murphy,

From the project you will need only the class DotNetGermanUtils.Password
which is in the file Password.cs. So, first decompress this file to a folder
of your choise.

Now you have 2 options - option one, which is the harder one, is to
translate this to VB.NET.

Option two is to build this class to a .dll:
Open the command prompt (Start->Run, type cmd and click OK). Then either add
to the current path the path to the .NET Framework folder, i.e:

set path=%path%;C:\Windows\Microsoft.NET\Framework\v1.1.4322\

or change the current directory to the above one. Depending on the version
you have the last folder name will be different, take the name from Windows
Explorer.

If you have decomressed the file Password.cs to C:\ you can build it like
this:

csc /target:library /out:C:\password.dll /r:System.dll C:\Password.cs

Then just add the .dll file to the bin folder of the web application you are
intending to use it.

Hope this helps
Martin
 
M

Murphy

Martin, one more question if I may...

I have compiled the code into a dll in the bin directory of my app however I
am having problems accessing the functions as there is a function and a
class that both share the name 'Password' and this is causing errors...

The code I am trying to use is below 'namespace.class' however when I
reference the class the compiler is expecting arguments for password as this
is also a function:
Dim securitysystem As DotNetGermanUtils.Password = New
DotNetGermanUtils.Password()
Dim password as String = securitysystem.CreateRandomPassword(8)
Dim Salt as Integer = securitysystem.CreateRandomSalt()

Ther error received is:
Compiler Error Message: BC30455: Argument not specified for parameter
'nSalt' of 'Public Sub New(strPassword As String, nSalt As Integer)'.

Thanks Murphy
 
M

Martin Dechev

Hi, Murphy,

This class has only one constructor that takes 2 parameters. So you should
first generate the random password and salt and then pass these to the
constructor. This is how it is done in the TestApplication.cs file - though
it is in C# the code is quite simple and I'm sure you will understand what
it does. Moreover, there are comments explaining it.

So your code should be:

Dim RandomPassword as String = _
DotNetGermanUtils.Password.CreateRandomPassword(8)
Dim RandomSalt as Integer = _
DotNetGermanUtils.Password.CreateRandomSalt()
Dim securitysystem As DotNetGermanUtils.Password = _
New DotNetGermanUtils.Password(RandomPassword, RandomSalt)

And then calculate the hash etc.

Hope this helps
Martin
 

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

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top