protected void Page_Load(object sender, EventArgs e) { ////////////////Creating Grid View /////////////// DataTable dt = new DataTable(); //создаём таблицу dt.Columns.Add("File", typeof(string)); dt.Columns.Add("Size", typeof(string)); dt.Columns.Add("Type", typeof(string)); dt.Columns.Add("Hash", typeof(string)); dt.Columns.Add("Sign", typeof(string)); dt.Columns.Add("PublicKey", typeof(string)); dt.Columns.Add("Mod", typeof(string)); dt.Columns.Add("Login", typeof(string)); String userName, sign_out, openkey, mod = ""; using (site_dbDataContext contex = new site_dbDataContext()) //Создан экземпляр класса БД { //Создаем объекты таблиц FileUser UserName = new FileUser(); foreach (string strfile in Directory.GetFiles(Server.MapPath("~/Data")))//вносим данные { FileInfo fi = new FileInfo(strfile); userName = (from x in new site_dbDataContext().FileUser where x.FileName == fi.Name select x.Email).First(); sign_out = (from x in new site_dbDataContext().FileUser where x.FileName == fi.Name select x.Sign).First(); openkey = (from x in new site_dbDataContext().PublicKeys where x.UserLogin == userName select x.PublicKey).First(); mod = (from x in new site_dbDataContext().PublicKeys where x.UserLogin == userName select x.Mod).First(); dt.Rows.Add(fi.Name, fi.Length, GetFileTypeByExtension(fi.Extension), ComputeMD5Checksum(Server.MapPath("~/Data/") + fi.Name), sign_out, openkey, mod, userName); } } GridView1.DataSource = dt; GridView1.DataBind(); ////////////////////////////////////////////////// }
protected void CreateUser_Click(object sender, EventArgs e) { var manager = Context.GetOwinContext().GetUserManager <ApplicationUserManager>(); var signInManager = Context.GetOwinContext().Get <ApplicationSignInManager>(); var user = new ApplicationUser() { UserName = Email.Text, Email = Email.Text }; IdentityResult result = manager.Create(user, Password.Text); if (result.Succeeded) { signInManager.SignIn(user, isPersistent: false, rememberBrowser: false); // Записываем ключи и модуль using (site_dbDataContext contex = new site_dbDataContext()) //Создан экземпляр класса БД { RSA.RSA_Sign A_RSA_Sign = new RSA.RSA_Sign(); //конструктор //String userId = (from x in new site_dbDataContext().AspNetUsers where x.Email == Context.User.Identity.Name select x.Id).First(); //Создаем объекты таблиц PublicKeys PublicKey = new PublicKeys(); //PublicKey PublicKey.PublicKey = A_RSA_Sign.E; PublicKey.Mod = A_RSA_Sign.N; //Mod PublicKey.UserLogin = Email.Text; contex.PublicKeys.InsertOnSubmit(PublicKey); contex.SubmitChanges(); Sisurity PrivatKey = new Sisurity(); //PrivatKey PrivatKey.PrivatKey = A_RSA_Sign.D; PrivatKey.UserLogin = Email.Text; contex.Sisurity.InsertOnSubmit(PrivatKey); contex.SubmitChanges(); } /// IdentityHelper.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response); } else { ErrorMessage.Text = result.Errors.FirstOrDefault(); } }
protected void CreateUser_Click(object sender, EventArgs e) { var manager = Context.GetOwinContext().GetUserManager<ApplicationUserManager>(); var signInManager = Context.GetOwinContext().Get<ApplicationSignInManager>(); var user = new ApplicationUser() { UserName = Email.Text, Email = Email.Text }; IdentityResult result = manager.Create(user, Password.Text); if (result.Succeeded) { signInManager.SignIn(user, isPersistent: false, rememberBrowser: false); // Записываем ключи и модуль using (site_dbDataContext contex = new site_dbDataContext()) //Создан экземпляр класса БД { RSA.RSA_Sign A_RSA_Sign = new RSA.RSA_Sign(); //конструктор //String userId = (from x in new site_dbDataContext().AspNetUsers where x.Email == Context.User.Identity.Name select x.Id).First(); //Создаем объекты таблиц PublicKeys PublicKey = new PublicKeys(); //PublicKey PublicKey.PublicKey = A_RSA_Sign.E; PublicKey.Mod = A_RSA_Sign.N; //Mod PublicKey.UserLogin = Email.Text; contex.PublicKeys.InsertOnSubmit(PublicKey); contex.SubmitChanges(); Sisurity PrivatKey = new Sisurity(); //PrivatKey PrivatKey.PrivatKey = A_RSA_Sign.D; PrivatKey.UserLogin = Email.Text; contex.Sisurity.InsertOnSubmit(PrivatKey); contex.SubmitChanges(); } /// IdentityHelper.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response); } else { ErrorMessage.Text = result.Errors.FirstOrDefault(); } }
protected void Button1_Click(object sender, EventArgs e) { if (Context.User.Identity.Name == "") { Response.Redirect("~/Account/Login.aspx"); } else { if (FileUpload1.HasFile) { FileUpload1.PostedFile.SaveAs(Server.MapPath("~/Data/") + FileUpload1.FileName); // куда грузить ////////////Writing user name into database/////////// using (site_dbDataContext contex = new site_dbDataContext()) //Создан экземпляр класса БД { //Создаем объекты таблиц FileUser UserName = new FileUser(); //PublicKey UserName.Email = Context.User.Identity.Name; UserName.FileName = FileUpload1.FileName; //////////////////////////////////////////////////// ///////////////Добавляем Подпись/////////////////// RSA.BigInteger BI_Text = new RSA.BigInteger(ComputeMD5Checksum(Server.MapPath("~/Data/") + FileUpload1.FileName), 16); RSA.BigInteger d = new RSA.BigInteger((from x in new site_dbDataContext().Sisurity where x.UserLogin == Context.User.Identity.Name select x.PrivatKey).First(), 10); RSA.BigInteger n = new RSA.BigInteger((from x in new site_dbDataContext().PublicKeys where x.UserLogin == Context.User.Identity.Name select x.Mod).First(), 10); byte[] sign = BI_Text.modPow(d, n).getBytes(); UserName.Sign = BitConverter.ToString(sign).Replace("-", string.Empty); contex.FileUser.InsertOnSubmit(UserName); contex.SubmitChanges(); ///////////////////////////////////////////////////*/ } } DataTable dt = new DataTable();//создаём таблицу dt.Columns.Add("File", typeof(string)); dt.Columns.Add("Size", typeof(string)); dt.Columns.Add("Type", typeof(string)); dt.Columns.Add("Hash", typeof(string)); dt.Columns.Add("Sign", typeof(string)); dt.Columns.Add("PublicKey", typeof(string)); dt.Columns.Add("Mod", typeof(string)); dt.Columns.Add("Login", typeof(string)); String userName, sign_out, openkey, mod = ""; using (site_dbDataContext contex = new site_dbDataContext()) //Создан экземпляр класса БД { //Создаем объекты таблиц FileUser UserName = new FileUser(); foreach (string strfile in Directory.GetFiles(Server.MapPath("~/Data")))//вносим данные { FileInfo fi = new FileInfo(strfile); userName = (from x in new site_dbDataContext().FileUser where x.FileName == fi.Name select x.Email).First(); sign_out = (from x in new site_dbDataContext().FileUser where x.FileName == fi.Name select x.Sign).First(); openkey = (from x in new site_dbDataContext().PublicKeys where x.UserLogin == userName select x.PublicKey).First(); mod = (from x in new site_dbDataContext().PublicKeys where x.UserLogin == userName select x.Mod).First(); dt.Rows.Add(fi.Name, fi.Length, GetFileTypeByExtension(fi.Extension), ComputeMD5Checksum(Server.MapPath("~/Data/") + fi.Name), sign_out, openkey, mod, userName); } } GridView1.DataSource = dt; GridView1.DataBind(); } }
protected void Button1_Click(object sender, EventArgs e) { if (Context.User.Identity.Name == "") { Response.Redirect("~/Account/Login.aspx"); } else { if (FileUpload1.HasFile) { FileUpload1.PostedFile.SaveAs(Server.MapPath("~/Data/") + FileUpload1.FileName);// куда грузить ////////////Writing user name into database/////////// using (site_dbDataContext contex = new site_dbDataContext()) //Создан экземпляр класса БД { //Создаем объекты таблиц FileUser UserName = new FileUser(); //PublicKey UserName.Email = Context.User.Identity.Name; UserName.FileName = FileUpload1.FileName; //////////////////////////////////////////////////// ///////////////Добавляем Подпись/////////////////// RSA.BigInteger BI_Text = new RSA.BigInteger(ComputeMD5Checksum(Server.MapPath("~/Data/") + FileUpload1.FileName), 16); RSA.BigInteger d = new RSA.BigInteger((from x in new site_dbDataContext().Sisurity where x.UserLogin == Context.User.Identity.Name select x.PrivatKey).First(), 10); RSA.BigInteger n = new RSA.BigInteger((from x in new site_dbDataContext().PublicKeys where x.UserLogin == Context.User.Identity.Name select x.Mod).First(), 10); byte[] sign = BI_Text.modPow(d, n).getBytes(); UserName.Sign = BitConverter.ToString(sign).Replace("-", string.Empty); contex.FileUser.InsertOnSubmit(UserName); contex.SubmitChanges(); ///////////////////////////////////////////////////*/ } } DataTable dt = new DataTable();//создаём таблицу dt.Columns.Add("File", typeof(string)); dt.Columns.Add("Size", typeof(string)); dt.Columns.Add("Type", typeof(string)); dt.Columns.Add("Hash", typeof(string)); dt.Columns.Add("Sign", typeof(string)); dt.Columns.Add("PublicKey", typeof(string)); dt.Columns.Add("Mod", typeof(string)); dt.Columns.Add("Login", typeof(string)); String userName, sign_out, openkey, mod = ""; using (site_dbDataContext contex = new site_dbDataContext()) //Создан экземпляр класса БД { //Создаем объекты таблиц FileUser UserName = new FileUser(); foreach (string strfile in Directory.GetFiles(Server.MapPath("~/Data")))//вносим данные { FileInfo fi = new FileInfo(strfile); userName = (from x in new site_dbDataContext().FileUser where x.FileName == fi.Name select x.Email).First(); sign_out = (from x in new site_dbDataContext().FileUser where x.FileName == fi.Name select x.Sign).First(); openkey = (from x in new site_dbDataContext().PublicKeys where x.UserLogin == userName select x.PublicKey).First(); mod = (from x in new site_dbDataContext().PublicKeys where x.UserLogin == userName select x.Mod).First(); dt.Rows.Add(fi.Name, fi.Length, GetFileTypeByExtension(fi.Extension), ComputeMD5Checksum(Server.MapPath("~/Data/") + fi.Name), sign_out, openkey, mod, userName); } } GridView1.DataSource = dt; GridView1.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { ////////////////Creating Grid View /////////////// DataTable dt = new DataTable();//создаём таблицу dt.Columns.Add("File", typeof(string)); dt.Columns.Add("Size", typeof(string)); dt.Columns.Add("Type", typeof(string)); dt.Columns.Add("Hash", typeof(string)); dt.Columns.Add("Sign", typeof(string)); dt.Columns.Add("PublicKey", typeof(string)); dt.Columns.Add("Mod", typeof(string)); dt.Columns.Add("Login", typeof(string)); String userName, sign_out, openkey, mod = ""; using (site_dbDataContext contex = new site_dbDataContext()) //Создан экземпляр класса БД { //Создаем объекты таблиц FileUser UserName = new FileUser(); foreach (string strfile in Directory.GetFiles(Server.MapPath("~/Data")))//вносим данные { FileInfo fi = new FileInfo(strfile); userName = (from x in new site_dbDataContext().FileUser where x.FileName == fi.Name select x.Email).First(); sign_out = (from x in new site_dbDataContext().FileUser where x.FileName == fi.Name select x.Sign).First(); openkey = (from x in new site_dbDataContext().PublicKeys where x.UserLogin == userName select x.PublicKey).First(); mod = (from x in new site_dbDataContext().PublicKeys where x.UserLogin == userName select x.Mod).First(); dt.Rows.Add(fi.Name, fi.Length, GetFileTypeByExtension(fi.Extension), ComputeMD5Checksum(Server.MapPath("~/Data/") + fi.Name), sign_out, openkey, mod, userName); } } GridView1.DataSource = dt; GridView1.DataBind(); ////////////////////////////////////////////////// }