コード例 #1
0
        /// <summary>
        /// Uses RNGCryptoServiceProvider to gnerate a Base64 code that is then translated to JWT format.
        /// </summary>
        /// <param name="minLength"></param>
        /// <param name="maxLength"></param>
        /// <returns></returns>
        public string GenerateSecretCodeUrlSafe(int minLength, int maxLength)
        {
            var length = this.RandomNumber(minLength, maxLength);
            var cryptoRandomDataGenerator = new RNGCryptoServiceProvider();

            byte[] buffer = new byte[length];
            cryptoRandomDataGenerator.GetBytes(buffer);
            return(JsonWebTokenUtility.Base64UrlEncodeForJson(buffer));
        }
コード例 #2
0
 /// <summary>
 /// Returns a Base64 equivalent of a string created from GenerateSecretCodeUrlSafe or a JWT format.
 /// </summary>
 /// <param name="code"></param>
 /// <returns></returns>
 public string SecretCodeUrlSafeToBase64(string code)
 {
     return(JsonWebTokenUtility.UrlEncodedToBase64(code));
 }