示例#1
0
        public GenerateOtpResult GenerateOtp(GenerateOtpInput input)
        {
            var expireDateTime = DateTime.Now.AddSeconds(Settings.ExpirationInSeconds);
            var password       = RandomCodeGenerator.GenerateRandomCode(Settings.Length, Settings.PermittedLetters);

            var otpJsonObj = CreateOtpJsonObject(input, password, expireDateTime);

            var serializedOtpJsonObj = SerializeOtpJsonObject(otpJsonObj);
            var encryptedOtpJsonObj  = EncryptOtpJsonObject(serializedOtpJsonObj);

            return(new GenerateOtpResult(encryptedOtpJsonObj, expireDateTime));
        }
示例#2
0
 protected OtpJsonObject CreateOtpJsonObject(GenerateOtpInput input, string password, DateTime expireDateTime)
 => new OtpJsonObject(Settings.Issuer, input.GeneratesFor, password, expireDateTime);