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

If you’re using Visual Studio to build your .NET MAUI app on a Mac, locating the IPA (iOS App Package) file can be a bit tricky

  If you’re using   Visual Studio   to build your   .NET MAUI   app on a   Mac , locating the   IPA (iOS App Package)   file can be a bit tr...