Wednesday, July 27, 2011

Generate Random Password in C#

public static string CreateRandomNumbersword(int iPasswordLength)

{



// Get the GUID



string sGUID = System.Guid.NewGuid().ToString();



// Remove the hyphens

sGUID = sGUID.Replace(

"-", string.Empty);



// Make sure length is valid



if (iPasswordLength <= 0 || iPasswordLength > sGUID.Length)



throw new ArgumentException("Length must be between 1 and " + sGUID.Length);



// Return the first length bytes



return sGUID.Substring(0, iPasswordLength);

 

}

No comments:

Post a Comment

How to upload app to macOS

1. Open Terminal Press Cmd (⌘) + Space , type Terminal , and hit Enter . 2. Navigate to Your Build Output Directory Your .app file is likel...