public void GeneralKey() { var key = Cores.GeneralKey(8); Assert.Equal(2, key.Length); key = Cores.GeneralKey(128); Assert.Equal(32, key.Length); }
/// <summary> /// 重新生产令牌,并且保存。 /// </summary> /// <param name="application">当前应用程序。</param> /// <returns>返回数据库操作结果。</returns> public virtual async Task <DataResult> GenerateTokenAsync(CacheApplication application) { application.Token = Cores.GeneralKey(128); application.ExpiredDate = DateTimeOffset.Now.AddDays(_settingsManager.GetSettings <ApiSettings>().TokenExpired); return(Result(await _context.UpdateAsync(application.Id, new { application.Token, application.ExpiredDate }), DataAction.Updated)); }
public ResultAttribute() : base( new { ExpiredDate = DateTime.Now.AddDays(72), Token = Cores.GeneralKey(128) }, "获取令牌API,通过验证后可以获得请求API令牌。" ) { }
public IActionResult OnPostGeneral() { return(Success(new { AppSecret = Cores.GeneralKey(128) })); }
/// <summary> /// 初始化类<see cref="TokenResult"/>。 /// </summary> public TokenResult() : base(Cores.GeneralKey(128)) { }