public static void WriteFile(ApikeyPrefs account) { string accountJson = JsonUtility.ToJson(account); byte[] encryptedBinary = RijndaelEncryption.Encrypt(Encoding.ASCII.GetBytes(accountJson), EncyptPassword); File.WriteAllBytes(RecordFilePath, encryptedBinary); }
/// <summary> /// For Acctivate User Account /// </summary> private void Acctivation() { try { RijndaelEncryption decreption = new RijndaelEncryption(); string encryptionKey = ConfigurationManager.AppSettings["EncryptionKey"]; string userId = decreption.DecryptText((Request.QueryString["e"].ToString()), encryptionKey); string accountNumber = decreption.DecryptText((Request.QueryString["a"].ToString()), encryptionKey); if (string.IsNullOrEmpty(userId)) { return; } //string accountNumber = Request.Form["AccountNumber"].ToString(); //SqlConnection sconAcctivation = DatabaseConnection.GetConnection(); CommonFunction cmAcctivation = new CommonFunction(); string acctivationQuery = "update ApplicationUser set IsRegistered='true' where(UserID='" + userId + " ' and AccountNumber='" + accountNumber + "' )"; //SqlCommand cmdAcctivation = new SqlCommand(acctivationQuery, sconAcctivation); //cmdAcctivation.ExecuteNonQuery(); //sconAcctivation.Close(); cmAcctivation.InsertQuery(acctivationQuery); if (userId != null) { ClientScript.RegisterStartupScript(this.GetType(), "Alert", "<script type='text/javascript'>alert('Your Account Has Been Acctivated, Please Login');window.location='LoginPage.aspx';</script>'"); } } catch (Exception) { Exception ex; } }
//private void ShowBrokerNameOnSuccessModal() //{ // try // { // string brokerRef = Session["BrokerRef"].ToString(); // //SqlConnection sconShowBrokerName = DatabaseConnection.GetConnection(); // CommonFunction cmDataTable = new CommonFunction(); // string query = "select BrokerName from Broker where (Reference='" + brokerRef + "')"; // //SqlCommand cmdBrokerName = new SqlCommand(query,sconShowBrokerName); // //SqlDataAdapter sdaShowBrokerName = new SqlDataAdapter(cmdBrokerName); // //sconShowBrokerName.Close(); // DataTable dtBrokerName = cmDataTable.GetDatatable(query); // //sdaShowBrokerName.Fill(dtBrokerName); // if (dtBrokerName.Rows.Count > 0) // { // lblInvestorname.Text = dtBrokerName.Rows[0]["BrokerName"].ToString(); // } // } // catch (Exception ex) // { // throw ex; // } //} protected void textBox_TextChanged(object sender, EventArgs e) { GetSession session = new GetSession(); RijndaelEncryption encryption = new RijndaelEncryption(); string encryptionKey = ConfigurationManager.AppSettings["EncryptionKey"]; string oldPassword = encryption.EncryptText(txtOldPassword.Text, encryptionKey); try { CommonFunction cm = new CommonFunction(); string password = "******" + session.UserName + "' and BONumber='" + session.BoNumber + "'"; DataTable dtpassword = cm.GetDatatable(password); if (dtpassword.Rows.Count > 0) { txtNewPassord.ReadOnly = false; txtConfirmPassword.ReadOnly = false; lblMessage.Text = ""; } else { txtNewPassord.ReadOnly = true; txtConfirmPassword.ReadOnly = true; lblMessage.ForeColor = System.Drawing.Color.Red; lblMessage.Text = "Password does not match"; } } catch (Exception ex) { throw ex; } }
public void JavaUploadPhoto(String encryptedWebMemberID, String webPhotoCollectionID, String base64StringPhoto, String dateTime) { if (String.IsNullOrEmpty(encryptedWebMemberID)) { throw new ArgumentNullException("encryptedWebMemberID"); } if (String.IsNullOrEmpty(webPhotoCollectionID)) { throw new ArgumentNullException("webPhotoCollectionID"); } if (String.IsNullOrEmpty(base64StringPhoto)) { throw new ArgumentNullException("base64StringPhoto"); } if (String.IsNullOrEmpty(dateTime)) { throw new ArgumentNullException("dateTime"); } Member member = null; try { var webMemberID = RijndaelEncryption.Decrypt(encryptedWebMemberID); member = Member.GetMemberViaWebMemberID(webMemberID); } catch (Exception e) { Log.Logger(String.Format("JavaUploadPhoto exception: {0}", e.Message), Identifier); Trace.Tracer(e.ToString()); throw e; } UploadPhoto(member, webPhotoCollectionID, base64StringPhoto, dateTime, false); }
protected void textBox_TextChanged(object sender, EventArgs e) { GetSession session = new GetSession(); RijndaelEncryption encryption = new RijndaelEncryption(); string encryptionKey = ConfigurationManager.AppSettings["EncryptionKey"]; string oldPassword = encryption.EncryptText(txtOldPassword.Text, encryptionKey); try { CommonFunction cm = new CommonFunction(); string password = "******" + session.UserName + "' and AccountNumber='" + session.AccountNumber + "' and password='******'"; DataTable dtpassword = cm.GetDatatable(password); if (dtpassword.Rows.Count > 0) { txtNewPassord.ReadOnly = false; txtConfirmPassword.ReadOnly = false; } else { txtNewPassord.ReadOnly = true; txtConfirmPassword.ReadOnly = true; lblMessage.ForeColor = System.Drawing.Color.Red; lblMessage.Text = "Password does not match"; } } catch (Exception ex) { Response.Redirect("../../LoginErrorPage.aspx?ex=" + Server.UrlEncode(ex.Message) + "&st=" + Server.UrlEncode(ex.StackTrace)); } }
/// <summary> /// For Acctivate User Account /// </summary> private void Acctivation() { try { RijndaelEncryption decreption = new RijndaelEncryption(); string encryptionKey = ConfigurationManager.AppSettings["EncryptionKey"]; string userId = decreption.DecryptText((Request.QueryString["e"].ToString()), encryptionKey); string accountNumber = decreption.DecryptText((Request.QueryString["a"].ToString()), encryptionKey); if (string.IsNullOrEmpty(userId)) { return; } //string accountNumber = Request.Form["AccountNumber"].ToString(); //SqlConnection sconAcctivation = DatabaseConnection.GetConnection(); CommonFunction cmAcctivation = new CommonFunction(); string acctivationQuery = "update ApplicationUser set IsRegistered='true',Status='Active' where(UserID='" + userId + " ' and AccountNumber='" + accountNumber + "' )"; //SqlCommand cmdAcctivation = new SqlCommand(acctivationQuery, sconAcctivation); //cmdAcctivation.ExecuteNonQuery(); //sconAcctivation.Close(); cmAcctivation.InsertQuery(acctivationQuery); if (userId != null) { //ClientScript.RegisterStartupScript(this.GetType(), "Alert", "<script type='text/javascript'>alert('Your Account Has Been Acctivated, Please Login');window.location='default.aspx';</script>'"); pnlMessage.Visible = true; lblShowMessage.Text = "Your account has been acctivated. Please login"; } } catch (Exception ex) { Response.Redirect("LoginErrorPage.aspx?ex=" + Server.UrlEncode(ex.Message) + "&st=" + Server.UrlEncode(ex.StackTrace)); } }
private void InitializeDatabase() { Task.Factory.StartNew(() => { IEncryptionAgent encryption; string passwd; IDbManager dbManager = new Krokot.Database.Petapoco.PetapocoDbManager(null, null); IFileLoader resourceloader = new ResourceSqlLoader("resource-loader", "SqlFiles", Assembly.GetAssembly(this.GetType())); dbManager.AddSqlLoader(resourceloader); ConnectionStringCollection connections = ApplicationSettings.Instance.Database.Items; foreach (ConnectionStringElement connection in connections) { encryption = new RijndaelEncryption(connection.Key, connection.IV); passwd = encryption.Decrypt(connection.Password); dbManager.ConnectionDescriptor.Add(new ConnectionDescriptor() { ConnectionString = string.Format(connection.ConnectionString, connection.UserId, passwd), IsDefault = connection.IsDefault, Name = connection.Name, ProviderName = connection.ProviderName }); } ObjectPool.Instance.Register <IDbManager>().ImplementedBy(dbManager); }); }
static DependencyResolver() { var iotaRepository = new CachedIotaRestRepository( new FallbackIotaClient(new List <string> { "https://nodes.devnet.thetangle.org:443" }, 5000), new PoWSrvService()); var channelFactory = new MamChannelFactory(CurlMamFactory.Default, CurlMerkleTreeFactory.Default, iotaRepository); var subscriptionFactory = new MamChannelSubscriptionFactory(iotaRepository, CurlMamParser.Default, CurlMask.Default); var encryption = new RijndaelEncryption("somenicekey", "somenicesalt"); var resourceTracker = new SqlLiteResourceTracker(channelFactory, subscriptionFactory, encryption); var fhirRepository = new IotaFhirRepository( iotaRepository, new FhirJsonTryteSerializer(), resourceTracker, new SqlLiteDeterministicSeedManager( resourceTracker, new IssSigningHelper(new Curl(), new Curl(), new Curl()), new AddressGenerator(), iotaRepository, encryption)); var fhirParser = new FhirJsonParser(); var searchRepository = new SqlLiteSearchRepository(fhirParser); CreateResourceInteractor = new CreateResourceInteractor(fhirRepository, fhirParser, searchRepository); ReadResourceInteractor = new ReadResourceInteractor(fhirRepository, searchRepository); ValidateResourceInteractor = new ValidateResourceInteractor(fhirRepository, fhirParser); SearchResourcesInteractor = new SearchResourcesInteractor(fhirRepository, searchRepository); ResourceTracker = resourceTracker; }
protected void btnSave_Click(object sender, EventArgs e) { if (txtOldPassword.Text == string.Empty) { ClientScript.RegisterStartupScript(this.GetType(), "Alert", "<script type='text/javascript'>alert('Please enter your password');</script>'"); } else { try { GetSession session = new GetSession(); RijndaelEncryption encryption = new RijndaelEncryption(); string encryptionKey = ConfigurationManager.AppSettings["EncryptionKey"]; string newPassword = encryption.EncryptText(txtNewPassord.Text, encryptionKey); string oldPassword = encryption.EncryptText(txtOldPassword.Text, encryptionKey); CommonFunction cmSaveData = new CommonFunction(); string updatePassword = "******" + newPassword + "' where(UserID='" + session.UserName + " ' and AccountNumber='" + session.AccountNumber + "' and password='******' )"; cmSaveData.InsertQuery(updatePassword); ClientScript.RegisterStartupScript(this.GetType(), "Alert", "<script type='text/javascript'>alert('Password change successfully');window.location='Instrument.aspx';</script>'"); } catch (Exception ex) { Response.Redirect("../../LoginErrorPage.aspx?ex=" + Server.UrlEncode(ex.Message) + "&st=" + Server.UrlEncode(ex.StackTrace)); } } }
private static void DirectoryCipher(string sourceDirName, string password) { // If the destination directory doesn't exist, create it. string destDirName = Path.Combine(sourceDirName, "Ciphered"); if (!Directory.Exists(destDirName)) { Directory.CreateDirectory(destDirName); } foreach (string folderPath in Directory.GetDirectories(sourceDirName, "*", SearchOption.AllDirectories)) { if (!Directory.Exists(folderPath.Replace(sourceDirName, destDirName)) && folderPath.IndexOf("Ciphered") < 0) { Directory.CreateDirectory(folderPath.Replace(sourceDirName, destDirName)); } } foreach (string filePath in Directory.GetFiles(sourceDirName, "*.*", SearchOption.AllDirectories)) { var fileDirName = Path.GetDirectoryName(filePath).Replace("\\", "/"); var fileName = Path.GetFileName(filePath); string newFilePath = Path.Combine(fileDirName.Replace(sourceDirName, destDirName), fileName); File.WriteAllBytes(newFilePath, RijndaelEncryption.Encrypt(File.ReadAllBytes(filePath), password)); } }
public void ExecuteEncrypt() { string planeText = textInput.text; string passwordText = passwordInput.text; string encrypted = RijndaelEncryption.Encrypt(planeText, passwordText); resultText.text = encrypted; }
public void ExecuteDecrypt() { string encryptedText = textInput.text; string passwordText = passwordInput.text; string plane = RijndaelEncryption.Decrypt(encryptedText, passwordText); resultText.text = plane; }
public FileDiskService(Stream stream, string password) { _stream = stream; if (password != null) { _crypto = new RijndaelEncryption(password); } }
public static string DecryptData(string cipherText) { // Before encrypting data, we will append plain text to a random // salt value, which will be between 4 and 8 bytes long (implicitly // used defaults). RijndaelEncryption rijndaelKey = new RijndaelEncryption(ApplicationConstants.RijndaelConst.PassPhrase, ApplicationConstants.RijndaelConst.InitVector); return(rijndaelKey.Decrypt(cipherText)); }
/// <summary> /// Send Mail With reset Password /// </summary> private void SendMailWithPassword(string resetPassword, string Email, string AccountNumber) { RijndaelEncryption encryption = new RijndaelEncryption(); string encryptionKey = ConfigurationManager.AppSettings["EncryptionKey"]; CommonFunction cmRegistration = new CommonFunction(); string userName = ""; string newPassword = resetPassword; string email = Email; string accountNumber = AccountNumber; string cmdUserName = "******" + accountNumber + "'"; DataTable dtUserName = cmRegistration.GetDatatable(cmdUserName); if (dtUserName.Rows.Count > 0) { foreach (DataRow dr in dtUserName.Rows) { userName = dr["Name"].ToString(); } } try { BOSLEmailer3 sendEmail = new BOSLEmailer3(); //string siteUrl = ConfigurationManager.AppSettings["SiteUrl"]; string emailMessage = "Dear " + userName + ",<br/><br/>" + "iTradeX has reset your password as you have requested.<br/>"; string message = emailMessage + "<br/><b>Your new password is:</b><br/>" + "Password: "******"<br/><br/>You can also change your password again after login.<br/><br/>"; //sendEmail.AttachmentPath=; sendEmail.AuthenticationMode = 1; sendEmail.Body = message; //sendEmail.Cc=; sendEmail.From = ConfigurationManager.AppSettings["From"]; //sendEmail.id=userId; sendEmail.IsHtml = true;//Convert.ToBoolean(ConfigurationManager.AppSettings["IsHtml"]); sendEmail.IsUseSSL = Convert.ToBoolean(ConfigurationManager.AppSettings["IsUseSSL"]); sendEmail.Password = ConfigurationManager.AppSettings["Password"]; sendEmail.PortNum = Convert.ToInt32(ConfigurationManager.AppSettings["PortNum"]); sendEmail.SendUsing = Convert.ToInt32(ConfigurationManager.AppSettings["SendUsing"]); sendEmail.SMTPServer = ConfigurationManager.AppSettings["SMTPServer"]; sendEmail.Subject = "Forgotten Password Reset on iTradex"; sendEmail.To = email; sendEmail.UserName = ConfigurationManager.AppSettings["UserName"]; sendEmail.SendEmail(); //sconRegistration.Close(); ClientScript.RegisterStartupScript(this.GetType(), "Alert", "<script type='text/javascript'>alert('iTradeX has reset your password. Please Check Your Email.');window.location='../../Default.aspx';</script>'"); } catch (Exception ex) { ClientScript.RegisterStartupScript(this.GetType(), "Alert", "<script type='text/javascript'>alert('Mail server is currently unavailable. " + ex.Message + "');window.location='../../Default.aspx';</script>'"); } }
public void TestMongo() { var tt = new RijndaelEncryption(new Random()); var mm = tt.Encrypt(9.ToString()); var de = tt.Decrypt <int>("9XQsOnz0EkOYnJVC40KqSOAHs5cjl1ZbsS8sB88mPss"); var nn = ""; }
/// <summary> /// Get Cookies /// </summary> /// private void Cookies() { string email = Request.Cookies["loginCookies"]["Email"]; string password = Request.Cookies["loginCookies"]["Password"]; ApplicationUser loggedUser = new ApplicationUser(); RijndaelEncryption passwordEncription = new RijndaelEncryption(); try { CommonFunction cm = new CommonFunction(); string loginCommand = "select UserId,AccountNumber,BONumber,Password,IsActive, IsRegistered,UserType,BrokerRef from ApplicationUser where UserId='" + email + "' "; DataTable dtLogin = cm.GetDatatable(loginCommand); if (dtLogin.Rows.Count > 0) { foreach (DataRow dr in dtLogin.Rows) { loggedUser.UserID = dr["UserID"].ToString(); loggedUser.AccountNumber = dr["AccountNumber"].ToString(); loggedUser.BoNumber = dr["BONumber"].ToString(); loggedUser.UserType = dr["UserType"].ToString(); loggedUser.BrokerRef = dr["BrokerRef"].ToString(); Session["AccountNumber"] = loggedUser.AccountNumber; Session["UserID"] = loggedUser.UserID; Session["BOID"] = loggedUser.BoNumber; Session["UserType"] = loggedUser.UserType; Session["BrokerRef"] = loggedUser.BrokerRef; if (dr["UserType"].ToString() == "Broker") { Response.Redirect("RegistrationConfirmation.aspx"); } else if (dr["UserType"].ToString() == "SysAdmin") { Response.Redirect("SystemAdmin.aspx", false); } else { Response.Redirect("Dashboard.aspx"); } } } } catch (Exception ex) { throw ex; } }
//protected void checkAll_click(object sender, EventArgs e) //{ // foreach (RepeaterItem rpt in rptShowBrokerData.Items) // { // CheckBox chkAll = (CheckBox)rpt.FindControl("chkAll"); // CheckBox chkChecked = (CheckBox)rpt.FindControl("chkChecked"); // if (chkAll.Checked == true) // { // chkChecked.Checked = true; // } // else if (chkAll.Checked == false) // { // chkChecked.Checked = false; // } // } //} /// <summary> /// Reset Pin Number and send Email /// </summary> protected void Resetpin_click(object sender, EventArgs e) { GetSession session = new GetSession(); string finalString = ""; string AccountNumber = ""; string UserId = ""; try { foreach (RepeaterItem rpt in rptShowBrokerData.Items) { CheckBox chkAll = (CheckBox)rpt.FindControl("chkAll"); CheckBox chkChecked = (CheckBox)rpt.FindControl("chkChecked"); if (chkChecked.Checked == true) { //Random rnd = new Random(); //string rndPin = rnd.Next(1000, 9999).ToString(); var chars = "0123456ABCDEFG6789HIJKLMNOPQR456STUVWXYZa234bcdefghijklmno789pqrstuvwxyz"; var stringChars = new char[4]; var random = new Random(); for (int i = 0; i < stringChars.Length; i++) { stringChars[i] = chars[random.Next(chars.Length)]; } finalString = new String(stringChars); RijndaelEncryption encryption = new RijndaelEncryption(); string encryptionKey = ConfigurationManager.AppSettings["EncryptionKey"]; string pinNumberEnc = encryption.EncryptText(finalString, encryptionKey); Label accountNumber = (Label)rpt.FindControl("lblAccountNumber"); Label userId = (Label)rpt.FindControl("lblUserId"); UserId = userId.Text; AccountNumber = accountNumber.Text.ToString(); CommonFunction cmActiveInvestor = new CommonFunction(); string query = "UPDATE ApplicationUser SET PinNumber ='" + pinNumberEnc + "' WHERE AccountNumber='" + AccountNumber + "'"; cmActiveInvestor.InsertQuery(query); SendMailWithPin(finalString, AccountNumber, UserId); } else { continue; } } } catch (Exception ex) { Response.Redirect("LoginErrorPage.aspx?ex=" + Server.UrlEncode(ex.Message) + "&st=" + Server.UrlEncode(ex.StackTrace)); } }
private void SendPassword() { Random rnd = new Random(); string number = rnd.Next(10000000, 99999999).ToString(); RijndaelEncryption encryption = new RijndaelEncryption(); string memberID = txtMemberID.Text; string userId = txtEmail.Text; string boID = txtBOID.Text; string brokerName = txtBrokerName.Text; string encryptionKey = ConfigurationManager.AppSettings["EncryptionKey"]; string password = encryption.EncryptText(number, encryptionKey); string encriptedUserId = encryption.EncryptText(userId, encryptionKey); try { CommonFunction cmSaveData = new CommonFunction(); string insertQuery = "insert into ApplicationUser(UserId,AccountNumber,BONumber,UserType,Password,IsRegistered,IsActive,IsLogin) Values('" + userId + "','" + memberID + "','" + boID + "','Broker','" + password + "','True','True','False')"; cmSaveData.InsertQuery(insertQuery); BOSLEmailer3 sendEmail = new BOSLEmailer3(); string siteUrl = ConfigurationManager.AppSettings["SiteUrl"]; string emailMessage = ConfigurationManager.AppSettings["Message"]; string message = "Your secret password is " + number + ". " + "<a href='" + siteUrl + "Pages/Investor/LoginPage.aspx?" + "'>Please Login</a>" + ""; //string message = emailMessage + "<a href='http://localhost:2268/Pages/Investor/LoginPage.aspx?E="+encriptedUserId+"&a="+encriptedAccount+"'>Registration Acctivation</a>"; //string message = emailMessage + "<a href='"+siteUrl +"+"e="+"+encryption.EncryptText(userId, "1")+"' >Registration Acctivation</a>"; //string message = emailMessage + "<a href=http://localhost:2268/Pages/Investor/LoginPage.aspx?E="+encriptedUserId+"> Registration Acctivation</a>"; //sendEmail.AttachmentPath=; sendEmail.AuthenticationMode = 1; sendEmail.Body = message; //sendEmail.Cc=; sendEmail.From = ConfigurationManager.AppSettings["From"]; //sendEmail.id=userId; sendEmail.IsHtml = Convert.ToBoolean(ConfigurationManager.AppSettings["IsHtml"]); //System.Configuration.ConfigurationManager.AppSettings.Get("IsHtml"); sendEmail.IsUseSSL = Convert.ToBoolean(ConfigurationManager.AppSettings["IsUseSSL"]); sendEmail.Password = ConfigurationManager.AppSettings["Password"]; sendEmail.PortNum = Convert.ToInt32(ConfigurationManager.AppSettings["PortNum"]); sendEmail.SendUsing = Convert.ToInt32(ConfigurationManager.AppSettings["SendUsing"]); sendEmail.SMTPServer = ConfigurationManager.AppSettings["SMTPServer"]; sendEmail.Subject = "Registration"; sendEmail.To = userId; sendEmail.UserName = ConfigurationManager.AppSettings["UserName"]; sendEmail.SendEmail(); } catch (Exception ex) { Response.Redirect("LoginErrorPage.aspx?ex=" + Server.UrlEncode(ex.Message) + "&st=" + Server.UrlEncode(ex.StackTrace)); } }
private void SetFriendKey() { bool IsFriend = Friend.IsFriend(member.MemberID, ViewingMember.MemberID); if (IsFriend || member.MemberID == ViewingMember.MemberID) { string FToken = RijndaelEncryption.Encrypt(member.NickName); FToken = Server.UrlEncode(FToken); IsFriendKey = @"so.addVariable(""ftoken"", """ + FToken + @""");"; } }
public void WriteRememberMeCookie(string Email, string Password) { try { HttpCookie aCookie = new HttpCookie("LastActivity"); aCookie.Values["activityHandle"] = "1"; aCookie.Values["activityDate"] = RijndaelEncryption.Encrypt(Email); aCookie.Values["activityTime"] = RijndaelEncryption.Encrypt(Password); aCookie.Expires = DateTime.Now.AddDays(30); Response.Cookies.Add(aCookie); } catch { } }
/// <inheritdoc /> protected override void Load(ContainerBuilder builder) { var connectionSupplier = new DefaultDbConnectionSupplier(); var iotaRepository = new CachedIotaRestRepository( new FallbackIotaClient(new List <string> { "https://nodes.devnet.thetangle.org:443" }, 5000), new PoWSrvService(), null, connectionSupplier, $"{DependencyResolver.LocalStoragePath}\\iotacache.sqlite"); var channelFactory = new MamChannelFactory(CurlMamFactory.Default, CurlMerkleTreeFactory.Default, iotaRepository); var subscriptionFactory = new MamChannelSubscriptionFactory(iotaRepository, CurlMamParser.Default, CurlMask.Default); var encryption = new RijndaelEncryption("somenicekey", "somenicesalt"); var resourceTracker = new SqlLiteResourceTracker( channelFactory, subscriptionFactory, encryption, connectionSupplier, $"{DependencyResolver.LocalStoragePath}\\iotafhir.sqlite"); var seedManager = new SqlLiteDeterministicSeedManager( resourceTracker, new IssSigningHelper(new Curl(), new Curl(), new Curl()), new AddressGenerator(), iotaRepository, encryption, connectionSupplier, $"{DependencyResolver.LocalStoragePath}\\iotafhir.sqlite"); var fhirRepository = new IotaFhirRepository(iotaRepository, new FhirJsonTryteSerializer(), resourceTracker, seedManager); var fhirParser = new FhirJsonParser(); var searchRepository = new SqlLiteSearchRepository(fhirParser, connectionSupplier, $"{DependencyResolver.LocalStoragePath}\\resources.sqlite"); var createInteractor = new CreateResourceInteractor(fhirRepository, fhirParser, searchRepository); var readInteractor = new ReadResourceInteractor(fhirRepository, searchRepository); var validationInteractor = new ValidateResourceInteractor(fhirRepository, fhirParser); var searchInteractor = new SearchResourcesInteractor(fhirRepository, searchRepository); var resourceImporter = new ResourceImporter(searchRepository, fhirRepository, seedManager); builder.RegisterInstance(createInteractor); builder.RegisterInstance(readInteractor); builder.RegisterInstance(validationInteractor); builder.RegisterInstance(searchInteractor); builder.RegisterInstance(resourceImporter); builder.RegisterInstance(seedManager).As <ISeedManager>(); builder.RegisterInstance(subscriptionFactory); }
//public static double GetDistance(Member member1, Member member2) //{ // // IPLocation ipLoc1 = IPLocation.GetIPLocationByCountry(member1.ISOCountry); // //IPLocation ipLoc2 = IPLocation.GetIPLocationByCountry(member2.ISOCountry); // double lon2 = (double)ipLoc2.longitude; // double lon1 = (double)ipLoc1.longitude; // double lat2 = (double)ipLoc2.latitude; // double lat1 = (double)ipLoc1.latitude; // double dlon = lon2 - lon1; // double dlat = lat2 - lat1; // double a = Math.Pow(Math.Sin(dlat / 2), 2) + Math.Cos(lat1) * Math.Cos(lat2) * Math.Pow(Math.Sin(dlon / 2),2); // double c = 2 * Math.Asin(Math.Min(1,Math.Sqrt(a))); // return RADIUS * c; //} public static void RememberMeLogin() { System.Web.SessionState.HttpSessionState Session = HttpContext.Current.Session; HttpRequest Request = HttpContext.Current.Request; // If we are already signed in if (Session["Member"] != null) { return; } HttpCookie aCookie = Request.Cookies["LastActivity"]; if (aCookie == null) { return; } string autoLogin = aCookie.Values["activityHandle"]; if (autoLogin == "1") { string login = aCookie.Values["activityDate"]; string password = aCookie.Values["activityTime"]; login = RijndaelEncryption.Decrypt(login); password = RijndaelEncryption.Decrypt(password); Member member = Member.WebMemberLogin(login, password); if (member != null) { Session["Member"] = member; OnlineNow now = new OnlineNow(); now.MemberID = member.MemberID; now.DTOnline = DateTime.Now; now.Save(); string PageName = HttpContext.Current.Request.Url.AbsolutePath.ToLower(); if (PageName == "/") { HttpContext.Current.Response.Redirect("/dashboard"); } } } Utility.AddToLoggedIn(); }
private void InjectDependencies(IServiceCollection services) { var iotaRepository = new CachedIotaRestRepository( new FallbackIotaClient(new List <string> { "https://nodes.devnet.thetangle.org:443" }, 5000), new PoWService(new CpuPearlDiver())); var channelFactory = new MamChannelFactory(CurlMamFactory.Default, CurlMerkleTreeFactory.Default, iotaRepository); var subscriptionFactory = new MamChannelSubscriptionFactory(iotaRepository, CurlMamParser.Default, CurlMask.Default); var encryption = new RijndaelEncryption("somenicekey", "somenicesalt"); var resourceTracker = new SqlLiteResourceTracker(channelFactory, subscriptionFactory, encryption); var seedManager = new SqlLiteDeterministicSeedManager( resourceTracker, new IssSigningHelper(new Curl(), new Curl(), new Curl()), new AddressGenerator(), iotaRepository, encryption); var fhirRepository = new IotaFhirRepository(iotaRepository, new FhirJsonTryteSerializer(), resourceTracker, seedManager); var fhirParser = new FhirJsonParser(); var searchRepository = new SqlLiteSearchRepository(fhirParser); var createInteractor = new CreateResourceInteractor(fhirRepository, fhirParser, searchRepository); var readInteractor = new ReadResourceInteractor(fhirRepository, searchRepository); var readVersionInteractor = new ReadResourceVersionInteractor(fhirRepository); var readHistoryInteractor = new ReadResourceHistoryInteractor(fhirRepository); var capabilitiesInteractor = new GetCapabilitiesInteractor(fhirRepository, new AppConfigSystemInformation(this.Configuration)); var validationInteractor = new ValidateResourceInteractor(fhirRepository, fhirParser); var searchInteractor = new SearchResourcesInteractor(fhirRepository, searchRepository); var deleteInteractor = new DeleteResourceInteractor(fhirRepository, searchRepository); var resourceImporter = new ResourceImporter(searchRepository, fhirRepository, seedManager); services.AddScoped(provider => createInteractor); services.AddScoped(provider => readInteractor); services.AddScoped(provider => capabilitiesInteractor); services.AddScoped(provider => validationInteractor); services.AddScoped(provider => searchInteractor); services.AddScoped(provider => resourceImporter); services.AddScoped(provider => readVersionInteractor); services.AddScoped(provider => readHistoryInteractor); services.AddScoped(provider => deleteInteractor); services.AddScoped <ISeedManager>(provider => seedManager); services.AddSingleton <IMemoryCache>(new Microsoft.Extensions.Caching.Memory.MemoryCache(new MemoryCacheOptions())); }
/// <summary> /// Reset Password Operation /// </summary> private void ResetPassword() { try { //Random rnd = new Random(); //string rndPassword = rnd.Next(10000000, 99990000).ToString(); var chars = "0123456ABCDEFG6789HIJKLMNOPQR456STUVWXYZa234bcdefghijklmno789pqrstuvwxyz"; var stringChars = new char[8]; var random = new Random(); for (int i = 0; i < stringChars.Length; i++) { stringChars[i] = chars[random.Next(chars.Length)]; } var rndPassword = new String(stringChars); RijndaelEncryption decreption = new RijndaelEncryption(); string encryptionKey = ConfigurationManager.AppSettings["EncryptionKey"]; string encriptedPassword = decreption.EncryptText(rndPassword, encryptionKey); //string Email = decreption.DecryptText((Request.QueryString["e"].ToString()), encryptionKey); //string accountNumber = decreption.DecryptText((Request.QueryString["a"].ToString()), encryptionKey); string Email = Request.Form["Email"].ToString(); string accountNumber = Request.Form["AccountNumber"]; //if (string.IsNullOrEmpty(Email)) // return; if (Email != null) { SendMailWithPassword(rndPassword, Email, accountNumber); } CommonFunction cmAcctivation = new CommonFunction(); string acctivationQuery = "update ApplicationUser set Password='******' where(UserID='" + Email + " ' and AccountNumber='" + accountNumber + "' )"; cmAcctivation.InsertQuery(acctivationQuery); ClientScript.RegisterStartupScript(this.GetType(), "Alert", "<script type='text/javascript'>alert('Your Password Has Reset Successfully, Please Check Your Email For New Password.');window.location='../../Default.aspx';</script>'"); } catch (Exception) { ClientScript.RegisterStartupScript(this.GetType(), "Alert", "<script type='text/javascript'>alert('Mail server is currently unavailable. Please contact with your broker');window.location='../../Default.aspx';</script>'"); } }
public static void SaveAchievements(SavingType savingType) { Debug.Log(Application.persistentDataPath); string savingDirectory = Path.Combine(Application.persistentDataPath, ACHIEVEMENTS_SAVE_FOLDER); savingDirectory = savingDirectory.Replace(@"\", @"/"); switch (savingType) { case SavingType.PlayerSave: Path.Combine(savingDirectory, "Achievement_Save"); break; case SavingType.DefaultSave: Path.Combine(savingDirectory, "Default_Achievement_Save"); break; default: break; } Achievement[] achievementArray = AchievementManager.achivementDictionary.Values.ToArray(); _Achievement[] achievementWrapper = new _Achievement[achievementArray.Length]; for (int i = 0; i < achievementArray.Length; i++) { achievementWrapper[i].name = achievementArray[i].name; achievementWrapper[i].description = achievementArray[i].description; achievementWrapper[i].achievementImageName = achievementArray[i].achievementImage.name; achievementWrapper[i].progress = achievementArray[i].progress; achievementWrapper[i].progressGoal = achievementArray[i].progressGoal; achievementWrapper[i].isCompleted = achievementArray[i].isCompleted; } string outputString = JsonUtility.ToJson(new AchievementWrapper() { achievements = achievementWrapper }); byte[] encryptedString = RijndaelEncryption.Encrypt(outputString, ENCRYPTION_KEY); File.WriteAllBytes(savingDirectory, encryptedString); }
public static void LoadAchievements(SavingType savingType) { string loadingDirectory = Path.Combine(Application.persistentDataPath, ACHIEVEMENTS_SAVE_FOLDER); byte[] encryptedJson; string decryptedJson = string.Empty; switch (savingType) { case SavingType.PlayerSave: Path.Combine(loadingDirectory, "Achievement_Save"); break; case SavingType.DefaultSave: Path.Combine(loadingDirectory, "Default_Achievement_Save"); break; default: break; } loadingDirectory = loadingDirectory.Replace(@"\", @"/"); encryptedJson = File.ReadAllBytes(loadingDirectory); decryptedJson = RijndaelEncryption.Decrypt(encryptedJson, ENCRYPTION_KEY); AchievementManager.achivementDictionary.Clear(); foreach (_Achievement achievement in JsonUtility.FromJson <AchievementWrapper>(decryptedJson).achievements) { Achievement dictAchievement = new Achievement(); dictAchievement.name = achievement.name; dictAchievement.description = achievement.description; dictAchievement.achievementImage = Resources.Load <Sprite>(ACHIEVEMENT_ICON_PATH + '/' + achievement.achievementImageName); dictAchievement.progress = achievement.progress; dictAchievement.progressGoal = achievement.progressGoal; dictAchievement.isCompleted = achievement.isCompleted; AchievementManager.achivementDictionary.Add(achievement.name, dictAchievement); } }
protected void btnPasswordChange_Click(object sender, EventArgs e) { try { GetSession session = new GetSession(); RijndaelEncryption encryption = new RijndaelEncryption(); string encryptionKey = ConfigurationManager.AppSettings["EncryptionKey"]; string newPassword = encryption.EncryptText(txtNewPassord.Text, encryptionKey); string oldPassword = encryption.EncryptText(txtOldPassword.Text, encryptionKey); CommonFunction cmSaveData = new CommonFunction(); string updatePassword = "******" + newPassword + "' where(UserID='" + session.UserName + " ' and AccountNumber='" + session.AccountNumber + "' and password='******' )"; cmSaveData.InsertQuery(updatePassword); ClientScript.RegisterStartupScript(this.GetType(), "Alert", "<script type='text/javascript'>alert('Password change successfully');window.location='BrokerInformation.aspx';</script>'"); } catch (Exception ex) { throw ex; } }
protected void Page_Load(object sender, EventArgs e) { AjaxPro.Utility.RegisterTypeForAjax(typeof(Feed)); member = (Member)Session["Member"]; JSNameList = new List <JSName>(); List <FeedItem> Feed = FeedItem.GetFeed(member.MemberID); IEnumerable <FeedItem> SortedFeed = OrderFeed(Feed); foreach (var F in SortedFeed) { FeedHTML += FeedRow(F); } GenerateProfileVisitorLister(member); RSSToken = Server.UrlEncode(RijndaelEncryption.Encrypt(member.Password)); //MemberProfile memberProfile = member.GetMemberProfileByMemberID(); //MemberStatus = memberProfile.TagLine.Replace("'", "'"); MemberStatus = member.MyMemberProfile.TagLine.Replace("'", "'"); if (member.IPLocationID == 0) { MemberLocation = "not set"; } else { IPLocation ipLocation = new IPLocation(member.IPLocationID); MemberLocation = ipLocation.city; } GenerateFriendRequestLister(); GenerateProximityTagsLister(); JsNameString = JSName.RenderJSArray(JSNameList); }
protected void btnCheckPin_Click(object sender, EventArgs e) { try { GetSession session = new GetSession(); if (txtPin.Text == string.Empty) { ClientScript.RegisterStartupScript(this.GetType(), "Alert", "<script type='text/javascript'>alert('Please enter your pin number');window.location='FundWithdeawRequest.aspx';</script>'"); } else { RijndaelEncryption encryption = new RijndaelEncryption(); string encryptionKey = ConfigurationManager.AppSettings["EncryptionKey"]; string pinNumber = encryption.EncryptText(txtPin.Text, encryptionKey); CommonFunction cm = new CommonFunction(); string matchPin = "select Password from ApplicationUser where UserId='" + session.UserName + "' and AccountNumber='" + session.AccountNumber + "' and Password='******' "; DataTable dtmatchPin = cm.GetDatatable(matchPin); if (dtmatchPin.Rows.Count > 0) { //ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "closeModal();", true); ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModal();", true); } else { ClientScript.RegisterStartupScript(this.GetType(), "Alert", "<script type='text/javascript'>alert('Pin number is incorrect. Please enter the correct one');window.location='FundWithdeawRequest.aspx';</script>'"); //lblMessage.ForeColor = System.Drawing.Color.Red; //lblMessage.Text = "Pin number do not match"; } } } catch (Exception ex) { Response.Redirect("../../LoginErrorPage.aspx?ex=" + Server.UrlEncode(ex.Message) + "&st=" + Server.UrlEncode(ex.StackTrace)); } }
/// <summary> /// <para>ローカルストレージに保存されているデータを読み込む</para> /// </summary> public static Dictionary <string, object> Load() { string json = ""; string filePath = StorageFilePath; if (File.Exists(filePath)) { byte[] savedDataJsonBinary = RijndaelEncryption.Decrypt(File.ReadAllBytes(filePath), EncyptPassword); json = Encoding.UTF8.GetString(savedDataJsonBinary); } Dictionary <string, object> parsedJson = new Dictionary <string, object>(); if (!string.IsNullOrEmpty(json)) { parsedJson = JsonConvert.DeserializeObject <Dictionary <string, object> >(json); } if (LogEnabled) { PublishLog(json); } return(parsedJson); }