Blog.Web.Api.Controllers.AccountController.RandomOAuthStateGenerator.Generate C# (CSharp) Method

Generate() public static method

public static Generate ( int strengthInBits ) : string
strengthInBits int
return string
            public static string Generate(int strengthInBits)
            {
                const int bitsPerByte = 8;

                if (strengthInBits % bitsPerByte != 0)
                {
                    throw new ArgumentException("strengthInBits must be evenly divisible by 8.", "strengthInBits");
                }

                var strengthInBytes = strengthInBits / bitsPerByte;

                var data = new byte[strengthInBytes];
                Random.GetBytes(data);
                return HttpServerUtility.UrlTokenEncode(data);
            }
        }
AccountController.RandomOAuthStateGenerator