Exemple #1
0
        public Verify Create(TimeSpan expireDate, EnumDefine.VerifyTypeEnum type, object model)
        {
            OtpUtility     otpUtility     = new OtpUtility();
            RijndaelSimple rijndaelSimple = new RijndaelSimple();

            Id = Common.Common.GenerateGuid();
            OtpHashMode otpHashMode = OtpHashMode.Sha512;

            SaltKey        = Common.Common.GenerateNonce();
            SecretKey      = otpUtility.GenerateRandomKey(otpHashMode);
            CreatedDateUtc = Extensions.GetCurrentDateUtc();
            ExpireDate     = CreatedDateUtc.Add(expireDate);
            Type           = type;
            VerifyCode     = otpUtility.GenerateOtp(SecretKey, (int)expireDate.TotalSeconds, otpHashMode, 8);
            Model          = model;
            Status         = EnumDefine.VerifyStatusEnum.New;
            UpdatedDateUtc = CreatedDateUtc;
            CreatedUid     = string.Empty;
            UpdatedUid     = string.Empty;
            string code = UnicodeUtility.ToHexString(rijndaelSimple.Encrypt(VerifyCode, SaltKey));

            VerifyUrl = $"{ConfigSettingEnum.VerifyUrl.GetConfig()}?verify={Id}&code={code}";
            return(this);
        }
 public InMemoryCacheItem(object valueObject, TimeSpan expiresAfter, bool slidable = false) : this(slidable)
 {
     ValueObject   = valueObject;
     ExpireDateUtc = CreatedDateUtc.Add(expiresAfter);
 }