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")<>"" then
  values("password") = md5(values("password"))
else
  values.Remove("password")
end if]);

 

BCRYPT:

 

if values("password")<>"" then
  values("password") = getPasswordHash(values("password"))
else
  values.Remove("password")
end if

See also:

Event: ProcessValues<PageName>

Events: Before record updated

Security: Encryption

About Security API