IMetabaseSecurity.HashPassword

Syntax

HashPassword(Password: String): String;

Parameters

Password. Password that must be hashed.

Description

The HashPassword method hashes the password.

Example

To execute the example, place the following components on the form: Button, EditBox, Memo  named Button1, EditBox1, Memo1, respectively.

Add links to the Metabase, Collections, and Forms system assemblies.

The example is a handler of the OnClick event for the Button1 component.

Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
    MB: IMetabase;
    MS: IMetabaseSecurity;
    User: IMetabaseUser;        
    HashP: String;
    MbPassHistory: IPasswordHistory;
    Lic: Object;
Begin
    MB := MetabaseClass.Active;
    
// Check out license to work with security manager
    Lic := Mb.RequestLicense(UiLicenseFeatureType.Adm);
    MS := MB.Security;
    
// Get parameters of the ADMIN user
    User := MS.ResolveName("ADMIN"As IMetabaseUser;
    HashP := MS.HashPassword(EditBox1.Text);
    MbPassHistory := User.PasswordHistory;
    
// Add the specified password to the history
    If MbPassHistory.Contains(HashP) Then
        Memo1.Lines.Add(
"Password '" + EditBox1.Text + "' is already in hystory");
        
Else MbPassHistory.Insert(HashP);
            Memo1.Lines.Add(
"Password '" + EditBox1.Text + "' is added to the history");
    
End If;
    
// Save changes
    MS.Apply;
    
// Check in license
    Lic := Null;
End Sub Button1OnClick;

After executing the example the Memo component displays the result of checking the specified password in the EditBox component:

See also:

IMetabaseSecurity