zoukankan      html  css  js  c++  java
  • 随机字符串生成




    随机字符串生成
    function TfrmPWGenerate.btnGenerateClick(Sender: TObject): string;

    {max length of generated password}
    const
      intMAX_PW_LEN = 10;
    var
      i: Byte;
      s: string;
    begin
      {if you want to use the 'A..Z' characters}
      if cbAZ.Checked then
        s := 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
      else
        s := '';

      {if you want to use the 'a..z' characters}
      if cbAZSmall.Checked then
        s := s + 'abcdefghijklmnopqrstuvwxyz';

      {if you want to use the '0..9' characters}
      if cb09.Checked then
        s := s + '0123456789';
      if s = '' then exit;

      Result := '';
      for i := 0 to intMAX_PW_LEN-1 do
        Result := Result + s[Random(Length(s)-1)+1];
    end;

    initialization
      Randomize;

    结果:
    IBbfA1mVK2
    tmuXIuQJV5
    oNEY1cF6xB
    flIUhfdIui
    mxaK71dJaq
    B0YTqxdaLh
    ...





  • 相关阅读:
    3.27上午
    3.24上午 补
    2017.3.27下午
    2017.3.27上午
    2017.3.24下午
    2017.3.24上午
    2017.3.23下午
    2017.3.23上午
    2017.3.22上午
    2017.3.21下午
  • 原文地址:https://www.cnblogs.com/xe2011/p/3875966.html
Copyright © 2011-2022 走看看