Click here to Skip to main content
15,892,537 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have to Create a nonce with 32 characters for a soap request Can anybody drag me Out ..Thanks in Advance
Posted

1 solution

Try below code
C#
private static string validChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
        private static Random random = new Random();

        private static string GenerateNonce(int length)
        {
            var nonceString = new StringBuilder();
            for (int i = 0; i < length; i++)
            {
                nonceString.Append(validChars[random.Next(0, validChars.Length - 1)]);
            }

            return nonceString.ToString();
        }

Call GenerateNonce method and pass 32 as parameter to get 32 character long string.
 
Share this answer
 
Comments
Ashok1986 17-Apr-13 2:06am    
Thanks mr vijay

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900