Random alphanumeric string

greenbyte lysenko765 at yandex.ru
Mon Jun 20 11:49:24 UTC 2022


```d
string randomAlphanumericString(int length)
{
     import std.array : array;
     import std.ascii : letters, digits;
     import std.random : choice, Random, unpredictableSeed;
     import std.range : generate, take;
     import std.conv : to;

     auto rnd = Random(unpredictableSeed);
     auto symbols = array(letters ~ digits);

     return generate!({ return symbols.choice(rnd); 
}).take(length).to!string;
}
```


More information about the Digitalmars-d mailing list