Dynamics 365 Business Central: Strong Password Generator (Random text)

Dynamics 365 Business Central

Hi, Readers.
Today I would like to share a mini tip of Business Central, how to generate a strong password with Business Central.

First, what is a strong password? It is long unique password, contains uppercase letters, lowercase letters, numbers, and special characters.
There are many tools to do this, and Chrome also has the following standard features.
Generate a password:

But it looks like there are no special characters.

No matter, in this post I will describe how to generate a strong password with Business Central. Actually it’s not that hard. This time we use codeunit 1284 “Password Handler”.
And there is a procedure GeneratePassword(Length: Integer): Text.

Let me do a test: Create a new Strong Password Generator page that randomly generates a strong password of password lengths of 15-character.

Well, very good.

Test Video:

Source Code:

page 50101 "Strong Password Generator"
{
    PageType = Card;
    ApplicationArea = All;
    UsageCategory = Administration;

    layout
    {
        area(Content)
        {
            group(General)
            {
                field(StrongPassword; StrongPassword)
                {
                    Caption = 'New Strong Password';
                    ApplicationArea = All;
                    Editable = false;

                    trigger OnAssistEdit()
                    var
                        PasswordHandler: Codeunit "Password Handler";
                    begin
                        StrongPassword := PasswordHandler.GeneratePassword(15);
                    end;
                }
            }
        }
    }

    var
        StrongPassword: Text[100];
}

Finally, because we can’t generate random text in Business Central, the Random(Integer) Method can only return a pseudo-random number. Use this method can generate a random text.
But if this standard rule does not work for you, you can refer to codeunit 1282 “Password Handler Impl.” to write the generation rule you need.

END

Hope this will help.

Thanks.

ZHU

コメント

Copied title and URL