Esempio n. 1
0
        public void CreateNote(Note oldNoteData)
        {
            string pass = SettingsProvider.getInstance().PassPhrase;

            try
            {
                Note toAdd = new Note
                {
                    Content      = DataEncrypter.Encrypt(oldNoteData.Content, pass),
                    Name         = DataEncrypter.Encrypt(oldNoteData.Name, pass),
                    CreationTime = DataEncrypter.Encrypt(oldNoteData.CreationTime, pass),
                    LastUpdate   = DataEncrypter.Encrypt(oldNoteData.LastUpdate, pass),
                    Owner        = (oldNoteData.Owner)
                };
                this.db.Notes.Add(toAdd);

                db.SaveChanges();

                oldNoteData.Id = toAdd.Id;
            }
            catch (DbEntityValidationException e)
            {
                foreach (var eve in e.EntityValidationErrors)
                {
                    Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                      eve.Entry.Entity.GetType().Name, eve.Entry.State);
                    foreach (var ve in eve.ValidationErrors)
                    {
                        Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                          ve.PropertyName, ve.ErrorMessage);
                    }
                }
                throw;
            }
        }
        public async Task <ResultContext> Oyla(string SoruID, bool ResimNo)
        {
            Dictionary <string, string> form = new Dictionary <string, string>();

            form.Add("SoruID", DataEncrypter.Encrypt(SoruID));
            if (ResimNo)
            {
                form.Add("ResimNo", DataEncrypter.Encrypt("1"));
            }

            else
            {
                form.Add("ResimNo", DataEncrypter.Encrypt("0"));
            }

            var sonucKumesi = await Client.PostAsync("/api/Oyla", new FormUrlEncodedContent(form));

            if (sonucKumesi != null && sonucKumesi.Content != null)
            {
                var sonuc = await sonucKumesi.Content.ReadAsStringAsync();

                if (sonuc != null)
                {
                    return(JsonConvert.DeserializeObject <ResultContext>(DataEncrypter.Decrypt(sonuc)));
                }
            }
            return(new ResultContext()
            {
                Sonuc = false,
                Mesaj = "İstek yaparken hata oluştu"
            });
        }
Esempio n. 3
0
        public void TestEncryption()
        {
            string pass      = "******";
            string toEncrypt = "hello";

            string encrypted = DataEncrypter.Encrypt(toEncrypt, pass);
        }
