Advertisement
Guest User

generate secret key

a guest
Oct 4th, 2018
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.58 KB | None | 0 0
  1. using System;
  2. using System.Runtime;
  3. using System.Linq;
  4.                    
  5. public class Program
  6. {
  7.     static int secretKeyLength = 10;
  8.     static string allowedCharacters = "asdfghjklqwertyuiopzxcvbnm";
  9.     public static void Main()
  10.     {
  11.         Console.WriteLine("Hello World");
  12.         var x = GenerateSecretKey();
  13.         Console.WriteLine("x" + x);
  14.        
  15.     }
  16.    
  17.     public static string GenerateSecretKey()
  18.     {
  19.           Random random = new Random((int)DateTime.Now.Ticks & 0x0000FFFF);
  20.           return new string((new char[secretKeyLength]).Select(c => c = allowedCharacters[random.Next(0, allowedCharacters.Length)]).ToArray());
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement