Beispiel #1
0
        /// <summary>
        /// Generates random client secret
        /// </summary>
        /// <returns>Returns client secret</returns>
        public static string GenerateRandomClientSecret()
        {
            //Genero dei bytes random
            var key = new byte[32];

            RandomNumberGenerator.Create().GetBytes(key);

            //Eseguo l'encoding base 64
            return(Base64UrlTextEncoder.Encode(key));
        }
Beispiel #2
0
        /// <summary>
        /// Generate client secret using key
        /// </summary>
        /// <param name="input">Input string</param>
        /// <returns>Returns client secret</returns>
        public static string GenerateClientSecret(string input)
        {
            //Validazione argomenti
            if (string.IsNullOrEmpty(input))
            {
                throw new ArgumentNullException(nameof(input));
            }

            //Converto in bytes
            byte[] byteValue = Encoding.UTF8.GetBytes(input);

            //Eseguo l'encoding base 64
            return(Base64UrlTextEncoder.Encode(byteValue));
        }