|
|
It is in title of Text/image printing counter a program that can print all kinds of text and all kinds of images in C#. To further information it has a button of Browse the documented that to be printed then after you browse it will read the document then specify the size of a bondpaper whether it is short,long or a4.
|
|
|
|
|
This is not any clearer than the first time you posted it.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Is there a reason you created a new account to post something that is as unclear as your other post?
|
|
|
|
|
|
It is in title of Text/image printing counter a program that can print all kinds of text and all kinds of images in C#. To further information it has a button of Browse the document or image that to be printed then after you browse it will read the document then specify the size of a bondpaper whether it is short,long or a4.
|
|
|
|
|
Do you have a specific question?
/ravi
|
|
|
|
|
Sorry doesn't get clear picture of your requirement, can you explain with an example.
|
|
|
|
|
Very very obscure. Not at all clear.
|
|
|
|
|
hello evry body
i have mikrotik server and i need to make broadband connection using windows form application i need ur help i need this form contain user name and password
|
|
|
|
|
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
Use the "Improve question" widget to edit your question and provide better information.
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
|
|
How to insert image on pixel using c# code
|
|
|
|
|
What do you mean by: "insert image on pixel"?
Veni, vidi, abiit domum
|
|
|
|
|
A high-tech microdot[^]?
=========================================================
I'm an optoholic - my glass is always half full of vodka.
=========================================================
|
|
|
|
|
Do you mean: "how do you change a pixel in an image?" ... or: "how do you read an image, calculate the row/column adjustment necessary to insert a pixel, and compose a new image with the pixel added?"
“But I don't want to go among mad people,” Alice remarked.
“Oh, you can't help that,” said the Cat: “we're all mad here. I'm mad. You're mad.”
“How do you know I'm mad?” said Alice.
“You must be," said the Cat, or you wouldn't have come here.” Lewis Carroll
|
|
|
|
|
I have a horrible feeling he wants to insert a whole image in the space of a pixel...
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
|
Let me rephrase your question:
Quote: How to read an image pixel by pixel using C#
Please correct me if i am wrong.
|
|
|
|
|
Hi to all,
This is with continuation of my previous question here.
I am using Microsoft Visual Studio 2010 Ultimate, C# Winforms & MySql Database.
I am trying to use BCrypt class by Derek Slager for creating and authenticating username and password. A form is use to create new user to save Username and Password to database, but this Password is not the plaintext one, it is hashed using BCrypt.HashPassword method. I am using binding source for the form, so I am using a dummy textbox which will hold the hashed value of plaintext user entered in password textbox. Then I bind the controls using following:
public void BindControls()
{
txtUser.Text = null;
txtPass.Text = null;
txtHash.Text = null;
txtID.DataBindings.Clear();
txtUser.DataBindings.Clear();
txtHash.DataBindings.Clear();
txtID.DataBindings.Add(new Binding("Text", bs, "userID"));
txtUser.DataBindings.Add(new Binding("Text", bs, "userName"));
txtHash.DataBindings.Add(new Binding("Text", bs, "userPass"));
}
As plaintext password is not required to save in Database, there is no need to bind it. txtHash will get hashed password after user enter plaintext password in txtPass textbox on LeaveEvent as follows:
private void txtPass_Leave(object sender, EventArgs e)
{
txtHash.Text = null;
txtHash.Text = BCrypt.HashPassword(txtPass.Text.Trim().ToString(),BCrypt.GenerateSalt(12));
}
Then called the save method of User class when user click Save Button:
private void btnSave_Click(object sender, EventArgs e)
{
this.Validate();
bs.EndEdit();
if (!ds.HasChanges())
{
MessageBox.Show("No changes to save.", "Saving Records");
return;
}
try
{
fUser.SaveUser(ds);
MessageBox.Show("Records saved.", "Saving Records");
}
catch (Exception exceptionObj)
{
MessageBox.Show(exceptionObj.Message.ToString());
}
}
User class save method is follows:
public void SaveUser(DataSet oDs)
{
oCn = da.GetConnection();
oTrn = oCn.BeginTransaction();
sqlDataMaster = new MySqlDataAdapter();
try
{
if (oCn == null)
{
oCn.Open();
}
sInsProcName = "prInsert_User";
insertcommand = new MySqlCommand(sInsProcName, oCn, oTrn);
insertcommand.CommandType = CommandType.StoredProcedure;
insertcommand.Parameters.Add(new MySqlParameter("nNewID", MySqlDbType.Int32, 0, "userID"));
insertcommand.Parameters["nNewID"].Direction = ParameterDirection.Output;
insertcommand.UpdatedRowSource = UpdateRowSource.OutputParameters;
insertcommand.Parameters.Add("mUserName", MySqlDbType.VarChar, 50, "userName");
insertcommand.Parameters.Add("mUserPass", MySqlDbType.VarChar, 60, "userPass");
sqlDataMaster.InsertCommand = insertcommand;
sUpdProcName = "prUpdate_User";
updatecommand = new MySqlCommand(sUpdProcName, oCn, oTrn);
updatecommand.CommandType = CommandType.StoredProcedure;
updatecommand.Parameters.Add("nNewID", MySqlDbType.Int32, 0, "userID");
updatecommand.Parameters.Add("mUserName", MySqlDbType.VarChar, 50, "userName");
updatecommand.Parameters.Add("mUserPass", MySqlDbType.VarChar, 60, "userPass");
sqlDataMaster.UpdateCommand = updatecommand;
sqlDataMaster.Update(oDs.Tables[0]);
oTrn.Commit();
}
catch (MySqlException e)
{
oTrn.Rollback();
MessageBox.Show(e.ToString());
}
}
Data is saved successfully, no problem is there. In the password field of Table it is shows the hashed value. But problem arises when I need to validate the password via Login form. User enter username and password and click login, which fires following code:
private void btnCheck_Click(object sender, EventArgs e)
{
string hashpassdb = dm.GetData("Select userPass from userMaster where userName = " + "'" + txtUser.Text.ToString() + "'" ).Rows[0]["userPass"].ToString();
if (!BCrypt.CheckPassword(txtPass.Text.Trim().ToString(), hashpassdb))
{
MessageBox.Show(hashpassdb);
MessageBox.Show("Invalid Username or Password.");
MessageBox.Show(BCrypt.HashPassword(txtPass.Text.Trim().ToString(), hashpassdb));
}
else
{
MessageBox.Show("Login Successfull");
((frmMain)this.MdiParent).EnableMenu();
this.Close();
}
}
private bool DoesPasswordMatch(string userEnteredPassword, string hashedPwdFromDatabase)
{
return BCrypt.CheckPassword(userEnteredPassword, hashedPwdFromDatabase);
}
dm is the instance of DAL class which contains GetData method, accepts Sql command as parameter and returns DataTable. The problem is hashed values never matched with the one using in validation, as notice in code I've use MessageBox.Show method just to ensure what value is return from Database hashed password and the one return by BCrypt.Hashpassword. They both are different. Also, I am using VarChar(60) datatype for holding hash value in Mysql.
I need some guidance about what I am doing wrong here? any help is much appreciated.
Thanks
Ahmed
|
|
|
|
|
I had a very quick look at what was going on - essentially, this
if (!BCrypt.CheckPassword(txtPass.Text.Trim().ToString(), hashpassdb))
is wrong - which I think stems from this
txtHash.Text = BCrypt.HashPassword(txtPass.Text.Trim().ToString(),BCrypt.GenerateSalt(12));
The crux is you're generating a NEW salt when you use BCrypt.GenerateSalt(12) - you should use the original hashpassdb instead (I don't know how you are going to do that)
The reason is, hashpassdb contains the original salt value. The clue is in BCrypt's code, function CheckPassword
public static bool CheckPassword(string plaintext, string hashed) {
return StringComparer.Ordinal.Compare(hashed, HashPassword(plaintext, hashed)) == 0;
}
'g'
|
|
|
|
|
Garth J Lancaster wrote:
if (!BCrypt.CheckPassword(txtPass.Text.Trim().ToString(), hashpassdb))
is wrong - which I think stems from this
txtHash.Text = BCrypt.HashPassword(txtPass.Text.Trim().ToString(),BCrypt.GenerateSalt(12));
Thanks for your reply...
But txtPass.Text.Trim().ToString() is not generated from txtHash.Text = BCrypt.HashPassword(txtPass.Text.Trim().ToString(),BCrypt.GenerateSalt(12));
Infact, there is no txtHash textbox in user login form, it only has 2 textboxes, username and password. Then uses password value (txtPass.Text.Trim.ToString())with BCrypt.CheckPassword routine with hashpassdb (retrieve from database).
txtHash textbox is used in the Form where new user is created with Username and password. It is actually hidden textbox, use only to save hash value of password in database.
|
|
|
|
|
Im sorry, I think you're missing the point - you're not getting the correct results because you're not comparing 'apples with apples'
If you start with a password A
And generate Hashed-Salted-Password-A
(and then store Hashed-Salted-Password-A)
And then want to compare that with Password B
You have to compare Hashed-Salted-Password-A with HashPassword(Password B, Hashed-Salted-Password-A)
'g'
|
|
|
|
|
Garth J Lancaster wrote: Im sorry, I think you're missing the point - you're not getting the correct results because you're not comparing 'apples with apples'
Actually I am also trying to do the same, but what I don't understand is why it is not working.
Let me re-phrase my problem without code:
Form User Creation:
1.New User create with Username and Password, password is hashed and stored in db,using a hidden textbox (txtHash).
Form User Login:
1. User enter username and password.
2. Get hashed password from db and stored it in hashpassdb string.
3. Now compare the user entered password with BCrypt.CheckPassword(txtPass.Text.Trim().ToString(), hashpassdb))
I know there is something wrong in logic behind User login form, but I am unable to track it. I've used breakpoints in BCrypt.Checkpassword function to check what values are in, and they are different. But the question is why?
|
|
|
|
|