public ActionResult Index(string user, string pass)
 {
     var ec = new EncodeData();
     var decode = ec.Encode(pass.Trim());
     var row = _db.Accounts.SingleOrDefault(a => a.UserName.Trim().ToLower() == user.Trim().ToLower()
                                 && a.Password.Trim() == decode);
     if (row == null)
     {
         ViewBag.Err = "Đăng nhập thất bại- vui lòng kiểm tra lại Tài khoản hoặc Mật Khẩu !";
         return View();
     }
     else
     {
         if (row.Active == false)
         {
             ViewBag.Err = "Tài khoản của bạn bị khóa vì 1 lý do nào đó !";
             return View();
         }
         else
         {
             Session["id"] = row.Id;
             Session["username"] = row.UserName;
             Session["name"] = row.Name;
             Session["image"] = row.Image;
             Session["permission"] = row.Permission;
             Session["timeEnd"] = row.TimeEnd;
             Session["temp"] = "username" + row.Id;
             return RedirectToAction("Index", "Admin");
         }
     }
 }
Example #2
0
        public void Update()
        {
            // [Note-kazuki: 2020-03-09] Flip vertically RenderTexture
            // note: streamed video is flipped vertical if no action was taken:
            //  - duplicate RenderTexture from its source texture
            //  - call Graphics.Blit command with flip material every frame
            //  - it might be better to implement this if possible
            if (needFlip_)
            {
                Graphics.Blit(sourceTexture_, destTexture_, s_scale, s_offset);
            }
            else
            {
                Graphics.Blit(sourceTexture_, destTexture_);
            }

            // todo:: This comparison is not sufficiency but it is for workaround of freeze bug.
            // Texture.GetNativeTexturePtr method freezes Unity Editor on apple silicon.
            if (prevTexture_ != destTexture_)
            {
                data_ = new EncodeData(destTexture_, self);
                Marshal.StructureToPtr(data_, ptr_, true);
                prevTexture_ = destTexture_;
            }
            WebRTC.Context.Encode(ptr_);
        }
Example #3
0
        public ActionResult Encode(EncodeData d)
        {
            if (d.DataLeft != null)
            {
                d.DataRight = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(d.DataLeft));
            }

            return(View("EncDec", d));
        }
Example #4
0
 public EncodeData(EncodeData d)
 {
     this.data   = new List <byte>(d.data);
     this.keyPos = d.keyPos;
     this.keyLen = d.keyLen;
 }
Example #5
0
    /**
     * Returns Tuple with the encoded data, an int for the key position, and
     * an int for the number of bits used in the key.
     * @param pos   The position of the next byte to encode (everything after is ignored)
     */
    static EncodeData EncodeHlpr(byte[] inData, int pos)
    {
        if (encodeAnswers[pos] != null)
        {
            return(encodeAnswers[pos]);
        }

        if (pos == 0)
        {
            var data = new List <byte>();
            data.Add(0x01);
            data.Add(inData[pos]);
            encodeAnswers[0] = new EncodeData(data, 0, 1);
            return(encodeAnswers[0]);
        }

        var        possibilities = new List <EncodeData>();
        EncodeData poss;

        if (possibilities.Count == 0)
        {
            poss = new EncodeData(EncodeHlpr(inData, pos - 1));
            if (poss.keyLen == 8)
            {
                poss.keyPos = poss.data.Count;
                poss.keyLen = 1;
                poss.data.Add(0x01);
            }
            else
            {
                poss.data[poss.keyPos] |= (byte)((1 << poss.keyLen));
                poss.keyLen++;
            }
            poss.data.Add(inData[pos]);
            possibilities.Add(poss);
        }

        for (int len = 3; len <= 12 && len <= pos + 1; len++)
        {
            int position;
            if (!encodeStrings.TryGetValue(new EncodeEntry(inData, pos - len + 1, len), out position))
            {
                continue;
            }
            int offset = (pos - len + 1) - position;
            if (offset >= 0x1000)
            {
                continue;
            }

            poss = new EncodeData(EncodeHlpr(inData, pos - len));
            if (poss.keyLen == 8)
            {
                poss.keyPos = poss.data.Count;
                poss.keyLen = 1;
                poss.data.Add(0x00);
            }
            else
            {
                poss.keyLen++;
            }

            UInt16 word = (UInt16)((len - 3) | (offset << 4));
            poss.data.Add((byte)(word & 0xff));
            poss.data.Add((byte)(word >> 8));
            possibilities.Add(poss);
        }

        // Choose shortest candidate
        encodeAnswers[pos] = possibilities.Aggregate(
            (acc, val) => acc.data.Count < val.data.Count ? acc
                : acc.keyLen < val.keyLen ? acc : val);
        return(encodeAnswers[pos]);
    }