|
hello,
my problem is that i am working on a window app in c#.
i have three buttons on my form.now while selecting with tab button i want to
fire button1_click or button2_click event when we press enter.for 1 button it can
be easily done by form's accept button property .but how can i do it for all
|
|
|
|
|
If any button is focused and you press enter, its click event is automatically fired.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Expect everything to be hard and then enjoy the things that come easy. (code-frog)
|
|
|
|
|
Hi,
First I will apologise for not answering your exact question but here is another way to achieve your goal.
Did you know that the standard windows keyboard method for simulating a keypress on the button that has focus is the space bar. Change focus from button to button with the tab key and then use space to press the button, no programming required on your part!
Alan.
|
|
|
|
|
I am a beginner in C#,this is an extract from a webservice project.i get an error Error 24 Cannot apply indexing with [] to an expression of type 'method group'.pls help wat am i doing wrong here.
1.)object[] args = new object[](this is in one method)
2.)args[2] = Row[SharedVars._MobileNo].ToString();(this is in another method)
string demo = args[2].ToString();
string mobshort = demo.Substring[0,3];
if (mobshort == 971)
string CountryCode = "U";
}
else
{
CountryCode = "O";
}
|
|
|
|
|
soniaiq wrote: string mobshort = demo.Substring[0,3];
change to
string mobshort = demo.Substring(0,3);
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Expect everything to be hard and then enjoy the things that come easy. (code-frog)
|
|
|
|
|
Thanks a lot dave,
wen i solved this i am getting other errors
if i comment this below part no errors but i need tat
if (mobshort == 971)
string CountryCode = "U";
}
else
{
CountryCode = "O";
}
|
|
|
|
|
You're missing an opening brace {
if (mobshort == 971)
{
string CountryCode = "U";
}
else
{
CountryCode = "O";
}
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Expect everything to be hard and then enjoy the things that come easy. (code-frog)
|
|
|
|
|
And you have to make declaration before "if"
string CountryCode;
if (mobshort == 971)
{
CountryCode = "U";
}
else
{
CountryCode = "O";
}
Or you can do it on one line
string CountryCode = (mobshort == 971)? "U" : "O";
|
|
|
|
|
soniaiq wrote: demo.Substring[0,3];
Should be demo.Substring(0,3);
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
|
Well, that really doesn't help much without knowing which lines are the offending lines. You may need to look further into the code, sometimes the problem line can have a root problem elsewhere in the code.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
|
Cool deal
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
Good evening Everyone
My VS is behaving n an unnormal way. I have 9 Project in a Solution and i have set one of the Projects as a Startup Project and created a Setup project, after i Built it to create an exe, The Project that gets Started is not the one that i set as a Startup. The Strange this is that the Project that start is the first in the list(Solution Explorer). i rebuilt the Setup Project but still no luck. I went to the Solutions Properties and i made Sude that the Project is Selected as a Startup object, but still my Project is not selected as a Startup
What is Wrong
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
Hi all ,
As you know , when implementing salted hash technique , we go through the following steps:
1)Generate a random salt using classes in Cryptography namespace.
2)Get Password
3)combine password and salt and hash it
4)Storing the salt in a field called SALT.
5)Storing the hashed value in a field Called Password
Also we have a field called Username.
When Authenticating , we follow these steps:
1)Get Username
2)Get Password
3)Combine entered password with salt in database
4)Hash it and then compare it to Password
5)If both matches , the user is valid.
My question is that is it possible to Store salt inside password field instead of creating a seperate field for salt?So if attcker breaks into DB , he cannot extract the salt value and will not know what salt is.
And another question is that is it a good idea to also Salt-Hash username?If yes , how do you implement this?
Note that I use a uniqe salt for each password.
Thanks in advance.
modified on Thursday, September 18, 2008 12:49 PM
|
|
|
|
|
DotNetWWW wrote: that is it possible to Store salt inside password field instead of creating a seperate field for salt?
Yes. That's a good method. Steps could be,
1 - Generate random salt
2 - Append salt with the plain text and calculate hash
3 - Append salt bytes with the hashed bytes and return base64 string.
For verifying you can follow,
1 - Get the hash bytes from base64 string.
2 - Extract original salt from the byte array. Usually hash algorithm will have a predefined hash size. MD5 uses 128 bit hashing.
3 - Calculate hash again with the plain text and extracted salt.
4 - Verify the newly created hash and the original one.
DotNetWWW wrote: is that is it a good idea to also Salt-Hash username
I think it is not necessary.
|
|
|
|
|
N a v a n e e t h wrote: DotNetWWW wrote:
is that is it a good idea to also Salt-Hash username
I think it is not necessary.
I agree. No real point in doing that, unless he wants to make the username unreadable and that may backfire on him.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
Thanks for your answers.
Isn't is useful to salt-hash username?In that case attacker can not understand which record corresponds to which user. Doesn't it make the job harder for attacker?
Another point is that we implement all algorithms for hashing and also combining password and salt in code , as you know , .Net code is easily decompiled and in case of using a protector like XenoCode , It is still possible to access program code , so If attacker can read code , he will understand everything about algorithm and the way we combine password and salt , what is your suggestion?
|
|
|
|
|
DotNetWWW wrote: so If attacker can read code , he will understand everything about algorithm and the way we combine password and salt , what is your suggestion?
Attacker can read the algorithm, but since you are using random salt, it is tough hack into some account. But if he is getting the code, chance for attacking is high. You could change the design probably.
|
|
|
|
|
DotNetWWW wrote: is it a good idea to also Salt-Hash username?
Not really because a one way hash will make it difficult to retrieve a lost username. If a hacker gets into your database and sees the usernames, they really don't help him/her at all when the passwords are hashed.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
DotNetWWW wrote: My question is that is it possible to Store salt inside password field instead of creating a seperate field for salt?So if attcker breaks into DB , he cannot extract the salt value and will not know what salt is.
No. You need to get the salt value when you verify a password that the user enters.
You could scramble the salt in some way to make it harder to use, but that is just security by obfuscation so it doesn't add any real strength to the security.
DotNetWWW wrote: And another question is that is it a good idea to also Salt-Hash username?
No. What would be the point of protecting the user names? They can be seen in plain text on the screen when a user types it in...
Generally user names are not encrypted, as they are so easy to guess or intercept anyway.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
What's going on here then?
public struct Bobbins
{
public int X;
}
class Program
{
static void Main(string[] args)
{
Bobbins[] memory = new Bobbins[100000000];
for (int index = 0; index < memory.Length; index++)
{
memory[index] = new Bobbins();
}
Console.ReadLine();
}
}
So here I create an array containing 100 million bobbins structs. I know the for loop isn't necessary but it will be in a minute. 700ms later the program is waiting for me to hit enter and task manager tells me its taking up 400 million bytes of memory. This is good; I like this. My struct contains just an integer of 4 bytes, there's 100 million of them so it all adds up.
Now, if I change bobbins from a struct to a class, I'd expect the memory to double. My class should still be 4 bytes in length and my array now contains 4 byte references to the class (instance). 8 bytes per array element. Infact, 16 seconds after running the application My memory usage is 1.6GB, a total of 16 bytes per element.
Don't get it. Is there some overhead in size on classes?
Regards,
Rob Philpott.
|
|
|
|
|
I guess I should have read your entire post!
Rob Philpott wrote: Is there some overhead in size on classes?
There's definitely overhead for each object.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
|
Ah, there it is in black and white. Perfect.
Thanks Alan.
Regards,
Rob Philpott.
|
|
|
|