Пример #1
0
 private void UpdateSyncCode()
 {
     if (!SyncKeyCodePassword.IsNullOrEmpty())
     {
         var hsc = HourlySyncCode.Generate(SyncKeyCodePassword).ToString();
         this["SyncKeyCode"] = hsc;
     }
 }
Пример #2
0
        public static bool Validate(HourlySyncCode code, String Password, DateTime?keyMoment = null)
        {
            keyMoment = keyMoment ?? Fi.Tech.GetUtcTime();
            if (Generate(keyMoment.Value, Password).Code.SequenceEqual(code.Code))
            {
                return(true);
            }

            for (int i = -3; i <= 3; ++i)
            {
                var dt = keyMoment.Value.Add(TimeSpan.FromMinutes(i));
                if (Generate(dt, Password).Code.SequenceEqual(code.Code))
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #3
0
 public static bool Validate(DateTime keyMoment, HourlySyncCode code, String Password)
 {
     return(Validate(code, Password, keyMoment));
 }