Exemplo n.º 1
0
 public List <SP_SEL_ENCRYPT_NHANVIEN_Result> getNV()
 {
     using (QLSV_CANHANEntities db = new QLSV_CANHANEntities())
     {
         List <SP_SEL_ENCRYPT_NHANVIEN_Result> list = new List <SP_SEL_ENCRYPT_NHANVIEN_Result>();
         var tempList = db.SP_SEL_ENCRYPT_NHANVIEN();
         foreach (var i in tempList)
         {
             i.LUONG = DecryptStringFromBytes_Aes(Convert.FromBase64String(i.LUONG), key, IV);
             list.Add(i);
         }
         return(list);
     }
 }
Exemplo n.º 2
0
 public static void  update_NV(string maNV, string hoTen, string email, string luong, string tenDN, string matKhau)
 {
     using (QLSV_CANHANEntities db = new QLSV_CANHANEntities())
     {
         SHA1Managed sha1 = new SHA1Managed();
         sha1.ComputeHash(Encoding.UTF8.GetBytes(matKhau));
         byte[]        hashMK  = sha1.Hash;
         StringBuilder buildMK = new StringBuilder();
         for (int i = 0; i < hashMK.Length; i++)
         {
             buildMK.Append(hashMK[i].ToString());
         }
         string finalMk        = buildMK.ToString();
         byte[] encryptedLuong = EncryptStringToBytes_Aes(luong, key, IV);
         string finalLuong     = Convert.ToBase64String(encryptedLuong);
         db.UPDATE_NV(maNV, hoTen, email, finalLuong, tenDN, finalMk);
     }
 }
Exemplo n.º 3
0
        public void insertSV(string maSV, string hoTen, string ngaySinh, string diaChi, string maLop, string tenDN, string matKhau)
        {
            MD5 md5 = new MD5CryptoServiceProvider();

            md5.ComputeHash(Encoding.UTF8.GetBytes(matKhau));
            byte[]        hashMatKhau = md5.Hash;
            StringBuilder buildMK     = new StringBuilder();

            for (int i = 0; i < hashMatKhau.Length; i++)
            {
                buildMK.Append(hashMatKhau[i].ToString());
            }
            string finalMK = buildMK.ToString();

            using (QLSV_CANHANEntities db = new QLSV_CANHANEntities())
            {
                DateTime ngaySinhDate = Convert.ToDateTime(ngaySinh);
                db.SP_INS_ENCRYPT_SINHVIEN(maSV, hoTen, ngaySinhDate, diaChi, maLop, tenDN, finalMK);
            }
        }