Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# generate random key with specified length

 /// <summary>
        /// Generate Random Key
        /// </summary>
        /// <param name="length">Lenght of key to generate</param>
        /// <returns></returns>
        public static string UniqueKey(int length)
        {
            string guidResult = string.Empty;

            while (guidResult.Length < length)
            {
                // Get the GUID.
                guidResult += Guid.NewGuid().ToString().GetHashCode().ToString("#");
            }

            // Make sure length is valid.
            if (length <= 0 || length > guidResult.Length)
                throw new ArgumentException("Length must be between 1 and " + guidResult.Length);

            // Return the first length bytes.
            return guidResult.Substring(0, length);
        }
Comment

PREVIOUS NEXT
Code Example
Csharp :: unity rotatetowards 
Csharp :: Garbage collect every 30 frames unity 
Csharp :: how to check if string from textbox exists in db 
Csharp :: touch screen to world point 
Csharp :: translate english to spanish 
Csharp :: closing main window after clicking on a button that opens another window in wpf 
Csharp :: stack iterator c# 
Csharp :: php encrypt message encrypt() decrypt 
Csharp :: how to download things c# 
Csharp :: c# aspx return image 
Csharp :: nunjucks if variable exists 
Csharp :: visual studio private field underscore 
Csharp :: unity matchinfo 
Csharp :: how to make a respaen script in unity 
Csharp :: get fixedupdate interval unity 
Csharp :: how to make dobuble jump unity 2d 
Csharp :: Convert any class to a keyvaluepair 
Csharp :: ignore warning openxml 
Csharp :: wpf create rectangle c# 
Csharp :: advance C# tricks and hits 
Csharp :: CullingGroup 
Csharp :: Set orientation of moving object towards it movement direction 
Csharp :: client = matrice[indexselectedclient] as String[]; 
Csharp :: C# Printing Variables and Literals using WriteLine() and Write() 
Csharp :: c# inline 
Csharp :: vb.net single quote in string 
Csharp :: C# today, yesterday, last week, last month 
Csharp :: c# convert datatable to csv 
Csharp :: c# string contain double quote 
Csharp :: unity destroy 
ADD CONTENT
Topic
Content
Source link
Name
1+7 =