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)); }
protected OtpJsonObject CreateOtpJsonObject(GenerateOtpInput input, string password, DateTime expireDateTime) => new OtpJsonObject(Settings.Issuer, input.GeneratesFor, password, expireDateTime);