|
There are two ways:
1. Examine the algorithm used to create the hash code so that you can invent a way of calculating the shortest possible strings that result in a specific hash code.
2. Loop through all possible combinations of characters and create a hash code from them and compare to the stored hash code.
Neither of these are easy or fast. The purpose of hashing the passwords is that it should not be possible to recreate them.
Just give your client a new password.
Experience is the sum of all the mistakes you have done.
|
|
|
|
|
Create a new password, hash it using the method in the application and then insert it into the field.
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
|
|
|
|
|
I have an application where I use the web browser control and allow JScript to interact with my application though the object for scripting class that is set to com visible.
I've been looking around the and I can't seem to find the limits of what data types/object you can pass to and from JScript. I know the basics work like int, float, string, ect...
But I'd like to pass XML directly, but not as text due to the overhead of phrasing it. So does anyone know the limits or where to find out more information about the C# to JScript COM interop though the web browser control?
I know the following works:
public string feedJScriptXML()
{
XmlDocument myXMLDoc = new XmlDocument();
myXMLDoc.Load("C:\myXMLfile.xml");
return myXMLDoc.OuterXml;
}
Then send it as text to JScript and use it in JScript by
function readCsharpXML()
{
var xmlString = window.external.feedJScriptXML();
var theXML = new ActiveXObject("Microsoft.XMLDOM");
theXML.load(xmlString);
}
The above is 100x better than writing the XML to a file and then reading the file into JScript... I think it might be better if I could dump the XML document into the JScript directly to save the extra phrase time... This application needs to read the XML 100's of times a minute so every little bit helps...
The only information I've found on this is very basic via the MSDN C# tutorials http://msdn2.microsoft.com/en-us/vcsharp/bb798044.aspx?wt.slv=RightRail[^]
and the WebBrowser.ObjectForScripting information at MSDN: http://msdn2.microsoft.com/en-us/library/system.windows.forms.webbrowser.objectforscripting(VS.80).aspx[^]
|
|
|
|
|
I doubt you can return a .NET XmlDocument to Javascript but you might be able to return an MSXML interface. Of course then you don't have the simplicity of using XmlDocument in your C# code so I don't know if that is of any benefit.
SpacixOne wrote: but not as text due to the overhead of phrasing it.
you mean parsing it I guess. Are you sure the overhead is significant to warrant consideration? Also I have no idea what you are going to do with it in the javascript but I seems likely you want to copy some values from the XML into HTML elements for display etc. Can't you just do that using the DHTML interface from the C# code directly?
Also when it comes to altering a HTML display in an embedded browser control you can generate the HTML using XML/XSLT transformation and then use one DHTML call to transfer the results into the browser document rather than using DHTML to access each discrete HTML element.
led mike
|
|
|
|
|
led mike wrote: Also when it comes to altering a HTML display in an embedded browser control you can generate the HTML using XML/XSLT transformation and then use one DHTML call to transfer the results into the browser document rather than using DHTML to access each discrete HTML element.
So you mean just write the whole page out to an XML file instead of just the data... I never thought about doing it that way... crap wish I we thought something along these lines a few weeks back (or posted it on here to get your comment back then) as that might have been easier in the long run.
Currently to far along to change that much though
Right now I'm just setting it up so there is an easy to configure display (IE HTML display) that allows to see the data that is saved via XML for web posting.
led mike wrote: I doubt you can return a .NET XmlDocument to Javascript but you might be able to return an MSXML interface. Of course then you don't have the simplicity of using XmlDocument in your C# code so I don't know if that is of any benefit.
Wonder how hard that would be to write a convert function, yet though converting it would still have the extra step and might not be much a benefit at all... Sounds like I may end up on worth than failure heh
|
|
|
|
|
SpacixOne wrote: So you mean just write the whole page out to an XML file instead of just the data
Yes or even sections. That's what all this nonsense about Web Parts and others are about. You can divide your page into sections with say a DIV element as a parent to all the content. Then you can transform XML/XSLT into the new content for that DIV and update just that part of the page. It's nothing new, it's all been around since like IE 4 I believe.
led mike
|
|
|
|
|
A long time ago I used XML Data Islands to contain the data for a very dynamic browser based application. This is essentially what you are doing. Have you thought about AJAX or script callbacks to get chunks of rather than the whole thing?
only two letters away from being an asset
|
|
|
|
|
The way I'm doing this is sort-of like AJAX without using the JScript XML HTTP GET request, but a custom API function call built into my API. The JScript can call for new data when it needs it or the user can invoke it to update/refresh manually.
As I posted in the example code I didn't add all of the XML phrasing stuff, but a simple load and dump the XML. For the example it could have been just as easy to use File.readalllines on String.Join them it together to send the string.
string[] XmlLines = File.ReadAllLines("C:\randomXMLfile.xml");
string XmlString = String.Join("\n", XmlLines);
But then where isn't an XML document or node, which was the original point of my question. Anyway enough of my clarification rant, the data is already in chunks and my example doesn't show it.
|
|
|
|
|
To clarify, you are have coded you own version of an existing framework. Now then, what was the question?
only two letters away from being an asset
|
|
|
|
|
Mark Nischalke wrote: To clarify, you are have coded you own version of an existing framework.
I didn't recode and existing framework to my own version. AJAX requires a web server to serve an XML file. You open an JScript XML HTTP GET request and call an URL running a server side script (ASP.NET, PHP, and so on) that returns XML via a text string.
I'm using a WinForm C# application with a webbrowser control that is running a local JScript page to dynamically request and display data XML returned to it.
The page is setup as a JScript page so it is possible to easily change the interface (skinning, overall functionality, and so forth) without recompiling the application. The C# program just collects and then XML formats the data. This data could be posted to a webpage or just saved as XML on the users PC. The webbrowser control + JScript page allows the user to view it as it is being collected, or to view data that isn't saved (maybe logging is off) as it comes in.
Mark Nischalke wrote: Now then, what was the question?
My question was as stated in my orgianl post.
Is there a way to pass an System.Xml object to JScript via com using a [ComVisible(true)] class set to the WebBrowser.ObjectForScripting property of a web browser control?
|
|
|
|
|
It is possible to serve web pages, or handle http requests without a webserver.
It seems to me as though you are making this more complicated than it needs to be. Use xslt to transform you xml into the appropriate html to be displayed in a webbrowser control.
Insert the XML into a XML data island via the HTML DOM.
only two letters away from being an asset
|
|
|
|
|
I know what you mean but using the <xml src=""> data island makes it harder to port over to Mono.Mozilla.WebBrowser.dll for a gecko based browser control.
|
|
|
|
|
It is easier to give advice and answers when relevant information is stated up front. If this is a Windows app, you are guaranteed to have IE on the machine, why bother with trying to support others browser controls. I'm sure your project has a timeline and budget, does it including trying to develop something to support all possible combinations of technology?
Good luck
only two letters away from being an asset
|
|
|
|
|
Hi guys. I have the below code but am having problems with compiling the code. I get the following error when compiling the code. I know where the error is but do not know how to fix it. Can somebody please advise?
The error message is as follows:
"Operator '==' cannot be applied to operands of type 'method group' and 'bool'"
private void btnCancel_Click(object sender, EventArgs e)
{
this.Close();
this.Dispose();
}
OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=W:\CS Call Info\MobEmail.mdb");
OleDbCommand cmd;
private void btnLogon_Click(object sender, EventArgs e)
{
string sql = "SELECT UserName,Password FROM Users WHERE UserName = '"
+ txtboxUserName.Text + "' AND Password = '" + txtboxPassword.Text + "'";
OleDbCommand cmd = new OleDbCommand(sql, conn);
OleDbDataReader dr = cmd.ExecuteReader();
try
{
conn.Open();
}
catch (InvalidOperationException ex)
{
MessageBox.Show(ex.Message.ToString());
}
try
{
if (dr.Read == false)
{
MessageBox.Show("Invalid Username And Or Password Supplied", "Logon Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
this.DialogResult = DialogResult.OK;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
if (conn.State != ConnectionState.Closed)
{
conn.Close();
}
|
|
|
|
|
Kwagga wrote: //Read Database
if (dr.Read == false) //This is where the error is
is OleDbDataReader.Read a property?
led mike
|
|
|
|
|
Brilliant. Understood and rectified. It now works. Thanks a mill mate. Just needed somebody to point me in the right direction. Below the code changed and it works fine.
private void btnLogon_Click(object sender, EventArgs e)
{
string sql = "SELECT UserName,Password FROM Users WHERE UserName = '"
+ txtboxUserName.Text + "' AND Password = '" + txtboxPassword.Text + "'";
OleDbCommand cmd = new OleDbCommand(sql, conn);
conn.Open();
OleDbDataReader dr = cmd.ExecuteReader();
try
{
}
catch (InvalidOperationException ex)
{
MessageBox.Show(ex.Message.ToString());
}
try
{
while (dr.Read() == true)
{
this.DialogResult = DialogResult.OK;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
if (conn.State != ConnectionState.Closed)
{
conn.Close();
}
}
|
|
|
|
|
1. Read is a method so it needs brackets.
2. Your code is open for sql injection attacks. This article will help you to avoid them SQL Injection Attacks and Some Tips on How to Prevent Them[^]
4. You should open connection first in order to invoke ExecuteReader()
3. Use finally block to close connection.
|
|
|
|
|
Nice post. Reminds me of that old adage.
"You can lead a horse to water but you can't make him fish"
led mike
|
|
|
|
|
I am unable to figure out how to simulate a SHIFT+MOUSE_RIGHT_CLICK, I tried several samples without any luck, here is some of the code I am using to try and get it to work...
<br />
[DllImport("USER32.DLL")]<br />
public static extern int SendMessage(IntPtr hwnd, int<br />
msg, int character, int count);<br />
<br />
[Flags]<br />
public enum MouseEventFlags<br />
{<br />
LEFTDOWN = 0x00000002,<br />
LEFTUP = 0x00000004,<br />
MIDDLEDOWN = 0x00000020,<br />
MIDDLEUP = 0x00000040,<br />
MOVE = 0x00000001,<br />
ABSOLUTE = 0x00008000,<br />
RIGHTDOWN = 0x00000008,<br />
RIGHTUP = 0x00000010<br />
} <br />
<br />
--- THE ACTUAL CODE ---<br />
<br />
SetCursorPos(ox + xx, oy + yy);<br />
<br />
win32.SendMessage(phwnd, 0x0100, 0xA0, 0);
<br />
mouse_event((uint)MouseEventFlags.RIGHTDOWN, 0, 0, 0, 0);<br />
mouse_event((uint)MouseEventFlags.RIGHTUP, 0, 0, 0, 0);<br />
<br />
win32.SendMessage(phwnd, 0x0101, 0xA0, 1);
<br />
Looking for help, suggestions or a "Hey, your doing this wrong you tool!"
Best,
Mike
|
|
|
|
|
This won't be a very helpful reply, I'm sorry.
I'm curious though - why do you want to simulate a Shift+Mouse_Right_Click?
|
|
|
|
|
Edit: Oops. I figured you wanted to detect shift-right mouse click behavior, but I see you want to simulate that. No idea there really...
Standards are great! Everybody should have one!
|
|
|
|
|
Might be a mistake during your copy-pate of the example code but it looks like you're missing
[DllImport("User32.dll")]
static extern void mouse_event(MouseFlags dwFlags, int dx, int dy, int dwData, UIntPtr dwExtraInfo);
|
|
|
|
|
My guess is that you are missing the click. The reason why is that the coordinates sent to the mouse event MUST match the coordinates that the mouse is actually at. If not, windows ignores the event altogether. I would open Spy++ and make sure that all your messages are being sent identically as when you do it manually. I also didn't check your SendMessage syntax/data, so you may have done that wrong as well. If you fix the mouse_event problem and it still doesn't work, let me know and I will check the other. Good luck,
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
Just checked it out, the mouse click event works, my problem is that the shift key is not being depressed.
Does my shift code look ok?
|
|
|
|
|
What happens if you just send the SHIFT key (0x10)? I also wonder if, since you are sending a specific shift key, if you have to set bit 24 on the lparam sent with SendMessage. In the past I have also had instances when I had to use PostMessage for an application to receive the keystroke. If I were you I would go through the following progression:
1. Try using SendMessage (up + down) for something simple (like an 'a' 0x41).
2. Try using PostMessage (up + down) for something simple
3. Try using keybd_event (up + down) for something simple
If none of the above messages were received by your target application (and the last win32 error is not from your calls to the methods), then post your results so I can help some more. Otherwise, continue using the message type (Send, Post, or event) that worked from steps 1-3:
4. Modify your messages to send the Shift key (if it doesn't work, try sending the left or right specific shift keys; if you still get nothing, use Spy++ to see EXACTLY what each parameter is being set to, and mimick exactly those params)
After you complete these steps, you should be able to get your code working. Here is a reference for WM_KEYDOWN[^] if you need it. Let me know if this helps,
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|