private void Button_Decrypt(object sender, RoutedEventArgs e) { String keyword = this.tb_keyword.Text; String value = this.tb_value.Text; Encryption encryption = new Encryption(this.tb_value.Text, this.tb_keyword.Text); this.lbl_result.Text = encryption.decryptText(); }
public EntityCredential(Encryption encrypt, Credentials creds) { Id = creds.Id; UserId = creds.UserId; Website = encrypt.EncryptToString(creds.Website); Url = encrypt.EncryptToString(creds.Url); Username = encrypt.EncryptToString(creds.Username); Password = encrypt.EncryptToString(creds.Password); Email = encrypt.EncryptToString(creds.EmailAddress); }
public Credentials(Encryption encrypt, EncryptedCredentials encrypeted) { Id = encrypeted.Id; UserId = encrypeted.UserId; Website = encrypt.DecryptString(encrypeted.Website); Url = encrypt.DecryptString(encrypeted.Url); Username = encrypt.DecryptString(encrypeted.Username); Password = encrypt.DecryptString(encrypeted.Password); EmailAddress = encrypt.DecryptString(encrypeted.EmailAddress); }
private void Button_Encrypt(object sender, RoutedEventArgs e) { Encryption encryption = new Encryption(this.tb_value.Text, this.tb_keyword.Text); String crypted = encryption.encryptText(); DatabaseHelper Db_Helper = new DatabaseHelper(); Db_Helper.Insert(new Encryption(crypted, encryption.Key)); this.lbl_result.Text = crypted; }
public HttpResponseMessage GetAES(string option) { Encryption encryption = new Encryption(); if (option == "encrypt") { encryption.EncryptFile(PathFile, PathFile + "enc", "password"); } else if (option == "decrypt") { encryption.DecryptFile(PathFile + "enc", PathFile, "password"); } HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK); var stream = new FileStream(PathFile + "enc", FileMode.Open); result.Content = new StreamContent(stream); result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream"); return result; }
public HttpResponseMessage GetAES(string option, string password) { Encryption encryption = new Encryption(); if (option == "encrypt") { encryption.EncryptFile(PathFile, PathFile + "enc", password); } else if (option == "decrypt") { try { encryption.DecryptFile(PathFile + "enc", PathFile, password); } catch (CryptographicException e) { return new HttpResponseMessage(HttpStatusCode.BadRequest); } } HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK); Stream stream; if (option == "encrypt") { stream = new FileStream(PathFile + "enc", FileMode.Open); } else { stream = new FileStream(PathFile, FileMode.Open); } result.Content = new StreamContent(stream); result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream"); return result; }
public Login SetPassword(string value, string sessionId) { if (!string.IsNullOrEmpty(value)) { if (!value.StartsWith("pw:")) { _password = value; } else { try { var data = Convert.FromBase64String(value.Substring(3)); using (var enc = new Encryption(sessionId)) using (var output = new MemoryStream(data)) using (var cryptStream = new CryptoStream(output, enc.CreateDecryptor(), CryptoStreamMode.Read)) { _password = new SecureToken(cryptStream); } } catch (FormatException) { _password = value; } } } return this; }
public string GetEncryptedPassword(string sessionId) { using (var enc = new Encryption(sessionId)) using (var output = new MemoryStream()) using (var cryptStream = new CryptoStream(output, enc.CreateEncryptor(), CryptoStreamMode.Write)) { _password.UseBytes((ref byte[] b) => { cryptStream.Write(b, 0, b.Length); return true; }); cryptStream.FlushFinalBlock(); return "pw:" + Convert.ToBase64String(output.ToArray()); } }
public Int32 SignIn(string UserName, string Password) { Encryption encryption = new Encryption(); //OperationClass opration = new OperationClass(); Int32 Returnvalue = 0; //opration.CreateWordFile(); try { //getExpirydays(UserName); string MysaltValue, MyEncryptPassword, NewEncryptPassword = ""; //dtPasswrod = _UserBal.GetSaltValue(txtUserName.Text.ToString().Trim(), txtPassword.Text.ToString().Trim()); DataTable dtsaltvalue = GetDataTable( string.Format(@"SELECT Username,[Password],Saltvalue,userID FROM tblUserMaster WHERE Username = '******' AND status =1", UserName)); if (dtsaltvalue.Rows.Count > 0) { MysaltValue = dtsaltvalue.Rows[0]["Saltvalue"].ToString(); MyEncryptPassword = dtsaltvalue.Rows[0]["Password"].ToString(); NewEncryptPassword = encryption.CreatePasswordHash(Password, MysaltValue); if (MyEncryptPassword == NewEncryptPassword) { DataTable dtuserdetails = GetDataTable( string.Format(@"IF EXISTS ( SELECT Username,[Password],Saltvalue FROM tblUserMaster WHERE Username = '******' AND [Password] = '{1}' AND Status = 1 ) begin SELECT tbluserdetail.UserID,tbluserdetail.FirstName+' '+tbluserdetail.lastname as [Name], tbluserdetail.GroupID, tblWorkGroupMaster.GroupName,tblUserMaster.loginstatus,tblUserMaster.userName FROM tbluserdetail INNER JOIN tblWorkGroupMaster ON tbluserdetail.GroupId = tblWorkGroupMaster.GroupId inner join tblUserMaster on tbluserdetail.userid = tblUserMaster.userid WHERE tbluserdetail.userid = ( SELECT distinct Userid FROM tblusermaster WHERE Username = '******' ) end ", UserName, NewEncryptPassword)); if (dtuserdetails.Rows.Count > 0) { int intLoginStatus = Convert.ToInt32(dtuserdetails.Rows[0]["LoginStatus"]); if (intLoginStatus == 0) { Program.strUserName = Convert.ToString(dtuserdetails.Rows[0]["UserName"]); Program.UserId = dtuserdetails.Rows[0]["UserID"].ToString(); Returnvalue = 50; //redirect to home page } else { Program.strUserName = Convert.ToString(dtuserdetails.Rows[0]["UserName"]); Program.UserId = dtuserdetails.Rows[0]["UserID"].ToString(); Returnvalue = 100; //redirect to home page } } else { Returnvalue = -3;//invalid user; } } else { //ScriptManager.RegisterClientScriptBlock(Page, typeof(UpdatePanel), "msg", "alert('Invalid user name or password.')", true); //return; Returnvalue = -2;//invalid password; } } else { //ScriptManager.RegisterClientScriptBlock(Page, typeof(UpdatePanel), "msg", "alert('Invalid user name or password.')", true); //return; Returnvalue = -1;//invalid user name; } } catch (Exception ex) { Returnvalue = -3; } return Returnvalue; }
/// <summary> /// Method to encrypt the contents of this credentials object, clears all string data when complete. /// </summary> /// <param name="encrypt">Encryption object containing key and vector values</param> public void Encrypt(Encryption encrypt) { EncryptedWebsite = encrypt.Encrypt(Website); Website = string.Empty; EncryptedUrl = encrypt.Encrypt(Url); Url = string.Empty; EncryptedUsername = encrypt.Encrypt(Username); Username = string.Empty; EncryptedPassword = encrypt.Encrypt(Password); Password = string.Empty; EncryptedEmail = encrypt.Encrypt(EmailAddress); EmailAddress = string.Empty; }
/// <summary> /// Method to decrypt the contents of this Credentials object, clears all byte[] data when complete. /// </summary> /// <param name="encrypt">Encryption object containing key and vectory values</param> public void Decrypt(Encryption encrypt) { Website = encrypt.Decrypt(EncryptedWebsite); EncryptedWebsite = null; Url = encrypt.Decrypt(EncryptedUrl); EncryptedUrl = null; Username = encrypt.Decrypt(EncryptedUsername); EncryptedUsername = null; Password = encrypt.Decrypt(EncryptedPassword); EncryptedPassword = null; EmailAddress = encrypt.Decrypt(EncryptedEmail); EncryptedEmail = null; }
public void FilePathIsNull_DecryptFile() { Encryption encryption = new Encryption(); encryption.DecryptFile("plik.txt", null, "abc"); }
public void EncryptedFilePathIsNull_EncryptFile() { Encryption encryption = new Encryption(); encryption.EncryptFile("plik.txt", null, "password"); }
static void Main(string[] args) { Encryption encryption = new Encryption(); encryption.DecryptFile("plik.txt", null, "abcd"); }
public void FilePathIsNull_EncryptFile() { Encryption encryption = new Encryption(); encryption.EncryptFile(null, "encrypted.txt", "password"); }
/// <summary> /// Invoked when this page is about to be displayed in a Frame. /// </summary> /// <param name="e">Event data that describes how this page was reached. /// This parameter is typically used to configure the page.</param> protected override void OnNavigatedTo(NavigationEventArgs e) { this.itemID = int.Parse(e.Parameter.ToString()); this.currentEncrypt = dbHelper.GetEncryption(itemID); this.tb_encrypt.Text = currentEncrypt.Phrase; }
public void GetPendingUpdateQueues() { LobbyResult lobbyResult = new LobbyResult() { Host = "www.test.com", LobbyId = 1, LobbyIdSpecified = true, Name = "TestUpdate" }; string testPath = Path.Combine(Allegiance.CommunitySecuritySystem.Client.Integration.AllegianceRegistry.LobbyPath, lobbyResult.Name); if(Directory.Exists(testPath) == false) Directory.CreateDirectory(testPath); File.WriteAllText(Path.Combine(testPath, "test1.txt"), "this is a test file. It is for testing."); var encryption = new Encryption<SHA1>(); var checksum = encryption.Calculate(Path.Combine(testPath, "test1.txt")); AutoUpdateResult autoUpdateResult = new AutoUpdateResult() { AutoUpdateBaseAddress = "http://www.pork.com", Files = new FindAutoUpdateFilesResult[] { new FindAutoUpdateFilesResult() { AutoUpdateFileId = 1, AutoUpdateFileIdSpecified = true, CurrentVersion = "1.0.0.0", DateCreated = DateTime.Parse("4/8/2014"), DateCreatedSpecified = true, DateModified = DateTime.Parse("4/8/2014"), DateModifiedSpecified = true, Filename = "test1-notfound.txt", IsProtected = false, IsProtectedSpecified = true, LobbyId = 1, LobbyIdSpecified = true, ValidChecksum = checksum } } }; if (File.Exists("autoupdate.ds") == true) File.Delete("autoupdate.ds"); List<FindAutoUpdateFilesResult> result = Client.Service.AutoUpdate.ProcessPendingUpdates(lobbyResult, autoUpdateResult); Assert.AreEqual(1, result.Count, "File was not found, one update should have applied."); autoUpdateResult.Files[0].Filename = "test1.txt"; result = Client.Service.AutoUpdate.ProcessPendingUpdates(lobbyResult, autoUpdateResult); Assert.AreEqual(0, result.Count, "No updates should have been done, checksums match."); autoUpdateResult.Files[0].ValidChecksum = "INVALID_CHECKSUM"; result = Client.Service.AutoUpdate.ProcessPendingUpdates(lobbyResult, autoUpdateResult); Assert.AreEqual(1, result.Count, "One update should have been done, checksum miss-match with no prior update record."); var autoUpdate = DataStore.Open("autoupdate.ds", "Ga46^#a042"); var lastResults = new Dictionary<string, FindAutoUpdateFilesResult>(); //foreach (var res in result) // lastResults.Add(res.Filename, res); string dataKey = "Files_" + lobbyResult.LobbyId; autoUpdate[dataKey] = lastResults; autoUpdate.Save(); result = Client.Service.AutoUpdate.ProcessPendingUpdates(lobbyResult, autoUpdateResult); Assert.AreEqual(1, result.Count, "One update should have been done, checksum miss-match prior update dictionary exists, but no record for file."); autoUpdateResult.Files[0].ValidChecksum = checksum; foreach (var res in result) lastResults.Add(res.Filename, res); autoUpdate[dataKey] = lastResults; autoUpdate.Save(); result = Client.Service.AutoUpdate.ProcessPendingUpdates(lobbyResult, autoUpdateResult); Assert.AreEqual(0, result.Count, "No updates should have been done, versions match."); autoUpdateResult.Files[0].CurrentVersion = "1.0.0.1"; result = Client.Service.AutoUpdate.ProcessPendingUpdates(lobbyResult, autoUpdateResult); Assert.AreEqual(1, result.Count, "File version miss-match with previous version of file, update applied."); autoUpdateResult.Files[0].CurrentVersion = "1.0.0.0"; autoUpdateResult.Files[0].IsProtected = false; autoUpdateResult.Files[0].ValidChecksum = "INVALID_CHECKSUM"; result = Client.Service.AutoUpdate.ProcessPendingUpdates(lobbyResult, autoUpdateResult); Assert.AreEqual(1, result.Count, "updates should have been done, versions are same, checksum is different, file is not protected and the user has not modified the file."); autoUpdateResult.Files[0].DateModified = DateTime.Parse("1/1/2015"); result = Client.Service.AutoUpdate.ProcessPendingUpdates(lobbyResult, autoUpdateResult); Assert.AreEqual(0, result.Count, "updates should not have been done, versions are same, checksum is different, file is not protected and the user has modified the file since the last update."); //autoUpdateResult.Files[0].DateModified = DateTime.Parse("4/8/2014"); autoUpdateResult.Files[0].CurrentVersion = "1.0.0.0"; autoUpdateResult.Files[0].IsProtected = true; autoUpdateResult.Files[0].ValidChecksum = "INVALID_CHECKSUM"; result = Client.Service.AutoUpdate.ProcessPendingUpdates(lobbyResult, autoUpdateResult); Assert.AreEqual(1, result.Count, "updates should have been done, versions are same, checksum is different, file is protected and the user has modified the file."); }
public static List<FindAutoUpdateFilesResult> ProcessPendingUpdates(LobbyResult lobby, AutoUpdateResult results) { //Initialize Checksum class to use SHA1 var encryption = new Encryption<SHA1>(); //var root = AllegianceRegistry.EXEPath; //Allegiance root directory var autoUpdate = DataStore.Open("autoupdate.ds", "Ga46^#a042"); string dataKey = "Files_" + lobby.LobbyId; var lastResults = autoUpdate[dataKey] as Dictionary<string, FindAutoUpdateFilesResult>; List<FindAutoUpdateFilesResult> updateQueue = new List<FindAutoUpdateFilesResult>(); //Check files which need update foreach (var file in results.Files) { DebugDetector.AssertCheckRunning(); // You can put this in if you are testing the launcher with the production CSS server. // Turn off file protection on the launcher on the CSS server's Auto Update version of the launcher, // then drop the debug version of the launcher into your local game directory. Then you can // launch the launcher from the debugger and work with it. //#if DEBUG // if (file.Filename.EndsWith("Launcher.exe", StringComparison.InvariantCultureIgnoreCase) == true // || file.Filename.EndsWith("Launcher.pdb", StringComparison.InvariantCultureIgnoreCase) == true) // continue; //#endif string path; if (string.Equals(file.Filename, GlobalSettings.ClientExecutableName) || string.Equals(file.Filename, GlobalSettings.ClientExecutablePDB)) path = Path.Combine(AllegianceRegistry.LobbyPath, file.Filename); else path = GetLobbyPath(lobby, file.Filename); //Check that all files exist if (!File.Exists(path)) { Log.Write("File did not exist: " + path + ", will update."); updateQueue.Add(file); continue; } //Check that all file versions match if (lastResults != null && lastResults.ContainsKey(file.Filename) && (file.CurrentVersion != lastResults[file.Filename].CurrentVersion)) { Log.Write("File version mismatch, will update: " + file.Filename + ", server version: " + file.CurrentVersion + ", local version: " + lastResults[file.Filename].CurrentVersion); updateQueue.Add(file); continue; } // Test for checksum match, and if they don't replace the file if: // * This is the first time AutoUpdate has run for this installation. // * This is the first time this file has been seen by AutoUpdate // * The file has the protected flag turned on. var checksum = encryption.Calculate(path); if (!string.Equals(file.ValidChecksum, checksum)) { // If there haven't been any updates at all, and the checksums don't match, then overwrite the unknown file. (old installation / left over files from a previous uninstall) if (lastResults == null) { Log.Write("No prior autoupdate records, will updated: " + path); updateQueue.Add(file); continue; } // If there wasn't a prior update applied for the file, and the checksums don't match, then overwrite the unknown file. (An older file is on disk, and was re-added to the auto update system) if (!lastResults.ContainsKey(file.Filename)) { Log.Write("No record of file in autoupdate history, will update: " + path); updateQueue.Add(file); continue; } // If the file was changed on the server, but not modified by the user, then update. if (lastResults[file.Filename].DateModified == file.DateModified) { Log.Write("file was not user modified, and a change was detected from AU, will update: " + path); updateQueue.Add(file); continue; } // If the file is protected and the hashes don't match, then update. if (file.IsProtected) { Log.Write("File checksum mismatch, will update: " + path + ", server checksum: " + file.ValidChecksum + ", local checksum: " + checksum); updateQueue.Add(file); continue; } } } return updateQueue; }
protected static Encryption ParseEncryption(EncryptionSupportServiceEnum? EnableService, EncryptionSupportServiceEnum? DisableService = null) { //DisableService and EnableService should not have overlap if (DisableService != null && EnableService != null) { if ((DisableService & EnableService) != 0) throw new ArgumentOutOfRangeException("EnableEncryptionService, DisableEncryptionService", String.Format("EnableEncryptionService and DisableEncryptionService should no have overlap Service: {0}", DisableService & EnableService)); } Encryption accountEncryption = new Encryption(); accountEncryption.Services = new EncryptionServices(); if (EnableService != null && (EnableService & EncryptionSupportServiceEnum.Blob) == EncryptionSupportServiceEnum.Blob) { accountEncryption.Services.Blob = new EncryptionService(); accountEncryption.Services.Blob.Enabled = true; } if (DisableService != null && (DisableService & EncryptionSupportServiceEnum.Blob) == EncryptionSupportServiceEnum.Blob) { accountEncryption.Services.Blob = new EncryptionService(); accountEncryption.Services.Blob.Enabled = false; } return accountEncryption; }
// Evento PreLoad protected void Override_PagePreLoad(object sender, EventArgs e) { DAArea oDAArea = new DAArea(); ENTSession oENTSession; Encryption utilEncryption = new Encryption(); String sKey = ""; String sPage = ""; // Validación. Solo la primera vez que entre a la página if (this.IsPostBack) { return; } // Mensaje de error general sKey = utilEncryption.EncryptString("[V01] Acceso denegado", true); // Sesión if (this.Session["oENTSession"] == null){ this.Response.Redirect("~/Index.aspx", true); } // Información de Sesión oENTSession = (ENTSession)this.Session["oENTSession"]; // Token generado if (!oENTSession.TokenGenerado){ this.Response.Redirect("~/Index.aspx", true); } // Página que esta visitando sPage = this.Request.Url.AbsolutePath; sPage = sPage.Split(new Char[] { '/' })[sPage.Split(new Char[] { '/' }).Length - 1]; // Validación de permisos en la página actual if (sPage != "AppIndex.aspx" && sPage != "saLogout.aspx" && sPage != "saNotificacion.aspx"){ // Permisos if (oENTSession.tblSubMenu.Select("sPageName = '" + sPage + "'").Length < 1){ sKey = utilEncryption.EncryptString("[V02] No tiene permisos para acceder a esta página", true); this.Response.Redirect("~/Application/WebApp/Private/SysApp/saNotificacion.aspx?key=" + sKey, true); } // Compañía activa if ( oENTSession.idArea != 1 ){ if (oDAArea.IsAreaActive(oENTSession.idArea, ConfigurationManager.ConnectionStrings["Application.DBCnn"].ToString(), 0) == false){ sKey = utilEncryption.EncryptString("[V04] Su compañía no tiene permisos para acceder a esta página", true); this.Response.Redirect("~/Application/WebApp/Private/SysApp/saNotificacion.aspx?key=" + sKey, true); } } } // Validación de acceso a opciones [System Administrator] if ((sPage == "scatArea.aspx" || sPage == "scatMenu.aspx" || sPage == "scatSubMenu.aspx") && (oENTSession.idArea != 1) ){ sKey = utilEncryption.EncryptString("[V03] No tiene permisos para acceder a esta página", true); this.Response.Redirect("~/Application/WebApp/Private/SysApp/saNotificacion.aspx?key=" + sKey, true); } // Deshabilitar caché this.Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache); }
public CookieProtector(ICookieAuthenticationConfiguration configuration) { _encryption = Encryption.Create(configuration.EncryptionAlgorithm, configuration.EncryptionKey); _validation = Validation.Create(configuration.ValidationAlgorithm, configuration.ValidationKey); }
protected void NextClick(object sender, EventArgs e) { if (Session["AccountCreateType"] == null) Session["AccountCreateType"] = "Create"; bool isCreate = false; bool isShoppingCreate = false; if (Session["AccountCreateType"] == "Create") isCreate = true; if (Session["ShoppingCreate"] != null) isShoppingCreate = bool.Parse(Session["ShoppingCreate"].ToString()); Encryption encrypt = new Encryption(); bool openMessage = false; string boxMessage = ""; bool success = false; if (Session["HasUserBeenClicked"] == null) { try { Session["RedrawForm"] = false; string state = ""; bool isStateValid = false; if (StateLabel1RadComboBox.Visible) { if (StateLabel1RadComboBox.SelectedValue != "-1") isStateValid = true; } else if (StateLabel1TextBox.Text.Trim() != "") isStateValid = true; if (isStateValid) { if (Page.IsValid && RoleDropDown.SelectedValue != "-1" && AccountDropDown.SelectedValue != "-1") { Session["FormClicked"] = true; Session["formpage"] = "2"; bool hasState = false; if (StateLabel1RadComboBox.Visible) { if (StateLabel1RadComboBox.SelectedValue != "-1") hasState = true; } else if (StateLabel1TextBox.Text.Trim() != "") hasState = true; string isPassValid = IsPasswordValid(); if (hasState) { if (isPassValid == "success") { Session["AccountTypeLabel"] = AccountDropDown.SelectedItem.Value; Session["AccountFirstNameLabel"] = FirstNameTextBox.Text; Session["AccountLastNameLabel"] = LastNameTextBox.Text; Session["AccountRoleLabel"] = RoleDropDown.SelectedItem.Text; Session["AccountTitleLabel"] = TitleTextBox.Text; Session["AccountCompanyLabel"] = CompanyLabelTextBox.Text; Session["AccountResidentialLabel"] = ResidentialCheckBox.Checked; if (StateLabel1RadComboBox.Visible) state = StateLabel1RadComboBox.SelectedItem.Text; else state = StateLabel1TextBox.Text; Session["AccountStateLabel"] = state; Session["AccountCityLabel"] = CityLabelTextBox.Text; Session["AccountPhoneLabel"] = PhoneLabelTextBox.Text; if (exTextBox.Text.Trim() != "") { Session["AccountEx"] = exTextBox.Text; } Session["AccountAddressLabel"] = Address1LabelTextBox.Text; Session["AccountAddress2Label"] = Address2LabelTextBox.Text; Session["AccountZipLabel"] = ZipLabelTextBox.Text; Session["AccountCountryLabel"] = CountryLabel1RadComboBox.SelectedValue; Session["AccountEmailLabel"] = EmailTextBox.Text; Session["AccountPasswordLabel"] = PasswordTextBox.Text; Session["AccountNewsletterLabel"] = SignUpCheckBox.Checked; if (isCreate) { bool isError = false; try { success = CreateUser(); if (success) { string redir ="/MyAccount.aspx"; if (Request.QueryString["page"] != null && Request.QueryString["page"].Length > 0) { //lblMessage.Text = "Got here 1"; redir = "../"+Request.QueryString["page"].Replace("%20", "+").Replace(" ", "+"); } boxMessage = "Your account has been created. " + "<br/><br/><button onclick=\"Search('" + redir + "');\" >OK</button><br/>"; openMessage = true; JobRoles rolesJob = GetJobRole(RoleDropDown.SelectedItem.Text); if (rolesJob == JobRoles.Reseller_Contractor_Integrator) { boxMessage = "Your account has been created. Since your account type is 'Reseller', please remember that you can contact your representative for better pricing." + "<br/><br/><button onclick=\"Search('" + redir + "');\" >OK</button><br/>"; openMessage = true; } Session["HasUserBeenClicked"] = "true"; } } catch (CommandErrorException ex) { isError = true; if (ex.ErrorCode.ToString().ToLower() == "invalid_duplicatecustomer") { Static1Messages.Text = "A user already exists for this email address. Please choose a different email."; } else { Static1Messages.Text = ex.ToString(); } } catch (Exception ex) { isError = true; Static1Messages.Text = ex.ToString(); } } else { try { if (isShoppingCreate) { success = CreateUser(); //string redir = "/MyAccount.aspx"; //if (Request.QueryString["page"] != null && Request.QueryString["page"].Length > 0) //{ // //lblMessage.Text = "Got here 1"; // redir = Request.QueryString["page"].Replace("%20", "+").Replace(" ", "+"); //} if (success && Session["AccountBackClicked"] == null) { Explore.NetSuite.DataAccess.NDAL client = new Explore.NetSuite.DataAccess.NDAL(); Customer cust = client.GetCustomer(Session["UserID"].ToString()); boxMessage = "Your account has been created. " + "<br/><br/><button onclick=\"Search('/default.aspx?a=form&ID=2');\" >OK</button><br/>"; openMessage = true; if (IsUserInternational()) { boxMessage = "Your account has been created. At this time we do not provide international sales. To purchase a product, please contact your representative." + "<br/><br/><button onclick=\"Search('/MyAccount.aspx');\" >OK</button><br/>"; openMessage = true; } JobRoles rolesJob = GetJobRole(RoleDropDown.SelectedItem.Text); if (rolesJob == JobRoles.Reseller_Contractor_Integrator) { boxMessage = "Your account has been created. Since your account type is 'Reseller', please remember that you can contact your representative for better pricing." + "<br/><br/><button onclick=\"Search('/default.aspx?a=form&ID=2');\" >OK</button><br/>"; openMessage = true; } } else { openMessage = false; } } if (!openMessage && success) { if (CountryLabel1RadComboBox.SelectedItem.Value != "223") { Session["RedrawForm"] = true; Session["formpage"] = "9"; GoToForm(9, 1); } else { Session["RedrawForm"] = true; GoToForm(2, 1); Session["formpage"] = "2"; } } } catch (CommandErrorException ex) { Session["formpage"] = "1"; if (ex.ErrorCode.ToString().ToLower() == "invalid_duplicatecustomer") { Static1Messages.Text = "A user already exists for this email address. Please choose a different email."; } else { Static1Messages.Text = ex.ToString(); } } catch (Exception ex) { Session["formpage"] = "1"; Static1Messages.Text = ex.ToString(); } } if (openMessage && success) { MessageRadWindow.NavigateUrl = "Message.aspx?message=" + encrypt.encrypt(boxMessage); MessageRadWindow.Visible = true; MessageRadWindowManager.VisibleOnPageLoad = true; } } else { Static1Messages.Text = isPassValid; } } else { Static1Messages.Text = "State is required"; } } else { Static1Messages.Text = "Both Role and Account Type are required."; } } else { Static1Messages.Text = "State is required"; } } catch (CommandErrorException ex) { if (ex.ToString().Contains("for the following field:")) { ErrorLabel.Text = " The Phone is invalid."; } else { ErrorLabel.Text = ex.Message.ToString(); } } catch (Exception ex) { Session["formpage"] = "1"; ErrorLabel.Text = ex.ToString(); } } else { if (isCreate) { string redir = "/MyAccount.aspx"; if (Request.QueryString["page"] != null && Request.QueryString["page"].Length > 0) { //lblMessage.Text = "Got here 1"; redir = "../"+Request.QueryString["page"].Replace("%20", "+").Replace(" ", "+"); } boxMessage = "Your account has been created. " + "<br/><br/><button onclick=\"Search('" + redir + "');\" >OK</button><br/>"; openMessage = true; if (AccountDropDown.SelectedValue == "4") { boxMessage = "Your account has been created. Since your account type is 'Reseller', please remember that you can contact your representative for better pricing." + "<br/><br/><button onclick=\"Search('" + redir + "');\" >OK</button><br/>"; openMessage = true; } } else { if (isShoppingCreate) { //string redir = "/MyAccount.aspx"; //if (Request.QueryString["page"] != null && Request.QueryString["page"].Length > 0) //{ // //lblMessage.Text = "Got here 1"; // redir = Request.QueryString["page"].Replace("%20", "+").Replace(" ", "+"); //} if (Session["AccountBackClicked"] == null) { Explore.NetSuite.DataAccess.NDAL client = new Explore.NetSuite.DataAccess.NDAL(); Customer cust = client.GetCustomer(Session["UserID"].ToString()); boxMessage = "Your account has been created. " + cust.SalesRepID + "<br/><br/><button onclick=\"Search('/default.aspx?a=form&ID=2');\" >OK</button><br/>"; openMessage = true; if (IsUserInternational()) { boxMessage = "Your account has been created. At this time we do not provide international sales. To purchase a product, please contact your representative." + "<br/><br/><button onclick=\"Search('/MyAccount.aspx');\" >OK</button><br/>"; openMessage = true; } if (AccountDropDown.SelectedValue == "4") { boxMessage = "Your account has been created. Since your account type is 'Reseller', please remember that you can contact your representative for better pricing." + "<br/><br/><button onclick=\"Search('/default.aspx?a=form&ID=2');\" >OK</button><br/>"; openMessage = true; } } } if (!openMessage) { if (CountryLabel1RadComboBox.SelectedItem.Value != "223") { Session["RedrawForm"] = true; Session["formpage"] = "9"; GoToForm(9, 1); } else { Session["RedrawForm"] = true; GoToForm(2, 1); Session["formpage"] = "2"; } Session["HasUserBeenClicked"] = "true"; } } if (openMessage) { MessageRadWindow.NavigateUrl = "Message.aspx?message=" + encrypt.encrypt(boxMessage); MessageRadWindow.Visible = true; MessageRadWindowManager.VisibleOnPageLoad = true; } } }
public void PasswordIsNull_EncryptFile() { Encryption encryption = new Encryption(); encryption.EncryptFile("plik.txt", "encrypted.txt", null); }