Skip to content

Crypto.cs | GetRandomString

HackTheDev edited this page May 3, 2021 · 1 revision

This method is used to generate a random string when there was no encryption/decryption key set. This is mostly used on the first run ever on a machine.

           private static Random random = new Random();

           const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
            return new string(Enumerable.Repeat(chars, length)
              .Select(s => s[random.Next(s.Length)]).ToArray());