예제 #1
0
        public async Task <IResponseOutput> GetPassWordEncryptKeyAsync()
        {
            //写入Redis
            var guid      = Guid.NewGuid().ToString("N");
            var key       = string.Format(CacheKey.PassWordEncryptKey, guid);
            var encyptKey = StringHelper.GenerateRandom(8);
            await BaseCache.SetAsync(key, encyptKey, TimeSpan.FromMinutes(5));

            var data = new { key = guid, encyptKey };

            return(ResponseOutput.Ok(data));
        }
예제 #2
0
        public async Task <IResponseOutput> GetVerifyCodeAsync(string lastKey)
        {
            var img = VerifyCodeHelper.GetBase64String(out string code);

            //删除上次缓存的验证码
            if (lastKey.NotNull())
            {
                await BaseCache.DelAsync(lastKey);
            }

            //写入Redis
            var guid = Guid.NewGuid().ToString("N");
            var key  = string.Format(CacheKey.VerifyCodeKey, guid);
            await BaseCache.SetAsync(key, code, TimeSpan.FromMinutes(5));

            var data = new { Key = guid, Img = img };

            return(ResponseOutput.Ok(data));
        }