4873 Posts in 7171 Topics by 1471 members
|Go to End|
14 September 2009 at 8:36am
How exactly is the admin password encrypted?
I've created a registration form that encrypts the password with sha1. When I create a password 'password' in the table, it comes out as 5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8, and as the admin password is also 'password' I'd expect it to be the same, but it's not - it's fy17qyc55m0o8kc0oks00os8w0gk44w, but the PasswordEncryption field for admin says sha1 anyway.
Can someone tell me how to get the encryption in my form working the same way as the admin record?
14 September 2009 at 9:02am
Passwords are hashed and salted so they are unique. If you just hashed passwords you could pretty easily start guessing passwords.
The only way to get them the same is if they use the same salt and like I said, thats a security flaw. You can however override the default behaviour by setting Security::set_password_encryption_algorithm('sha1', false); in your config - false turning off salting
15 September 2009 at 9:26am Last edited: 15 September 2009 9:27am
How would I go about generating a new salt and applying it to a new password in order to make it unique?
Is that even what I have to do?
15 September 2009 at 9:39am
You can hash and salt a given string by running it through Security::encrypt_password("password"); and that will return you an array - the password, the salt and the hash. I think however, if you are making a registration form and you are saving the data into the Password field of the Member object it will do the salting and hashing for you.
3 October 2009 at 7:48pm
Is there a way I can change the way the Login form checks what is typed in the password field with the database? Like, a .php file in Security or something? So that it only changes the password to sha1 with no salt and just checks it that way?
Sure, there'll be a security issue there, but this is just for experimental purposes anyway
5 February 2013 at 4:11pm
Hi Willr. I don't know if this is appropriate to add my issue here. This is an old post but i seem to have an issue to auto-hashing & salting on front-end. I am currently using SS 3.0.3 and I have a custom sign-up form on the front-end and I am using ConfirmedPasswordField but it seems the saved password is different since all the users I sign-up using the front-end form cant login.
Does the auto hash / salt may be causing some issues?
,new TextField('Email', 'Email *')
,new TextField('JobTitle', 'Job Title *')
, new ConfirmedPasswordField('Password', 'New Password')
if($member = DataObject::get_one("Member", "`Email` = '". Convert::raw2sql($data['Email']) . "'"))
$form->AddErrorMessage('Email', "Sorry, that email address already exists. Please choose another.", 'bad');
$member = new Member();
if($userGroup = DataObject::get_one('Group', "Code = 'staff'"))
|Go to Top|