|
Hi there!
I want to save an encrypted password in a database in order to authenticate the users of my application (on C# 2.0).
So, I encrypted the password provided by the user, as following:
UnicodeEncoding unicodeEncoding = new UnicodeEncoding();<br />
byte[] passwordArray = unicodeEncoding.GetBytes(password);<br />
SHA1Managed sha1Managed = new SHA1Managed();<br />
byte[] encryptedPassword = sha1Managed.ComputeHash(passwordArray);
Then, I saved the password in 'varbinary(160)' field in a table of database (SQL Server 2005):
DataSet.Users.AddUsersRow(userName, encryptedPassword);<br />
UsersTableAdapter userTableAdapter = new UsersTableAdapter();<br />
userTableAdapter.Update(DataSet.Users);
How can I recover this encrypted password in order to compare it with a new encrypted password provided by the user?
This code:
byte[] passwordArray = row["Password"];
doesn't compile because "it can't convert object to byte[]".
Thank you, in advance.
--
Adrián Córdoba
|
|
|
|
|
Try casting it first:
byte[] passwordArray = (byte[])row["Password"];
|
|
|
|
|
Thank you very, very much!
--
Adrián Córdoba
|
|
|
|
|
In VS 2003 I used SBCollectionGenerator to auto-generate strongly-typed collections from .xml files. In VS 2005 the base classes and some interfaces are no longer accessible. Is there a work around or a new tool for VS 2005?
Thanks for help
|
|
|
|
|
|
hi how can i disable alt+f4 key please give me some clue if possible please send some sample
code in c#.
|
|
|
|
|
You might be able to with a system wide keyboard hook. Also, doesn't that close a program ? The onclosing event might be useful, you could write code to refuse to close, unless some condition is met ( such as, ALT is not held down )
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
|
Yeah, that's what I'd suggest.
private bool closeok = false ;
private void button1_Click ( object sender , System.EventArgs e )
{
this.closeok = true ;
this.Close() ;
}
private void Form1_FormClosing ( object sender , System.Windows.Forms.FormClosingEventArgs e )
{
e.Cancel = !closeok ;
}
The form will only close due to a click of button1.
(In addition, if you haven't already, set the form's ControlBox = false; )
|
|
|
|
|
Does anybody know of any way to find out which application/process has locked a file?
As an example, you have a file called widgets.txt and when you try and delete it you get a message along the lines of "Cannot delete widgets.txt, there has been a sharing violation, the source or destination file may be in use". The problem is this message doesnt tell you what it actually holding a handle on the file.
I am currently working under the assumption that there is something in the Win API that I can call to get this information, however I am currently at a loss to what it is.
|
|
|
|
|
|
How is it possible to create and populate an array for the follwing data please?:
Please note that this is just a sample data
AL LME BR IPE CU LME EURUSD
BR IPE 1.0 23 98
CU LME 3 1.0 8
EURUSD 2 76 1.0
|
|
|
|
|
Well, assuming the first row is headers, I'd create a struct that defines the collection of data in each row, so looks like two strings, and three floats, and then make an array of that type.
I'd use the List class, rather than an array.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
i have a DataGrid dbgTest with DataSource = dtA
i use DataView to search some row and display result in dbgTest
anythings are work well.
and my problems is: i want create new DataTable from result display in dbgTest after search by DataView.
Thanks
|
|
|
|
|
I have created an Windows.NET app in C#. with crystal reports.
These all run fine on my development computer. I modified my setup project to
include all the merge modules that CR.NET needs, added the
licence key info. and rebuilt the solution. still everything works fine when
I run the installation. both on Development computer as well as on Client
computer.
later i added an installer class to add the Database path to a config file
during installation
I successfully installed the app. on my development computer.
but when I try to run it on Client system, I receive the following error:
Unable to get installer types in the <app path="">\app.exe assembly --> one or
more of the types in the assembly unable to load.
it seems to be something related to crystal reports.
I am using .NET Studio 2005 and app is on c# with few crystal Reports.
Now if i copy and paste the bin/debug directory from the development system
to my client system, it gives the following error when trying to run crystal
report module:
File or assembly name CrystalDecision.Windows.Forms, or one of its
dependencies, was not found
help appreciated.
thanks in advance.
Rachit Damani.
|
|
|
|
|
(I know you said that you have all the merge modules so just make believe I'm the person looking over your shoulder with coffee breath offering useless advice...)
Under Detected Dependencies is CrystalReportsRedist2005_x86.msn listed? What I would do just for testing is to see if you can build an installer just for the Crystal Reports Redistributable and another for your main app (without the Crystal Reports). If that works then something went goofy in your original installer project (I have to make new ones all the time. For some reason mine get corrupted when I have a new version of the main exe).
Good Luck!
|
|
|
|
|
Dear friends,
Let say I have a connection from C# 2005 to MS Access database and table name "personal", and dataset name "myDataSet". How can I delete a current row record from that dataset also in access database?
Thanks in advise...
memix
|
|
|
|
|
|
Hello...how can I convert an element from a list into double or integer....I have something like this.......:
totalDemand += Convert.ToDouble(this[j].Demands, CultureInfo.CurrentCulture);
and it gives me an "unable to cast object of type System.Collections.Generic.List'1[system.Double]' to type System.IConvertible'.
and totalDemand it's declared like this:
private double totalDemand;
public double TotalDemand
{
set
{
totalDemand = value;
}
get
{
return totalDemand;
}
}
|
|
|
|
|
What kind of value does this[j].Demands return? Convert.ToDouble expects either a string instance or an object that implements the IConvertible interface. According to the error message, this[j].Demands returns neither of them.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
this[j].Demands return double....how can I convert it to string or IConvertible?
|
|
|
|
|
If this[j].Demands already returns a double, there is no need to "convert" it to a double.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
it's about a double and a list of type double...
I wrote something like this :
totalDemand+=this[j].Demands; but it give me two errors....
Error 10 Operator '+=' cannot be applied to operands of type 'double' and 'System.Collections.Generic.List<double>'
Error 11 Cannot implicitly convert type 'System.Collections.Generic.List<double>' to 'double'
|
|
|
|
|
Obviously Demands does not return a double but guessing from your comments a list of doubles. Maybe you wanted to write totalDemand += this.Demands[j] ? If not, it's probably time to show some more pieces of your code.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Now the problem is that totaldemand is always equal with 0.
The List Demands is making part of the class CityDemand
private List<double> demands = new List<double>();
public List<double> Demands
{
get
{
return demands;
}
set
{
demands = value;
}
}
And this part of the code is in a Class named CitiesDemand
private double totalDemand;
public double TotalDemand
{
set
{
totalDemand = value;
}
get
{
return totalDemand;
}
}
public void CalculateCityDemands(double totalQ)
{
totalDemand = 0;
foreach (CityDemand citydem in this)
{
citydem.Demands.Clear();
for (int i = 0; i <= Count; i++)
{
citydem.Demands.Add(citydem.VehicleQ);
for (int j = 0; j <= i; j++)
{
totalDemand += citydem.Demands[j];
}
}
if (totalDemand > totalQ)
citydem.Demands.RemoveAt(citydem.VehicleQ);
}
}
|
|
|
|