|
Hi,
What is the best way to store encripted passwords?
I'm using a simple XML file to store the passwords but I don't know how to store the key used in encriptation in a safe way.
The passwords are to connect to a database, so they need to be tranformed back to the original values.
Thanks
|
|
|
|
|
You might want to look up documentation of the following method. I think it is what you are looking for
FormsAuthentication.HashPasswordForStoringInConfigFile
R.Bischoff
.NET, Kommst du mit?
|
|
|
|
|
DrGreen wrote:
The passwords are to connect to a database, so they need to be tranformed back to the original values.
That's not a good way to do it. You should store passwords in a one-way hash (like MD5) which someone else mentioned. Instead of sending clear-text passwords across the wire (which can be easily sniffed) and decrypting the passwords from the database to compare, a much more secure approach is to hash the clear-text password and compare that with the password in the database. This can be done better by using a SALT value and other mechanisms to avoid replay attacks.
There are several articles about this here on CodeProject.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
can anyone tell me to create a prev/next in datagrid. I would like to display record in a datagrid with multiple pages.
thank You
|
|
|
|
|
I take it this is in reference to ASP.NET's DataGrid ? If so, this belongs in the ASP.NET forum. Really, though, the documentation is pretty clear about how to do this and even includes examples.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
In general you are talking about pagination, maybe a google on "datagrid pagination" is in order.
if you are referring to asp.net, research the following properties of the datagrid;
AllowPaging
AllowCustomPaging
event:
PageIndexChanged
Good luck!
R.Bischoff
.NET, Kommst du mit?
|
|
|
|
|
Hi
I want to be able to create an Type from an string.
I have tried using Type.GetType(string). But I just cant get it too work.
Im getting assembly not found in msorlib thing or the executing assembly errors.
Im trying to get the Type from for example Type.GetType("TextBox"). But this dont work since the program doesnt seem to know where to look.
How can I load the System.Windows.Forms assembly so it knows where to look?.
|
|
|
|
|
Have you tried Type.GetType("System.Windows.Forms.TextBox") ?
|
|
|
|
|
Yes and I allways get an TypeLoadException.
The problem is that the Type.GetType method searches the executing assembly in this case an testlibrary.
"An unhandled exception of type 'System.TypeLoadException' occurred in xmltestlibrary.dll
Additional information: Could not load type System.Windows.Forms.TextBox from assembly TestLibrary, Version=1.0.1589.1600, Culture=neutral, PublicKeyToken=null."
|
|
|
|
|
Then you have to force .NET to load the correct assembly:
<br />
String name = System.Reflection.Assembly.CreateQualifiedName("System.Windows.Forms", "TextBox");<br />
<br />
System.Reflection.Assembly a = System.Reflection.Assembly.LoadWithPartialName("System.Windows.Forms");<br />
<br />
Type t = a.GetType("System.Windows.Forms.TextBox", true, false);<br />
|
|
|
|
|
Thx it worked like a charm.
|
|
|
|
|
And after you get the Type like Corrina said, then you can use a number of ways to instantiate it, like Activator.CreateInstance . See the .NET Framework SDK documentation for more ways, like getting the constructor with a certain parameter list and calling that to create a new instance with the parameters you want.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I know that. Then I can use various methods to be able to execute methods.
I can even load an unknown dll and search it find and class and call methods.
So I know about the capabilities.
As I replied to Corrina.
Yes and I allways get an TypeLoadException.
The problem is that the Type.GetType method searches the executing assembly in this case an testlibrary.
"An unhandled exception of type 'System.TypeLoadException' occurred in xmltestlibrary.dll
Additional information: Could not load type System.Windows.Forms.TextBox from assembly TestLibrary, Version=1.0.1589.1600, Culture=neutral, PublicKeyToken=null."
I dont get it. I've looked at examples but they arent very helpfull.
|
|
|
|
|
Notice how it's trying to load a Type that should be in the System.Windows.Forms.dll assembly? You have to specify a correct partial or full Type, like:
Type t = Type.GetType("System.Windows.Forms.TextBox, System.Windows.Forms"); Notice the assembly name in there, too? If you want to get specific, you can also include the version, culture, and publicKeyToken attributes.
There are plenty of examples - even in common .config sections do you specify the fully-qualified Type name and either a partial of full assembly reference. If you don't specify the assembly, then it assumes the Type name is in the currently executing assembly.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
HI!
I want to detect CPU usage and Net speed using PerformanceCounter, but the vaules are always 0.
For net speed here is the code:
private void GetNetSpeed()
{
PerformanceCounterCategory category = new PerformanceCounterCategory("Network Interface");
foreach(string adapter in category.GetInstanceNames())
{
if(adapter == "MS TCP Loopback interface")
continue;
PerformanceCounter netRCounter = new PerformanceCounter("Network Interface","Bytes Received/sec",adapter);
PerformanceCounter netSCounter = new PerformanceCounter("Network Interface","Bytes Sent/sec",adapter);
txtSys.Text += "Recived: " + netRCounter.NextValue().ToString() + " b/s.";
txtSys.Text += "Sent: " + netSCounter.NextValue().ToString() + " b/s.";
}
}
Could anybody tell me way is always 0?
HELLO!
|
|
|
|
|
would like to know how to get hold of excel cells using the Excel namespace?
Is there anyone with ideas, I need to read a lot of data and manipulate it from a spread sheet.
thanks
Dries
|
|
|
|
|
Use the Microsoft PIAs (Primary Interop Assemblies) that can be downloaded from http://msdn.microsoft.com[^] for Office XP or that come on the CD with Office 2003 Professional. Add a reference to Microsoft.Office.Interop.Excel.dll and create a new instance of the ApplicationClass in the Microsoft.Office.Interop.Excel namespace. This creates a new instance of the Excel application (invisible at first - set its Visible property to true to display it).
Then load a new workbook or template using Workbooks.Open . That will give you a Workbook instance. Cast this to a WorkbookClass and use the Sheets property to get the Sheet you want. Use the Item property to get a Worksheet . Cast this to a WorksheetClass and you can now get the Cells property. This is all documented in the Office Programming Reference what to do and where to go from there (like the various ways you can reference cells).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
i have two classes, one serverCommands and one socketServer. once i have created a new instance of the serverCommands class in socketServer, i want to be able to type something like serv (my new instance of serverCommands) .CreateSocket(socketName) and create a socket according to the name specified. is this possible?
if so, how? this could be used with other stuff two as there is some things that would be much quicker to create with a function. should the functions be private, public, static or what? (and what do they mean? )
also is it possible to say something like Console.WriteLine(serv.Version()); and have it getting an output from the function Version and displaying it in the Console? i understand references have something to do with this, and returns...
thanks for help with any of the above,
surgeproof
-------------------------------------------------------
ithium is the best.
'Science without religion is lame, religion without science is blind.' --Albert Einstein
'The pioneers of a warless world are the youth who refuse military service.' --Albert Einstein
|
|
|
|
|
This is all possible if you design your application right. It's your implementation.
As far as the access modifiers, you need to decide if you want any class to be able to call a method or get/set a property or not. You can see the differences between the access modifiers by reading Access Modifiers[^] in the Visual C# product documentation.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
thanks for the link, it helps. would you have a link to teach me about functions/etc. and referencing? i can't seem to find anything useful, so if you do know of a good one please tell.
thanks,
surgeproof
-------------------------------------------------------
ithium is the best.
'Science without religion is lame, religion without science is blind.' --Albert Einstein
'The pioneers of a warless world are the youth who refuse military service.' --Albert Einstein
|
|
|
|
|
Nothing useful? How about reading the .NET Framework SDK[^] for starters, not to mention any number of the countless books out there about the .NET Framework and the languages that target it, like C#? It's how many of us learned.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
thanks. will try
surgeproof
-------------------------------------------------------
ithium is the best.
'Science without religion is lame, religion without science is blind.' --Albert Einstein
'The pioneers of a warless world are the youth who refuse military service.' --Albert Einstein
|
|
|
|
|
Hi to all,
Can somebody tell me some usefull links where I can get help for working with XML files. In my WinForm application I creating xml file and wite some data to it. But when I lauch my program again it rewrites the existing file. How can I do that new nodes would be written to the end of the document? And also I want to read all these nodes, what is the best way to them all, one for one? Thanx.
www.xedom.com
|
|
|
|
|
Everything you need to know is under the System.Xml[^] namespace.
Basically, you want to check if the .xml file exists, if so you want to insert your new data, if not create a new .xml file. Don't create a new file everytime, you'll write over your data.
The bulk of your methods might come from this class, XmlTextWriter[^]
Good luck.
R.Bischoff
.NET, Kommst du mit?
|
|
|
|
|
I'm really confused.
I'm new to forms in c#, but i have used c# and forms before, just not together.
i want to draw a rectangle on the screen so i used this code in a button click event
Pen NewPen = new Pen(Color.Red,10);
Graphics g = this.CreateGraphics();
g.DrawRectangle(NewPen,200,200, 50,50);
this does exactly what i would expect, but it's not very interesting so i added some lines:
Pen NewPen = new Pen(Color.Red,10);
Graphics g = this.CreateGraphics();
int X = this.Width/2;
int Y = this.Height-100;
g.DrawRectangle(NewPen,X,Y, 50,50);
Now i don't get the rectangle, but if i step through the code i can see a flash as it gets drawn and then when the form is displayed it dissappears.
I revert to the original code and now that doesn't work either, but if i paste the code into a new project it works fine.
has anyone seen anything like this before?
I'm really confused, any help would be appreciated
russ
|
|
|
|