|
In the Joomla Admin Console, on the Global Configuration / System settings page, there is a Secret Word listed, is this not the salt?
|
|
|
|
|
Sorry i should explain better. When you register a new user with joomla it adds a randomly generated salt to the md5 password. so the password in the password field looks like hash:salt (seperated by a colon in the database)
I think this php code helps. I don't know php that well but well enough to read it.
<form action='login.php' method='post' name='login'>
<b>User:<b> <input type=text name='username' maxlength=15 width=18><br/>
<b>Password:<b> <input type=password name='password' maxlength=15 width=18><br/>
<input type=submit value='Login'>
</form>
<?php
$dbaddress='localhost'; $dbuser='root'; $dbpass='root'; $dbname='yourdatabase';
$dbcnx = mysql_connect($dbaddress,$dbuser,$dbpass)
or die("Could not connect: " . mysql_error());
mysql_select_db($dbname, $dbcnx) or die ('Unable to select the database: ' . mysql_error());
$query = mysql_query("select password from jos_users where username = \"" . $_POST["username"] . "\"")
or die("Unable to validate login and password with the database:" . mysql_error());
$result = mysql_fetch_array($query);
$result = $result[0];
$parts = explode( ':', $result);
if (count($parts) < 2) $new_password = md5($_POST["password"]);
else {
$salt = $parts[1];
$new_password = md5($_POST["password"] . $salt) . ":" . $salt;
}
if ($new_password != $result)
{
echo "no login";
}
else
{
echo "successful validation";
}
?>
Thanks for replying,
Robbie.
|
|
|
|
|
Ive been researching for ages but maybe this can help anyone. Similar than above and kind of helps me in away.
$part = explode(":",$password);
$salt = $part[1];
$encrypted_password = md5($mypassword . $salt).":".$salt;
;
So maybe it works by making my vb.net app read the database, get the password and split the password into 2 parts with the :(colon) in the password. Then encrypt the password and add the salt to the password.
However now i think i have the theory, i have no idea how to implement it correctly. Can anyone give a basic example instead please?
Any help is great appreciated,
Robbie.
|
|
|
|
|
Looking at both sets of code, it looks like the md5 is generated from a combination of the password and the salt; then the salt is appended to the md5.
The first bunch of code does a split (expand) on the colon, and uses that to determine if the password has been salted or not. This has maybe been done to cater for an upgrade in Joomla security, but I don't know the history.
It would be better to see the code that is used to register a new user,to work out what they are doing. I'll maybe have a look later.
In the meantime, i am starting with the known values and seeing if i can recreate the stored value in the database.
|
|
|
|
|
Ok. Thanks for replying. It's really annoying me. Im trying to think and it's like when you get writers block. Theres nothing there. Like a head of compressed air.
|
|
|
|
|
I just had a thought.
You say you are trying to retrieve the password?
That won't be possible. Its been hashed with a one way algorithm - md5
All you will be able to do is a comparison for authentication purposes. i.e. provide a password and hash/salt it and then compare with the stored value.
|
|
|
|
|
Ah right i started like that at first but somebody said somthing different.
So still stuck. If the salt is randomly generated then how can i hash/salt the password then compare? The password has been hashed to md5 but the salting i can't do.
Any ideas?
Thanks for your time Dave.
|
|
|
|
|
because the salt is stored alongside the password (after the : )
1) user provides username and password;
2) use username to recover the password fieldvalue from the database table
3) extract the salt from result #2
4) use the password in #1 and the salt in #3 combine and hash to give password hash value
5) extract the hashed password from #2
6) compare #4 with #5 to validate
however, without looking at the php code used in joomla, can't say for sure thats what they are doing, would need to spend more time looking, maybe have a look tomorrow night, away to call it quits, as got an early start tomorrow.
Post how you get on, and i will look again hopefully tomorrow.
Dave
Don't forget to rate messages!Find Me On: Web| Facebook| Twitter| LinkedInWaving? dave.m.auld[at]googlewave.com
modified on Monday, July 12, 2010 2:34 AM
|
|
|
|
|
That sounds OK to me.
|
|
|
|
|
Don't know how you are getting on, but i did some digging in the original joomla distro today, to find out what they do.
As a starting point i wanted to see how they added the admin user to the database during the install and from that it would point me to the code libraries used to do the encryption and salt generation etc.
If you take a look at the installation\installer\helper.php file you will see the createAdminUser() method, and you can see the helper functions being called, namely genRandomPassword() , getCryptedPassword() . The interesting thing to note is the genRandomPassword is also used to generate the necessary random salts.
These methods are found in the library located at; libraries\joomla\user\helper.php along with a couple of others used internally. without knowing the ins and outs of php, the code is pretty easy to follow, and you should be able come up with suitable code to allow vb integration with the joomla db.
hope that heads you off in the right direction now.
|
|
|
|
|
Hi everybody,
one of the old-but-useful tools we work with collects thousands of large image files (meeting particular requirements) and copies them to a separate place on the network. By now this was done with a batch file processing a filelist from a textfile.
I'm trying to replace the tool by a .NET application, but the copy process seems to be a lot slower than the batch copy. After my approaches to split the copy process to different threads have failed, I'm examining a very simple process using a Backgroundworker:
Private Function BGW_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) As Boolean Handles BGW.DoWork
Dim i As Integer = 0
Dim copyResult As Boolean = False
Dim args As copypathArgs = e.Argument
For Each fl As String In args.FileArray
i += 1
e.Result = i
copyResult = DoCopy(Path.Combine(args.sourceDir, fl), Path.Combine(args.targetDir, fl))
BGW.ReportProgress(i / args.FileArray.Length * 100, fl)
Next
End Function
Private Function DoCopy(ByVal source As String, ByVal target As String) As Boolean
Dim overwrite As Boolean = True
Try
My.Computer.FileSystem.CopyFile(source, target, overwrite)
Return True
Catch ex As Exception
Return False
End Try
End Function
The problem is that copying a complete array of files takes much longer than the old method using a batch file. As a consequence and considering a large amount of files, the users react more or less like "I want my old batch file back" to avoid double (sometimes even triple) copy time.
Is the copy process in .NET really so much slower? Are there any other methods which have a better performance? Any other recommendations?
Thank you
Michael
|
|
|
|
|
this may or may not help: reporting progress is rather expensive; if all you do is deal with a percentage, make sure not to call BGW.ReportProgress() unless the percentage has really changed.
FWIW: I don't like the way you swallow exceptions; you turn them into a bool result, then store it in copyResult (without accumulating) and finally ignore it completely; a copy utility should report about the problems it encounters. In fact, the entire DoCopy method does not make sense at all.
|
|
|
|
|
Thank you for the FWIW (what ever that abbreviation stands for???). It might look even more confused than I actually am because I deleted several lines (e.g. almost everything around the arguments) before posting, trying not to mix the issue of copy performance with any other issues.
The idea of the DoCopy method is to have a false value in case the copy fails, which is then supposed to be reported back to the caller (an Excel sheet). Of course I'd appreciate advice how to solve that in a more elegant way.
Thanks for now
Michael
|
|
|
|
|
"it failed" is not what I want as a result message, as it provides no clue on what caused the failure, hence the user does not know what to do next.
FWIW (Google it!): Simplifying published code you're not happy about often isn't the best way to get things solved.
|
|
|
|
|
Purpose is to Invoke The Parent from a class.
From 'User Control' Parent/Paren form can be accessed.
'Me.Parent 'OR
'Me.ParentForm
'Me.Parent.Invoke(......)
But I want to do above from a class.
I did using following code:
Private Parent As System.Windows.Forms.Control
Public Sub New (ByVal Parent As System.Windows.Forms.Control)
'Any way to access Parent Form From a class without passing Parent as Argument?'<br>Me.Parent = Parent
End Sub Is there any alternative without passing Parent Form as Argument to Invoke Parent's Thread?
|
|
|
|
|
Hi,
each WinForms Control has a Parent property. It gets set when the Control is added to its parent's Controls collection, which cannot happen until after its constructor finishes. Hence, no you can't predict its future parent inside its constructor, but you will get it for free later on.
If the Controls get added in Visual Designer, their parent will have been set at the time your Form loads (use the Form.Load event). If you don't know when the parent is going to be set (e.g. because all things happen dynamically), then you could use the Control.ParentChanged event to your advantage.
|
|
|
|
|
Plz read the following Example. You are right only for ctrl1 Class. But my Question was about Class1.
Is there any way to access Parent from Class1?
'Form1
Public Class Form1
Inherits Form
End Class
'Class1
Public Class Class1
'here I want to access form1. not using frm1.member and not usinig dim ff as new form1, ff.member
'I just want to access that form using me.parent
Sub ParentAccess()
Me.Parent.Text = "It's a compile time Error"
'Error:- Parent is not a member of Class1
End Sub
End Class
'User Control1
Public Class ctrl1
Inherits ComboBox
Sub ParentAccess()
Me.Parent.Text = "Very easy to access but my class1 don't have the statment like Inherits ComboBox"
'No Error:
End Sub
End Class
|
|
|
|
|
You can if you set a reference to the form in Class1 but that is a very bad design, unless Class1 is strictly meant as a helper class for that form. Class1 is not an inherited Control class like ctrl1, so it doesn't have Parent property. You will have to define the Control type property and set the property accordingly.
Beside you won't be able to access to the combobox of the form unless you set it to public, which is another bad design.
|
|
|
|
|
How to get name in FlowLayoutPanel child control when I click him. Control is PictureBox
|
|
|
|
|
In the click handler for the control, you can use:
Dim c As Control = DirectCast(sender, Control)
Dim cName As String = c.Name
But, you're not providing enough detail about what you're clicking on or other details that I fear you may be leaving out.
|
|
|
|
|
I give picture from scaner
Dim img As New PictureBox
......
wiaItem = DirectCast(Marshal.CreateWrapperOfType(wiaObj, GetType(ItemClass)), ItemClass)
imageFilename = Path.GetTempFileName()
....
img.Image = Image.FromFile(imageFilename)
FlowLayoutPanel1.Controls.Add(img)
Dim i As Integer
i = FlowLayoutPanel1.Controls.Count
FlowLayoutPanel1.Controls.Item(i - 1).Name = "snimka" & i
and I want to give picture control name when click over him
|
|
|
|
|
Most often when people ask for a Control's name, they are doing something very wrong. Event handlers get a sender parameter that is much better than a name.
|
|
|
|
|
Hi, I need help displaying a list of items in a combo box. My problem is this, I want to display a name "Drive Time" and when it is selected i want to use the value of the variable "002302" it is like:
Drive Time = 002302
I want to display "Drive Time" and I want to use the value "002302" when it is selected in the combobox. I hope this made sense. I appreciate the help.
Thanks
|
|
|
|
|
It would be best if you created a structure to hold both items as a single datatype, and then you create a List(Of item) and bind the ComboBox to the List(Of T). Then in your ComboBox.SelectedIndexChanged you can reset the textbox Like this
Public Class Form1
Private Structure Items
Private strName As String
Private intID As Integer
Public Property Name() As String
Get
Return strName
End Get
Set(ByVal value As String)
strName = value
End Set
End Property
Public Property ID() As Integer
Get
Return intID
End Get
Set(ByVal value As Integer)
intID = value
End Set
End Property
End Structure
Private lstItems As List(Of Items)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
lstItems = New List(Of Items)
For i As Integer = 0 To 5
Dim newItem As New Items
newItem.Name = "Item " & i.ToString
newItem.ID = i
lstItems.Add(newItem)
Next
ComboBox1.DataSource = lstItems
ComboBox1.DisplayMember = "Name"
ComboBox1.ValueMember = "ID"
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
TextBox1.Text = CType(ComboBox1.SelectedItem, Items).Name
End Sub
End Class
Hope this helps
Happy Coding
|
|
|
|
|