Exemplo n.º 1
0
        public async Task <ActionResult> ChangePassword(PasswordChange std)
        {
            await Task.Delay(0);

            Response res = new Response();
            var      Id  = EncryptionDecryption.Decrypt(std.id);

            DataTable table = SQLDatabase.GetDataTable("SELECT * FROM users WHERE Id='" + Id + "' AND Password='******'");

            if (table.Rows.Count > 0)
            {
                if (SQLDatabase.ExecNonQuery("update users set Password='******' where Id='" + Id + "'") > 0)
                {
                    res.Status = "Password Update Successfully";
                }
                else
                {
                    res.Status = "Password Updation Failed";
                }
            }
            else
            {
                res.Status = "Old Password is Incorrect";
            }

            return(Ok(res));
        }
        public static void SaveReg(string Title, string keyName, string keyValue) //Save Local value to Reg
        {
            //Title = EncryptionDecryption.Encrypt(Title, "9946");
            //keyName = EncryptionDecryption.Encrypt(keyName, "9946");
            keyValue = EncryptionDecryption.Encrypt(keyValue, MyShopConfigration.EncyKey);

            RegistryKey Test = Registry.CurrentUser.CreateSubKey(Title);

            Test.SetValue(keyName, keyValue);
        }
Exemplo n.º 3
0
 protected void btn_Submit_Click(object sender, EventArgs e)
 {
     try
     {
         if (Session["userID"] != null)
         {
             var pwd = Guid.NewGuid().ToString().Replace("-", "").Substring(0, 8);
             //KeyValuePair<string, string> KeyValuePairPWD = enc.GetSaltKeyAndData(pwd);
             var Password = EncryptionDecryption.Encrypt(txtpassword.Text);
             int z        = helper.ExecuteNonQuery("update [dbo].[user] set Password ='******' where UserID='" + Session["userID"].ToString() + "'");
             if (z > 0)
             {
                 string message = "Password Change Successfully";
                 string url     = "default.aspx";
                 string script  = "window.onload = function(){ alert('";
                 script += message;
                 script += "');";
                 script += "window.location = '";
                 script += url;
                 script += "'; }";
                 ClientScript.RegisterStartupScript(this.GetType(), "Redirect", script, true);
             }
             else
             {
                 string message = "There is error";
                 string url     = "default.aspx";
                 string script  = "window.onload = function(){ alert('";
                 script += message;
                 script += "');";
                 script += "window.location = '";
                 script += url;
                 script += "'; }";
                 ClientScript.RegisterStartupScript(this.GetType(), "Redirect", script, true);
             }
         }
         else
         {
             Response.Redirect("User_Login.aspx");
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
    protected void btnfogot_Click(object sender, EventArgs e)
    {
        try
        {
            DataSet ds = new DataSet();
            ds = config.GetEmailAlreadyExist(txtemail.Text);
            if (ds.Tables.Count > 0)
            {
                if (ds.Tables[0].Rows.Count > 0)
                {
                    username = ds.Tables[0].Rows[0]["VACode"].ToString();
                    Email    = ds.Tables[0].Rows[0]["EmailAddress"].ToString();
                    password = ds.Tables[0].Rows[0]["Password"].ToString();

                    var pwd = Guid.NewGuid().ToString().Replace("-", "").Substring(0, 6);
                    KeyValuePair <string, string> KeyValuePairPWD = enc.GetSaltKeyAndData(pwd);
                    var Password = EncryptionDecryption.Encrypt(pwd);
                    // var Password1 = pwd.Replace("-", string.Empty).Substring(0, 10);
                    //var pwd = Guid.NewGuid().ToString().Replace("-", "").Substring(0, 8);
                    var Password1 = EncryptionDecryption.Encrypt(password);
                    config.ForgotPassword(pwd, username, Email);
                    int x = helper.ExecuteNonQuery("update [DBO].[USER] set password='******' where Userid='" + ds.Tables[0].Rows[0]["UserID"].ToString() + "'");
                    if (x > 0)
                    {
                        lblmessage.Text = "Password send you on your Email Address";
                    }
                    else
                    {
                    }
                }
                else
                {
                    lblmessage.Text = "Email Address Not Registered";
                }
            }
            else
            {
                lblmessage.Text = "Email Address Not Registered";
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
Exemplo n.º 5
0
        public async Task <ActionResult> Login(Students std)
        {
            await Task.Delay(0);

            Response  res   = new Response();
            DataTable table = SQLDatabase.GetDataTable("SELECT * FROM users where Username='******' and Password='******' and Status='1'");

            if (table.Rows.Count > 0)
            {
                res.Status = "Successfully Login";
                string Id = table.Rows[0]["Id"].ToString();

                res.str1 = EncryptionDecryption.Encrypt(Id);
            }
            else
            {
                res.Status = "Invalid UserName/Password";
            }
            return(Ok(res));
        }
Exemplo n.º 6
0
        public ActionResult InsertUpdate(UsersVM usersViewModel)
        {
            //LogAction(this, "Information", $"InsertUpdate() Accessed");
            long id = 0;

            //var authCookie = FormAutheticationHelper.GetUserDataFromCookie();
            //if (authCookie == null)
            //{
            //    //Logging.log(LogType.INFO, "UnauthorizedAccessException", authCookie);
            //    return RedirectToAction("login", "account");
            //}

            try
            {
                var countOfUsers = _IUserService.GetAll()?.Count(a => a.ID != usersViewModel.ID && a.UserName.Trim().Equals(usersViewModel.UserName.Trim(), StringComparison.InvariantCultureIgnoreCase)) ?? 0;
                if (countOfUsers > 0)
                {
                    return(Json(new { code = -1, Message = $"Same User Name is already Exist {usersViewModel.UserName}" }, JsonRequestBehavior.AllowGet));
                }
                if (usersViewModel.ID > 0)
                {
                    usersViewModel.ModifiedBy = 1;//.ToInt32(authCookie?.UserId);
                }
                else
                {
                    usersViewModel.CreatedBy = 1;                                                  // Convert.ToInt32(authCookie?.UserId);
                    usersViewModel.Password  = EncryptionDecryption.Encrypt("Password@123", true); //Create default password for intial
                }
                id = _IUserService.InsertUpdate(usersViewModel);
            }
            catch (Exception ex)
            {
                return(Json(new { code = -1, Message = "Something went wrong.Try again!!!" }, JsonRequestBehavior.AllowGet));
            }
            return(Json(new { code = id, Message = "Changes has been saved Successfully" }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 7
0
    protected void btnupdate_Click(object sender, EventArgs e)
    {
        try
        {
            if (Request.QueryString["id"] != null)
            {
                ContentPlaceHolder1_pagename.InnerHtml = "Edit Profile";
                DataHelper helper = new DataHelper();
                string     str    = null;
                foreach (ListItem lst in chkgender.Items)
                {
                    if (lst.Selected)
                    {
                        str = lst.Text;
                    }
                }


                //KeyValuePair<string, string> KeyValuePairPWD = enc.GetSaltKeyAndData(pwd);
                //var Password = EncryptionDecryption.Encrypt(txtpassword.Text);
                int x = helper.ExecuteNonQuery("update [dbo].[user] set FirstName='" + txtfirstname.Text + "',MiddleName='" + txtmiddlename.Text + "',LastName='" + txtlastname.Text + "',EmailAddress='" + txtemail.Text + "', Gender='" + str + "', MobileNo='" + txtphone.Text + "',StateID='" + ddlstate.SelectedItem.Value + "',District='" + txtdistrict.Text + "',Taluka='" + txttaluka.Text + "',Village='" + txtvillage.Text + "',PinCode='" + txtpincode.Text + "',AadharFileName='" + hdpan.Value + "',PanDocumenFileName='" + hd1.Value + "',ReferenceBy='" + txtreference.Text + "' where UserId=" + Request.QueryString["Id"].ToString());
                if (x > 0)
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Your profile is updated')", true);
                }
            }
            else
            {
                System.Data.DataSet dt = new System.Data.DataSet();
                dt = config.GetEmailAlreadyExist(txtemail.Text);
                if (dt.Tables[0].Rows.Count > 0)
                {
                    if (dt.Tables[0].Rows.Count > 0)
                    {
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('EmailAddress already Exist.')", true);
                    }
                }
                else
                {
                    string str = null;
                    foreach (ListItem lst in chkgender.Items)
                    {
                        if (lst.Selected)
                        {
                            str = lst.Text;
                        }
                    }
                    var pwd = Guid.NewGuid().ToString().Replace("-", "").Substring(0, 8);
                    //KeyValuePair<string, string> KeyValuePairPWD = enc.GetSaltKeyAndData(pwd);
                    var    Password   = EncryptionDecryption.Encrypt(pwd);
                    string contettype = adharfile.PostedFile.ContentType;
                    int    x          = helper.ExecuteNonQuery("insert into [dbo].[user] (FirstName,LastName,EmailAddress,Gender,MobileNo,User_status,Password,AadharFileName,PanDocumenFileName,DocumentContentType) values ('" + txtfirstname.Text + "','" + txtlastname.Text + "','" + txtemail.Text + "','" + str + "','" + txtphone.Text + "','" + 1 + "','" + Password + "','" + adharfile.PostedFile.FileName + "','" + panfilename.PostedFile.FileName + "','" + contettype + "')");
                    if (x > 0)
                    {
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Your Registration Completed')", true);
                        Response.Redirect("User_Login.aspx");
                    }
                }
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
Exemplo n.º 8
0
 public void EncryptTest()
 {
     Console.WriteLine(EncryptionDecryption.Encrypt("PY-123456"));
     Console.WriteLine(EncryptionDecryption.Decrypt("Jb0JxAiP41QAKVPMlagmtQ=="));
 }
        static void Main(string[] args)
        {
            //Sample of encryption
            /*
            EncryptionDecryption _entryption = new EncryptionDecryption();
            string _s1 = "12345";
            string _s2 = string.Empty; 
            string _key = string.Empty;
            _key = _entryption.DecryptPermanent("DsGSLNYJlj0Xhl0BnMFKNxGN5nHc79O65nFj2wA5Ex4uB2pVEnlHaA==", true);
            _s2 = _entryption.Encrypt(_s1, _key, true);
             */


            //Sample of decryption
            /*
            EncryptionDecryption _entryption = new EncryptionDecryption();
            string _s1 = "12345";
            string _s2 = string.Empty; 
            string _key = string.Empty;
            _key = _entryption.DecryptPermanent("DsGSLNYJlj0Xhl0BnMFKNxGN5nHc79O65nFj2wA5Ex4uB2pVEnlHaA==", true);
            _s2 = _entryption.Decrypt(_s1, _key, true);
             */

            EncryptionDecryption _entrypt = new EncryptionDecryption(); 
            //DsGSLNYJlj0Xhl0BnMFKNxGN5nHc79O65nFj2wA5Ex4uB2pVEnlHaA==
            //_entrypt.
            string _userid = "waldengroup\\administrator~0Griswold1";
            string _key = _entrypt.DecryptPermanent("DsGSLNYJlj0Xhl0BnMFKNxGN5nHc79O65nFj2wA5Ex4uB2pVEnlHaA==", true);
            string _id = _entrypt.Encrypt(_userid,_key,true);

            _id = _id.Replace("+", "~");
            //ProviderList
        //http://localhost:56630/servicestack/json/syncreply/ProviderList
            //http://localhost:56630/servicestack/json/syncreply/patientlist
            //String uri = "http://localhost:64345/servicestack/json/syncreply/checkuserid?id=" + _id;
            //String uri = "http://walden.myftp.org/barkorders/servicestack/json/syncreply/checkuserid?id=" + _id;
            //String uri = "http://walden.myftp.org/barkorders/servicestack/json/syncreply/getpatientlist?id=27";
            //string uri = "http://localhost:64350/servicestack/json/syncreply/getadtdata";
            //String uri = "http://localhost:56630/servicestack/json/syncreply/dailyexerciseroutine?dayofweek=Tuesday";

            //String uri = "http://localhost:56630/servicestack/json/syncreply/clientexerciseresults?results=Tuesday";
            String uri = "http://localhost:56630/servicestack/json/syncreply/retrieveappointment?id=8606803763";

            

            //String uri = "http://localhost:56630/servicestack/json/syncreply/clientexercises?clientid=1";
            //getpatientlist
            //String uri = "http://localhost:64345/servicestack/json/syncreply/removefromnopatientlist?id=27";
            //String uri = "http://localhost:64345/servicestack/json/syncreply/UpdateNoPatientRecord?id=27";
            //String uri = "http://100.0.3.128/InterfaceUtility/servicestack/json/syncreply/UpdateNoPatientRecord?id=27";

            //tring uri = "http://100.0.3.128/InterfaceUtility/servicestack/json/syncreply/getmiddlesexlog";
            ///getoutstandingpatients/{_providerID}"
                Stream stream;
                StreamReader reader;
                String response = null;
                WebClient webClient = new WebClient();
            //System.Collections.Specialized
            System.Collections.Specialized.NameValueCollection reqparm = new System.Collections.Specialized.NameValueCollection();

           // string example = "1~2013-02-04~Saturday February 2, 2013~2~1~1^1~2013-02-04~Saturday February 2, 2013~4~2~1^1~2013-02-04~Saturday February 2, 2013~5~3~1^1~2013-02-04~Saturday February 2, 2013~2~4~1^1~2013-02-04~Saturday February 2, 2013~2~5~1^1~2013-02-04~Saturday February 2, 2013~2~6~1^1~2013-02-04~Saturday February 2, 2013~4~7~1^1~2013-02-04~Saturday February 2, 2013~4~8~1^1~2013-02-04~Saturday February 2, 2013~4~9~1^1~2013-02-04~Saturday February 2, 2013~5~10~1^1~2013-02-04~Saturday February 2, 2013~5~11~1^";
            
           // reqparm.Add("Results",example);
    //Dim reqparm As New Specialized.NameValueCollection
    //reqparm.Add("param1", "somevalue")
    //reqparm.Add("param2", "othervalue")
    //Dim responsebytes = client.UploadValues(someurl, "POST", reqparm)
    //Dim responsebody = (New Text.UTF8Encoding).GetString(responsebytes)



                //var xx = webClient.UploadValues(uri, "POST",reqparm);
                //Dim responsebytes = client.UploadValues(someurl, "POST", reqparm)
            //webClient.
                // open and read from the supplied URI
                stream = webClient.OpenRead(uri);

                reader = new StreamReader(stream);
                response = reader.ReadToEnd();
            ///servicestack/[xml|json|html|jsv|csv]/[syncreply|asynconeway]/[servicename]

            //String request = reader.ReadToEnd();
        }
Exemplo n.º 10
0
        /// <summary>
        /// Sets constants response from resource file and stores the refresh token in the cookie.
        /// </summary>
        /// <param name="request">Request Object</param>
        /// <param name="response">Response Object</param>
        /// <param name="queryStringCookieName">Cookie Name</param>
        /// <param name="redirectURL">Redirect URL</param>
        /// <param name="constantFileObject">Object to fetch constants from resource file</param>
        /// <param name="constantFile">Name of the app specific resource file</param>
        internal static void SetConstantsResponse(HttpRequest request, HttpResponse response, string redirectURL, string constantFileObject, string constantFile)
        {
            string refreshToken = string.Empty;

            try
            {
                bool environment = Convert.ToBoolean(UIConstantStrings.IsDeployedOnAzure, CultureInfo.InvariantCulture);
                if (environment)
                {
                    //// Check if page loaded due to Token Request failure issue (Query string will contain IsInvalidToken parameter)
                    if (request.Url.Query.ToString().ToUpperInvariant().Contains(UIConstantStrings.TokenRequestFailedQueryString.ToUpperInvariant()))
                    {
                        refreshToken = SetMatterCenterCookie(request, response, redirectURL, constantFileObject, constantFile, true);
                    }
                    else
                    {
                        refreshToken = (null != request.Cookies[UIConstantStrings.refreshToken]) ? request.Cookies[UIConstantStrings.refreshToken].Value : string.Empty;
                    }
                    if (string.IsNullOrWhiteSpace(refreshToken))
                    {
                        refreshToken = SetMatterCenterCookie(request, response, redirectURL, constantFileObject, constantFile, false);
                    }
                    else
                    {
                        string DecryptedrefreshToken = string.Empty;
                        string key = ConfigurationManager.AppSettings["Encryption_Key"];
                        if (!string.IsNullOrWhiteSpace(key))
                        {
                            DecryptedrefreshToken = EncryptionDecryption.Decrypt(refreshToken, key);
                            if (!string.IsNullOrWhiteSpace(DecryptedrefreshToken))
                            {
                                SetResponse(request, response, constantFileObject, constantFile, refreshToken);
                                response.Write(UIUtility.SetSharePointResponse(refreshToken));
                            }
                            else
                            {
                                key = ConfigurationManager.AppSettings["Old_Encryption_Key"];
                                if (!string.IsNullOrWhiteSpace(key))
                                {
                                    DecryptedrefreshToken = EncryptionDecryption.Decrypt(refreshToken, key);
                                    if (!string.IsNullOrWhiteSpace(DecryptedrefreshToken))
                                    {
                                        request.Cookies[UIConstantStrings.refreshToken].Value = refreshToken = EncryptionDecryption.Encrypt(DecryptedrefreshToken);
                                        SetResponse(request, response, constantFileObject, constantFile, refreshToken);
                                        response.Write(UIUtility.SetSharePointResponse(refreshToken));
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    SetResponse(request, response, constantFileObject, constantFile, refreshToken);
                    response.Write(UIUtility.SetSharePointResponse(refreshToken));
                }
            }
            catch (Exception exception)
            {
                string result = Logger.LogError(exception, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, UIConstantStrings.LogTableName);
                response.Write(GenericFunctions.SetErrorResponse(ConstantStrings.TRUE, result));
            }
        }
Exemplo n.º 11
0
        public string encryptAccessionn(string filter)
        {
            string encstring = EncryptionDecryption.Encrypt(filter, "0123456abcdf");

            return(encstring);
        }
Exemplo n.º 12
0
        public async Task <ActionResult> InsertData(Students std)
        {
            await Task.Delay(0);

            Response res = new Response();

            DataTable table = SQLDatabase.GetDataTable("select* from users where Email='" + std.Email + "'");

            if (table.Rows.Count > 0)
            {
                res.Status = "Email Matched";
            }
            else
            {
                DataTable table1 = SQLDatabase.GetDataTable("select* from users where Username='******'");

                if (table1.Rows.Count > 0)
                {
                    res.Status = "Username Matched";
                }
                else
                {
                    var UserImage = "/assets/img/faces/card-profile1-square.jpg";

                    var Insertedbyid = std.Insertedbyid;

                    if (Insertedbyid == "" || Insertedbyid == null)
                    {
                        Insertedbyid = std.Insertedbyid;
                    }
                    else
                    {
                        Insertedbyid = EncryptionDecryption.Decrypt(std.Insertedbyid);
                    }

                    if (SQLDatabase.ExecNonQuery("insert into users (Name,FatherName,PhoneNumber,Email,Gender,Address,Username,Password,Image,Status,InsertedDateTime,Insertedbyid) values ('" + std.Name + "','" + std.FatherName + "','" + std.PhoneNumber + "','" + std.Email + "','" + std.Gender + "','" + std.Address + "','" + std.Username + "','" + EncryptionDecryption.Encrypt(std.Password) + "','" + UserImage + "',1,'" + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + "','" + Insertedbyid + "')") > 0)
                    {
                        res.Status = "Inserted Successfully";
                    }
                    else
                    {
                        res.Status = "Insertion failed";
                    }
                }
            }
            return(Ok(res));
        }