Please enable JavaScript to view this site.

Navigation: Advanced topics > Programming topics > Security API > Methods

Password hashing

Scroll Prev Next More

 

You can hash your password manually using events.

 

Let's say that you want to provide an admin with direct access to the Login table. To do so, add the following code to the BeforeAdd event of the Login table:

 

For BCRYPT:

 

$values["password"] = getPasswordHash($values["password"]);

 

For MD5:

 

$values["password"] = md5($values["password"]);

 

Editing is a bit trickier and there are several approaches available and here is one of them.

 

On the Edit page, the password field is empty by default. If you do not want to change the password - leave it empty. If you want to change it - enter a new password. This will require us to implement the following events:

Edit page: Process record values event

$values["password"]="";

Edit page: BeforeEdit event

MD5:
 

if ($values["password"]!="")
$values["password"] = md5($values["password"]);
else
unset($values["password"]);

 

BCRYPT:

 

if ($values["password"]!="")
$values["password"] = getPasswordHash($values["password"]);
else
unset($values["password"]);

See also:

Event: ProcessValues<PageName>

Events: Before record updated

Security: Encryption

About Security API

 

Created with Help+Manual 7 and styled with Premium Pack Version 3 © by EC Software