Esempio n. 4
0
        /// <summary>
        /// Methode for try connexion with password
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnOpenExistingButtonClicked(object sender, RoutedEventArgs e)
        {
            try
            {
                OpenArchiveButton.Visibility = Visibility.Hidden;
                LoadingLabel.Visibility      = Visibility.Visible;

                DataEncrypter.Decrypt(((Archive)ListArchive.SelectedItem).OwnerEncrypted, ExistingArchivePassphrase.Password);

                SettingsProvider.getInstance().PassPhrase    = ExistingArchivePassphrase.Password;
                SettingsProvider.getInstance().LoadedArchive = NoteEncryptCSManager.GetInstance().GetArchive(((Archive)ListArchive.SelectedItem).Name, ExistingArchivePassphrase.Password);

                MainWindow mainWindow = new MainWindow();
                mainWindow.Show();
                this.Close();
            }
            catch (Exception exc)
            {
                //display a message invalid password
                OpenArchiveButton.Visibility = Visibility.Visible;
                LoadingLabel.Visibility      = Visibility.Hidden;
                ExistingArchivePassphrase.Clear();
                MessageBox.Show("Unable to decrypt archive, check your password and try again", "Fatal error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Esempio n. 5
0
        public Archive GetArchive(string archiveName, string archivePassphrase)
        {
            using (DalArchive dalArchive = new DalArchive())
            {
                // Call Entity framework
                Archive archiveFound = dalArchive.GetArchiveData(archiveName);

                if (archiveFound == null)
                {
                    throw new Exception("Unable to retrieve archive with name " + archiveName);
                }

                try
                {
                    archiveFound.OwnerDecrypted = DataEncrypter.Decrypt(archiveFound.OwnerEncrypted, archivePassphrase);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    throw new Exception("Error, cannot decrypt archive.");
                }

                return(archiveFound);
            }
        }
        public async Task <ResultContext> Yorumlar(string SoruID)
        {
            string url = "/api/Yorumlar";

            if (!string.IsNullOrEmpty(SoruID))
            {
                url += "?SoruID=" + DataEncrypter.Encrypt(SoruID);
            }
            var sonucKumesi = await Client.GetAsync(url);

            if (sonucKumesi != null && sonucKumesi.Content != null)
            {
                var sonuc = await sonucKumesi.Content.ReadAsStringAsync();

                if (sonuc != null)
                {
                    return(JsonConvert.DeserializeObject <ResultContext>(DataEncrypter.Decrypt(sonuc)));
                }
            }
            return(new ResultContext()
            {
                Sonuc = false,
                Mesaj = "İstek yaparken hata oluştu"
            });
        }
        private void Encrypt_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(PasswordBox.Text))
            {
                MessageBox.Show("Please Enter the correct Password");
            }
            else
            {
                if (PasswordBox.Text.Length != 16)
                {
                    MessageBox.Show("Please Enter the correct Password");
                }
                else
                {
                    Range selection = Globals.ThisAddIn.Application.Selection as Range;
                    foreach (object cell in selection.Cells)

                    {
                        try

                        {
                            string data  = Convert.ToString(((Range)cell).Value2);
                            string edata = DataEncrypter.Encrypt(data, PasswordBox.Text);
                            ((Range)cell).Value2 = edata;
                        }
                        catch (Exception ex)
                        {
                            //MessageBox.Show("NULL VALUE");
                        }
                    }
                }
            }
        }
        public async Task <ResultContext> YorumEkle(string SoruID, string Yorum, byte[] YorumResim, string YorumResimAdi)
        {
            var content = new MultipartFormDataContent();

            content.Add(new StringContent(DataEncrypter.Encrypt(SoruID)), "SoruID");
            content.Add(new StringContent(DataEncrypter.Encrypt(Yorum)), "Yorum");
            if (YorumResim != null)
            {
                content.Add(new ByteArrayContent(YorumResim, 0, YorumResim.Length), "Resim", YorumResimAdi);
            }

            var sonucKumesi = await Client.PostAsync("/api/YorumEkle", content);

            if (sonucKumesi != null && sonucKumesi.Content != null)
            {
                var sonuc = await sonucKumesi.Content.ReadAsStringAsync();

                if (sonuc != null)
                {
                    return(JsonConvert.DeserializeObject <ResultContext>(DataEncrypter.Decrypt(sonuc)));
                }
            }
            return(new ResultContext()
            {
                Sonuc = false,
                Mesaj = "İstek yaparken hata oluştu"
            });
        }
        public async Task <ResultContext> SoruEkle(byte[] Resim1, string Resim1Adi, byte[] Resim2, string Resim2Adi, string Baslik, string Aciklama, string KategoriID)
        {
            var content = new MultipartFormDataContent();

            content.Add(new ByteArrayContent(Resim1, 0, Resim1.Length), "Resim1", Resim1Adi);
            content.Add(new ByteArrayContent(Resim2, 0, Resim2.Length), "Resim2", Resim2Adi);

            content.Add(new StringContent(DataEncrypter.Encrypt(Baslik)), "Baslik");
            content.Add(new StringContent(DataEncrypter.Encrypt(Aciklama)), "Aciklama");
            content.Add(new StringContent(DataEncrypter.Encrypt(KategoriID)), "KategoriID");

            var sonucKumesi = await Client.PostAsync("/api/SoruEkle", content);

            if (sonucKumesi != null && sonucKumesi.Content != null)
            {
                var sonuc = await sonucKumesi.Content.ReadAsStringAsync();

                if (sonuc != null)
                {
                    return(JsonConvert.DeserializeObject <ResultContext>(DataEncrypter.Decrypt(sonuc)));
                }
            }
            return(new ResultContext()
            {
                Sonuc = false,
                Mesaj = "İstek yaparken hata oluştu"
            });
        }
Esempio n. 10
0
        public async Task <ResultContext> Kayit(string kullaniciAdi, string Sifre, string AdiSoyadi, string Email)
        {
            Dictionary <string, string> form = new Dictionary <string, string>();

            form.Add("KullaniciAdi", DataEncrypter.Encrypt(kullaniciAdi));
            form.Add("Sifre", DataEncrypter.Encrypt(Sifre));
            form.Add("AdiSoyadi", DataEncrypter.Encrypt(AdiSoyadi));
            form.Add("Email", DataEncrypter.Encrypt(Email));
            var sonucKumesi = await Client.PostAsync("/api/Kayit", new FormUrlEncodedContent(form));

            if (sonucKumesi != null && sonucKumesi.Content != null)
            {
                var sonuc = await sonucKumesi.Content.ReadAsStringAsync();

                if (sonuc != null)
                {
                    return(JsonConvert.DeserializeObject <ResultContext>(DataEncrypter.Decrypt(sonuc)));
                }
            }
            return(new ResultContext()
            {
                Sonuc = false,
                Mesaj = "İstek yaparken hata oluştu"
            });
        }
Esempio n. 11
0
        public void TestEncryptionThenDecryption()
        {
            string pass      = "******";
            string toEncrypt = "hello";

            string encrypted = DataEncrypter.Encrypt(toEncrypt, pass);

            string decrypted = DataEncrypter.Decrypt(encrypted, pass);

            Assert.AreEqual(toEncrypt, decrypted);
        }
Esempio n. 12
0
        public void CreateArchive(string archiveName, string archivePassphrase)
        {
            using (DalArchive dalArchive = new DalArchive())
            {
                // Generate owner unique name that'll be used for decrypting
                string ownerReference = DateTime.Now.ToString("yyyyMMddHHmmssffff");

                string encryptedName = DataEncrypter.Encrypt(ownerReference, archivePassphrase);

                // Call Entity framework
                dalArchive.CreateArchive(encryptedOwnerName: (encryptedName), archiveName: archiveName);
            }
        }
Esempio n. 13
0
 public async Task Log(string Mesaj)
 {
     try
     {
         Dictionary <string, string> form = new Dictionary <string, string>();
         form.Add("Mesaj", DataEncrypter.Encrypt(Mesaj));
         var sonucKumesi = await Client.PostAsync("/api/Log", new FormUrlEncodedContent(form));
     }
     catch
     {
         App.Current.Exit();
     }
 }
Esempio n. 14
0
        public MainWindow()
        {
            DataEncrypter.Decrypt(SettingsProvider.getInstance().LoadedArchive);
            NotesList = SettingsProvider.getInstance().LoadedArchive.Notes;

            // retrieve notes
            //            manager.retrieveNotes();

            // Load GUI
            InitializeComponent();

            //recive All save notes
            listbox1.ItemsSource = NotesList;
        }
Esempio n. 15
0
        public void UpdateNote(int id, Note noteToSave)
        {
            noteToSave.LastUpdate = DateTime.Now.ToString();
            var noteFound = db.Notes.SingleOrDefault(note => note.Id == id);

            if (null != noteFound)
            {
                noteFound.Name       = DataEncrypter.Encrypt(noteToSave.Name, SettingsProvider.getInstance().PassPhrase);
                noteFound.Content    = DataEncrypter.Encrypt(noteToSave.Content, SettingsProvider.getInstance().PassPhrase);
                noteFound.LastUpdate = DataEncrypter.Encrypt(noteToSave.LastUpdate, SettingsProvider.getInstance().PassPhrase);

                db.SaveChanges();
            }
        }
    protected void bt_OK_Click(object sender, EventArgs e)
    {
        Rpt_DataSourceBLL _bll;

        if ((Guid)ViewState["ID"] != Guid.Empty)
        {
            //修改
            _bll = new Rpt_DataSourceBLL((Guid)ViewState["ID"]);
        }
        else
        {
            //新增
            _bll = new Rpt_DataSourceBLL();
        }

        string pre_conn = _bll.Model.ConnectionString;

        pl_detail.GetData(_bll.Model);

        #region 判断必填项

        #endregion

        if (_bll.Model.ConnectionString != pre_conn && _bll.Model.ConnectionString != "")
        {
            _bll.Model.ConnectionString = DataEncrypter.EncrypteString(_bll.Model.ConnectionString);
        }

        if ((Guid)ViewState["ID"] != Guid.Empty)
        {
            //修改
            if (_bll.Update() == 0)
            {
                MessageBox.ShowAndRedirect(this, "修改成功!", "Rpt_DataSourceList.aspx");
            }
        }
        else
        {
            //新增
            if (_bll.Add() == 0)
            {
                MessageBox.ShowAndRedirect(this, "新增成功!", "Rpt_DataSourceList.aspx");
            }
        }
    }
Esempio n. 17
0
        public async Task <ResultContext> UyeProfil(string UyeID)
        {
            string url         = "/api/UyeProfil?UyeID=" + DataEncrypter.Encrypt(UyeID);
            var    sonucKumesi = await Client.GetAsync(url);

            if (sonucKumesi != null && sonucKumesi.Content != null)
            {
                var sonuc = await sonucKumesi.Content.ReadAsStringAsync();

                if (sonuc != null)
                {
                    return(JsonConvert.DeserializeObject <ResultContext>(DataEncrypter.Decrypt(sonuc)));
                }
            }
            return(new ResultContext()
            {
                Sonuc = false,
                Mesaj = "İstek yaparken hata oluştu"
            });
        }
Esempio n. 18
0
        public async Task <ResultContext> Cikis()
        {
            Dictionary <string, string> form = new Dictionary <string, string>();
            var sonucKumesi = await Client.PostAsync("/api/Cikis", new FormUrlEncodedContent(form));

            if (sonucKumesi != null && sonucKumesi.Content != null)
            {
                var sonuc = await sonucKumesi.Content.ReadAsStringAsync();

                if (sonuc != null)
                {
                    return(JsonConvert.DeserializeObject <ResultContext>(DataEncrypter.Decrypt(sonuc)));
                }
            }
            return(new ResultContext()
            {
                Sonuc = false,
                Mesaj = "İstek yaparken hata oluştu"
            });
        }
Esempio n. 19
0
    protected void bt_OK_Click(object sender, EventArgs e)
    {
        CM_DIUsersBLL      user = new CM_DIUsersBLL((int)Session["ClientUserID"]);
        CM_DIMembershipBLL ship = new CM_DIMembershipBLL(user.Model.ShipID);

        if (!DataEncrypter.Compare(ship.Model.Password, tbx_OrgPassword.Text))
        {
            Literal1.Text = "原密码输入错误!";
        }
        else
        {
            ship.Model.Password = DataEncrypter.EncrypteString(tbx_NewPassword.Text);
            ship.Update();
            Literal1.Text        = "";
            tbx_NewPassword.Text = "";
            tbx_OrgPassword.Text = "";
            tbx_RePassword.Text  = "";
            MessageBox.Show(this, "密码修改成功!");
        }
    }
Esempio n. 20
0
        public async Task <ResultContext> ResimGuncelle(byte[] Resim, string DosyaAdi)
        {
            var content = new MultipartFormDataContent();

            content.Add(new ByteArrayContent(Resim, 0, Resim.Length), "Resim", DosyaAdi);
            var sonucKumesi = await Client.PostAsync("/api/ResimGuncelle", content);

            if (sonucKumesi != null && sonucKumesi.Content != null)
            {
                var sonuc = await sonucKumesi.Content.ReadAsStringAsync();

                if (sonuc != null)
                {
                    return(JsonConvert.DeserializeObject <ResultContext>(DataEncrypter.Decrypt(sonuc)));
                }
            }
            return(new ResultContext()
            {
                Sonuc = false,
                Mesaj = "İstek yaparken hata oluştu"
            });
        }
Esempio n. 21
0
        public async Task <ResultContext> SifremiUnuttum(string mail)
        {
            Cookies = new CookieContainer();
            Dictionary <string, string> form = new Dictionary <string, string>();

            form.Add("Email", DataEncrypter.Encrypt(mail));
            var sonucKumesi = await Client.PostAsync("/api/SifremiUnuttum", new FormUrlEncodedContent(form));

            if (sonucKumesi != null && sonucKumesi.Content != null)
            {
                var sonuc = await sonucKumesi.Content.ReadAsStringAsync();

                if (sonuc != null)
                {
                    return(JsonConvert.DeserializeObject <ResultContext>(DataEncrypter.Decrypt(sonuc)));
                }
            }
            return(new ResultContext()
            {
                Sonuc = false,
                Mesaj = "İstek yaparken hata oluştu"
            });
        }
Esempio n. 22
0
 public EncryptionRequestHandler(DataEncrypter dataEncrypter)
 {
     _dataEncrypter = dataEncrypter;
 }