How to Generate Random Secret key with Number and Alphabet in c# public void randomnumber() { String guid = ""; String allowchars = " "; allowchars = "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z"; allowchars += "A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z"; allowchars += "1,2,3,4,5,6,7,8,9,0"; char[] sep = { ',' }; String[] arr = allowchars.Split(sep); String temp = ""; Random rnd = new Random(); for (int i = 0; i < 8; i++) { temp = arr[rnd.Next(0, arr.Length)]; guid += temp; } number1.Text = guid.ToString(); }
o/p: Number with Apphabet: 2HjiKG4
No comments:
Post a Comment