public IHttpActionResult GetRandomCode()
        {
            ValidationCodeHelper helper = new ValidationCodeHelper();

            byte[] stream = helper.CreateImage(helper.CreateCode(2, 4));
            return(new FileStreamContent(new MemoryStream(stream), "application/octet-stream"));
        }
        public IHttpActionResult GetRandomCode(string randomId)
        {
            ValidationCodeHelper helper = new ValidationCodeHelper();
            string code = helper.CreateCode(2, 4);

            RedisHelper.SetString(randomId, code, 120);
            byte[] stream = helper.CreateImage(code);
            return(new FileStreamContent(new MemoryStream(stream), "application/octet-stream"));
        }
Ejemplo n.º 3
0
        public ActionResult ValidateCode(int regType)
        {
            var          validateCodeHelper = new ValidationCodeHelper();
            string       code       = validateCodeHelper.CreateCode(2, 4);
            const string cookieName = "RegisterCode";

            CookieHelper.WriteCookie(cookieName, DESEncrypt.Encrypt(code));
            CookieHelper.SetCookieExpires(cookieName, DateTime.Now.AddMinutes(30));
            byte[] bytes = validateCodeHelper.CreateImage(code);
            return(File(bytes, @"image/jpeg"));
        }