Encrypting a text stringΒΆ

encrypt()

Encrypt a password


SYNTAX

encrypt(text [, algorithm])

Returns a text string in encrypted form. The most likely use for this function is to store a password in secure form in a Sculptor file. The password is encrypted before being stored, and is therefore no use even if an unauthorised person finds it in the database. To check a supplied password, encrypt it and compare the encrypted versions.

Since Sculptor version 6.1.0 the encrypted hash algorithm can be selected with the algorithm optional parameter.

The encrypt() function is used in Sculptor in the server security system, to encrypt user passwords before they are stored.


EXAMPLE

!file Users "/sculptor/security/users" update
!temp Password,,a16

...
+textbox PasswordBox at 106,62 {
     field = Users.UserPassword
     mode = EM_NOECHO
}

+textbox Password2Box at 106,84 {
     field = tmp.Password
     label = "Retype password"
     mode = EM_NOECHO
}
...
     if (tmp.Password != Users.UserPassword) {
          error " Cannot save changes - the passwords didn't match "
     } \
     else {
          Users.Algorithm = HAD_SHA256
          Users.UserPassword = encrypt(Users.UserPassword, HAD_SHA256)
          write Users traps = WRITETRAP
    }

RELATED TOPICS

Servers

Server security

Include file security.h