CSharp examples for Security:Password
Build Password
using System.Web.UI.WebControls; using System.Web; using System.Text.RegularExpressions; using System.Text; using System.Security.Cryptography; using System.IO.Compression; using System.IO;/* w w w .j a va2 s .com*/ using System.Diagnostics; using System.Collections.Generic; using System; public class Main{ public static string BuildPassword() { Random random = new Random(); List<int> ints = new List<int>(); for ( int i = 0; i < 4; i++ ) { ints.Add(random.Next(9)); } List<string> strs = new List<string>(); //string CodeSerial = "a,b,c,d,e,f,g,h,i,j,k,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R,S,T,U,V,W,X,Y,Z"; string CodeSerial = "a,b,c,d,e,f,g,h,i,j,k,m,n,p,q,r,s,t,u,v,w,x,y,z"; string[] arr = CodeSerial.Split(','); int randValue = -1; Random rand = new Random(unchecked((int) DateTime.Now.Ticks)); for ( int i = 0; i < 4; i++ ) { randValue = rand.Next(0, arr.Length - 1); strs.Add(arr[randValue]); } string passwd = ""; for ( int k = 0; k < 4; k++ ) { passwd += ints[k].ToString() + strs[k]; } return passwd; } }