Ejemplo n.º 1
0
        private void btnFileSave1_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(tbPath.Text))
            {
                WarningNotice.InputString();
                return;
            }
            if (!File.Exists(tbPath.Text))
            {
                WarningNotice.NotFound();
                return;
            }
            if (tbIV.Text.Length != 8)
            {
                WarningNotice.IVLength(8);
                return;
            }
            if (DialogResult.OK == sfdFile.ShowDialog())
            {
                FileInfo file   = new FileInfo(tbPath.Text);
                FileInfo result = new FileInfo(sfdFile.FileName);
                fileSize = file.Length;

                Task.Factory.StartNew(() =>
                {
                    ControlEnable(this.Controls, false);
                    TripleDESEncryption.Encrypt(file, result, tbPassword.Text, tbIV.Text);
                    this.Invoke(new Action(() => WarningNotice.Save()));
                    ControlEnable(this.Controls, true);
                });
            }
            sfdFile.FileName = "";
        }
Ejemplo n.º 2
0
 private void btnEncrypt_Click(object sender, EventArgs e)
 {
     if (tbIV.Text.Length != 8)
     {
         WarningNotice.IVLength(8);
         return;
     }
     tbToText.Text = TripleDESEncryption.Encrypt(tbFromText.Text, tbPassword.Text, tbIV.Text);
 }
        public string GenerateRedirectUrlToken(string username, string password, DateTime dt)
        {
            string encrypted_username  = string.Empty;
            string encrypted_password  = string.Empty;
            string encrypted_timestamp = string.Empty;

            using (var encrypter = new TripleDESEncryption(appConfig.TripleDESEncryptionKey))
            {
                encrypted_username  = System.Web.HttpUtility.UrlEncode(encrypter.Encrypt(username));
                encrypted_password  = System.Web.HttpUtility.UrlEncode(encrypter.Encrypt(password));
                encrypted_timestamp = System.Web.HttpUtility.UrlEncode(encrypter.Encrypt(dt.ToString()));
            }
            var    linkurl    = "{0}/Account/SSORedirectUrl?username={1}&password={2}&timestamp={3}";
            string domainName = System.Web.HttpContext.Current.Request.Url.Host;

            return(string.Format(linkurl, domainName, encrypted_username, encrypted_password, encrypted_timestamp));
            //return token;
        }
 public string GeneratePasswordResetToken(string token)
 {
     using (var encrypter = new TripleDESEncryption(appConfig.TripleDESEncryptionKey))
     {
         token = System.Web.HttpUtility.UrlEncode(encrypter.Encrypt(token));
     }
     //var linkurl = "{0}/Account/ResetPassword?token={1}";
     //string domainName = System.Web.HttpContext.Current.Request.Url.Host;
     //return string.Format(linkurl, domainName, token);
     return(token);
 }
        public string StringTripleDESEncrypt(string input)
        {
            var encrypted = string.Empty;

            using (var encrypter = new TripleDESEncryption(appConfig.TripleDESEncryptionKey))
            {
                try
                {
                    encrypted = encrypter.Encrypt(input);
                }
                catch (FormatException fe)
                {
                    encrypted = string.Empty;
                }
                catch (Exception e)
                {
                    encrypted = string.Empty;
                }
            }
            return(encrypted);
        }