public Object[] GetRegisterUsers(string FromDate, string ToDate) { DataSet ds = new DataSet(); string store = "Select * From Personal where CreateDate between @FromDate and @ToDate Order By CreateDate"; List <IDataParameter> parms = new List <IDataParameter>(); parms.Add(new SqlParameter("@FromDate", FromDate + " 00:00:00")); parms.Add(new SqlParameter("@ToDate", ToDate + " 23:59:59")); ds = Connection.GetDataSet(store, parms, CommandType.Text); //ds = Connection.GetDataSet(store); DataTable dt = ds.Tables[0]; var query = (from temp in dt.AsEnumerable() select new { //ID = temp.Field<Guid>("ID"), Data = Decryption.Decrypt(AppSettings.FormKey, temp.Field <String>("Data")), CreateDate = temp.Field <DateTime>("CreateDate").ToString("dd/MM/yyyy HH:mm:ss") }); return(query.ToArray()); }
public void TestDecrypt() { byte[] bytesDecrypted = Decryption.Decrypt(this.BytesToDecrypt, 13u, this.Key, this.IV); string decryptedString = Encoding.ASCII.GetString(bytesDecrypted); Assert.AreEqual(decryptedString, this.Decrypted); }
private void decryptBtn_Click(object sender, EventArgs e) { if (decryptBox.ForeColor == SystemColors.InactiveCaption) { MessageBox.Show("No input!"); } else { try { string message = Decryption.GetMessage(Decryption.Decrypt(Decryption.DisplayArrayFromString(decryptBox.Text))); if (message != string.Empty) { outputBox.Text = message; } else { outputBox.Text = "Invalid Data"; } } catch (Exception) { outputBox.Text = "Data appears to be malformed or tampered."; } } }
public ActionResult Login(UserLoginModel model) { if (!ModelState.IsValid) { return(View(model)); } using (var db = new MainDbContext()) { var emailCheck = db.Users.FirstOrDefault(u => u.Email == model.Email); var getPswd = db.Users.Where(u => u.Email == model.Email).Select(u => u.Password); var listPswd = getPswd.ToList(); var decryptPswd = (!listPswd.Any()) ? null : Decryption.Decrypt(getPswd.ToList()[0]); if (model.Email != null && model.Password == decryptPswd) { var getMail = db.Users.Where(u => u.Email == model.Email).Select(u => u.Email); var getName = db.Users.Where(u => u.Email == model.Email).Select(u => u.Username); var getCountry = db.Users.Where(u => u.Email == model.Email).Select(u => u.Country); var identity = new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, getName.ToList()[0]), new Claim(ClaimTypes.Email, getMail.ToList()[0]), new Claim(ClaimTypes.Country, getCountry.ToList()[0]) }, "ApplicationCookie"); Request.GetOwinContext().Authentication.SignIn(identity); return(RedirectToAction("Index", "Home")); } } ModelState.AddModelError("", "Invalid Email or Password"); return(View(model)); }
public Command GetMessage() { string answer = sReader.ReadLine(); answer = Decryption.Decrypt(answer, MainInfo.key, MainInfo.iv); return(JsonConvert.DeserializeObject <Command>(answer)); }
static void Main(string[] args) { //load configuration data RemotingConfiguration.Configure(@"TestConsole.exe.config"); //(1). Test the data encryption/decryption using SAF.Cryptography // (a) test the symmatric cryptography string original = "This is a test!"; string encrypted = Encryption.Encrypt(original, "Profile1"); Console.WriteLine("Encrypted data is : " + encrypted); string decrypted = Decryption.Decrypt(encrypted, "Profile1"); Console.WriteLine("Decrypted data is : " + decrypted); // (b) test the asymmatric cryptography byte[] key; byte[] iv; byte[] signature; encrypted = Encryption.Encrypt(original, "Profile2", out key, out iv, out signature); Console.WriteLine("Encrypted data is : " + encrypted); decrypted = Decryption.Decrypt(encrypted, "Profile3", key, iv, signature); Console.WriteLine("Decrypted data is : " + decrypted); //(2). Test the secure remoting call via CryptoRemotingClient(Server)Sink. //Please refer to configuration file for profile information used for remoting calls. //creating the remoting object SampleBusiness sb = new SampleBusiness(); //invoking the secure remoting call. Console.WriteLine(sb.SayHelloWorld()); Console.WriteLine("press enter to exit"); Console.ReadLine(); }
private async void Decrypt() { #region Validation string stegoContainerFilePath = DropStegoContainerFileVM.FilePath; if (!File.Exists(stegoContainerFilePath)) { DropStegoContainerFileVM.IsValid = false; StatusBarUCVM.UpdateState(text: "Stegocontainer file does not exist", state: AppState.Error); return; } if (!_decryption.IsStegocontainerExtensionAllowed(stegoContainerFilePath)) { DropStegoContainerFileVM.IsValid = false; StatusBarUCVM.UpdateState(text: "Wrong stegocontainer file extension", state: AppState.Error); return; } string outputPath = OutputPathVM.Path; if (!Directory.Exists(outputPath)) { OutputPathVM.IsValid = false; StatusBarUCVM.UpdateState(text: "Output directory does not exist", state: AppState.Error); return; } var password = _decryption.CreatePassword(PasswordVM.Password); if (!password.IsValid()) { PasswordVM.IsValid = false; StatusBarUCVM.UpdateState(text: password.ValidationDescription, state: AppState.Error); return; } #endregion StatusBarUCVM.UpdateState(state: AppState.Working); try { string filePath = await _decryption.Decrypt(stegoContainerFilePath, password, outputPath); StatusBarUCVM.UpdateState(text: "Decryption has been successfully done. Secret file is located: ", localFilePath: filePath, state: AppState.Neutral); DropStegoContainerFileVM.IsValid = true; PasswordVM.IsValid = true; OutputPathVM.IsValid = true; } catch (Exception e) when(e is InvalidOperationException || e is ArgumentException) { StatusBarUCVM.UpdateState(text: e.Message, state: AppState.Error); } catch (Exception e) { StatusBarUCVM.UpdateState(text: "Something went wrong. Try again", state: AppState.Error); } }
public ActionResult EditUser(string userId) { var usId = Decryption.Decrypt(userId, true); var userDto = _iUserHelper.GetUserByUserId(Convert.ToInt32(usId)); userDto.UserTypesDtos = _iUserHelper.GetUserTypes(); return(View("EditUser", userDto)); }
public void Rc2Test() { const string source = "eq0EPanGM6JSrfH5fvtzCsxUl9BxNpm78CXyFgks4J22wxzU8/Y3BA=="; const string str = "测试数据加密,中英汇合acdefg"; var result = Decryption.Decrypt(source, "RC2"); Assert.AreEqual(str, result); }
public void AesTest() { const string source = "2FYmJ9CZKwzGtYMNwkFD5yUbw2qh0ScoNJhSnCrULryaUoTGE+AB26mCt/6mAqE3"; const string str = "测试数据加密,123中英汇合acdefg"; var result = Decryption.Decrypt(source, "Aes"); Assert.AreEqual(str, result); }
public void DesTest() { const string source = "OGUYlWsRx5oLjgIR+OT0K1BG2V5wf3Rbg1ddANmhLEWDeQfUojIqig=="; const string str = "测试数据加密,中英汇合acdefg"; var result = Decryption.Decrypt(source, "DES"); Assert.AreEqual(str, result); }
public void RijndaelTest() { const string source = "Qfkfe201C/pmJTz/gyv3vGyaeYOnfKu1f1URRouCyWlzJjvpEGCeyX1JK2bln1NY"; const string str = "测试数据加密,中英汇合acdefg"; var result = Decryption.Decrypt(source, "Rijndael"); Assert.AreEqual(str, result); }
public void TripleDesTest() { const string source = "qCie0wIiEMo11VpoRMmrAd8zzqG0nyYII57V9sq4p1BEd1iELKAXSQ=="; const string str = "测试数据加密,中英汇合acdefg"; var result = Decryption.Decrypt(source, "TripleDES"); Assert.AreEqual(str, result); }
public void HandleClient(object obj) { // retrieve client from parameter passed to thread TcpClient client = (TcpClient)obj; // sets two streams StreamWriter sWriter = new StreamWriter(client.GetStream(), Encoding.UTF8); StreamReader sReader = new StreamReader(client.GetStream(), Encoding.UTF8); Boolean bClientConnected = true; String sData = null; String respond = null; object lock_ = new object(); while (bClientConnected) { try { // reads from stream if (!client.Connected) { throw new Exception("Connection Close!"); } sData = sReader.ReadLine(); if (sData == null) { throw new Exception("Connection Close!"); } sData = Decryption.Decrypt(sData, Program.key, Program.iv); Command command = JsonConvert.DeserializeObject <Command>(sData); respond = Parser.Parse(command); Parser.RememberPlayer(command, respond, sWriter, lock_); if (respond == null) { // exit client bClientConnected = false; throw new Exception("Connection Close!"); } // to write something back. if (!respond.Equals("null")) { SendMessage(respond, sWriter, lock_); } } catch (Exception e) { sWriter.Close(); client.Close(); if (!e.Message.Equals("Connection Close!")) { Log.ErrorLog("Connection Error: " + e.Message); } Log.InfoLog("Client disconect..."); Console.WriteLine("Client disconect..."); return; } } }
public void EncryptDecryptTest() { string key = Program.key; string iv = Program.iv; string data = "Hey Im Willi!"; string encrypt = Encryption.Encrypt(data, key, iv); string decrypt = Decryption.Decrypt(encrypt, key, iv); Assert.AreEqual(data, decrypt); }
public ActionResult Index(string id) { var custId = Convert.ToInt32(Decryption.Decrypt(id, true)); var cust = _iCustomerHelper.GetCustomerById(custId); return(View(new OTPDto { CustomerId = cust.CustomerId, CustomerName = cust.CustomerName, })); }
private static string DAttack(BitArray plain, BitArray cipher, string key) { KeyGeneration keygen = new KeyGeneration(key); var decrypted = Decryption.Decrypt(cipher, keygen.K1, keygen.K2); if (Tools.BitArrayEquals(decrypted, plain)) { return(key); } return(null); }
public void TestConsistency() { byte[] bytesDecrypted1 = Decryption.Decrypt(this.BytesToDecrypt, 13u, this.Key, this.IV); string decryptedString1 = Encoding.ASCII.GetString(bytesDecrypted1); byte[] bytesCompressed = Decryption.DecryptNoDecompress(this.BytesToDecrypt, 21u, this.Key, this.IV); byte[] bytesDecrypted2 = Decryption.Decompress(bytesCompressed, 13); string decryptedString2 = Encoding.ASCII.GetString(bytesDecrypted2); Assert.AreEqual(decryptedString1, decryptedString2); }
private void btnDecypher_Click(object sender, EventArgs e) { var de = new Decryption(); if (txtCypher.Text == "" || txtCipherKey.Text == "") { return; } txtPlain.Text = de.Decrypt(txtCypher.Text, txtCipherKey.Text); }
public ActionResult GetUploadDocumentForCustomer(string cuId) { var custId = Convert.ToInt32(Decryption.Decrypt(cuId, true)); var claim = _iCustomerHelper.GetClaimByCustId(custId); ViewBag.ClaimId = claim.ClaimId; ViewBag.LossTypeId = claim.LossTypeId; ViewBag.CustomerId = custId; var documentList = _iClaimHelper.GetUploadDocumentMaster(claim.LossTypeId); return(View("UploadDocumentCustomer", documentList)); }
public void EncryptDecryptNotSameTest() { string key = Program.key; string iv = Program.iv; string data1 = "Hey Im Willi!"; string data2 = "Hey Im Eliran!"; string encrypt1 = Encryption.Encrypt(data1, key, iv); string encrypt2 = Encryption.Encrypt(data2, key, iv); string decrypt1 = Decryption.Decrypt(encrypt1, key, iv); string decrypt2 = Decryption.Decrypt(encrypt2, key, iv); Assert.AreNotEqual(data1, decrypt2); Assert.AreNotEqual(data2, decrypt1); }
private static EncryptionConfigEntity LoadConfigEntity() { string[] keyInfo = null; if (!EnableAutoGenKey) { keyInfo = KeyInfo; } else { var filePath = string.Format("{0}{1}{2}", AppContext.BaseDirectory.TrimEnd(Path.PathSeparator), Path.PathSeparator, "keyfile.txt"); var isFind = false; try { if (File.Exists(filePath)) { var str = File.ReadAllText(filePath, Encoding.UTF8); keyInfo = Decryption.Decrypt(str, EncryptionConfigEntity.CreateEncryptionConfigEntity(KeyInfo[0] , true, new Dictionary <string, string> { { "Key", KeyInfo[2] }, { "IV", KeyInfo[1] } })) .DeserializeObject <string[]>(); if (keyInfo.Length == 3) //如果key文件格式不正确,自动生成新key { isFind = true; } } } catch (Exception) // { isFind = false; //Log.LogFactory.GetDefaultLogger().Write("加载文件出错,自动生成新文件,错误信息:" + exception); } if (isFind == false) //加载key失败使用默认key { keyInfo = GenKeyContent(); var str = Encryption.Encrypt(keyInfo.SerializeObject(), EncryptionConfigEntity.CreateEncryptionConfigEntity(KeyInfo[0], true, new Dictionary <string, string> { { "Key", KeyInfo[2] }, { "IV", KeyInfo[1] } })); File.WriteAllText(filePath, str, Encoding.UTF8); } } return(EncryptionConfigEntity.CreateEncryptionConfigEntity(keyInfo[0], true, new Dictionary <string, string> { { "Key", keyInfo[2] }, { "IV", keyInfo[1] } })); }
// // GET: /Customer/ public ActionResult RegenrateOtp(string id) { var custId = Convert.ToInt32(Decryption.Decrypt(id, true)); var otpNumber = _iClaimHelper.RegenrateOtp(custId); SendMailCustomer(custId, otpNumber); ViewBag.Incorrectlogin = "******"; var cust = _iCustomerHelper.GetCustomerById(custId); return(View("Index", new OTPDto { CustomerId = cust.CustomerId, CustomerName = cust.CustomerName, })); }
//[TestMethod] public void RsaTest() { //KhGI3xDKboMU6ddLemIXt3Y5WnCuDXedXUzr5ZAzDY5/rSrGQNG/qQ== const string str = "SLuw1TrMgrHgCxP6SdARgqDx46UnSgraT92CAdeAM+fnkUd0WAx2ZA=="; const string ivstr = "PLrPmAfV1AlGjd2WBEaFHn3CtJNi51a0we2hz2XNoWLxUDxURiebsaLYuOey1/rxQo6wM+KDpCCPhCKRkRTYoj9CRT321wmK7clVnR0RgAwtlI5ZoKfx/gaSZRQHzHCVYi9SIjMWC5m51zG5huR9VEQJwQ1wUkGqA3WtLzr30ahEJJaA15jVFNTtPI8WlkZpv5Lk5jsNsNXRkR0mZXSNpT4WNalOHpgnKPFmEImGtlnTTrgz8i0/cI9MgyaAK6+s59E6ZDoXCW/p+e/wAFpbQnRy4VjHvT8sQKTm2oUdfhqdznpw9Mw2o2VavyKJAY4u0e1WaObdN07i4nzWQwNloQ=="; const string keystr = "ULsMvA1DVz5Tym6tlHB/DqXzordptblEpvtcZ0Z5jmKlUquqydIHlnYd87ZgKQvGVs6z8N2KTA1WA38SX7WUmKZPazySZyDvQ1V62rrlDp3nWw95f4GMIqEl4godPeeXB7HZ4/qAz9s8X1xPLpQRvPA11bsuXIhcaS9+jl1Tsi8z+voemBmtR4QV3ex34Sc62EHdZoVKvKQ3WEDS76+BgfcE98u2H7/HIbJr+LUrL9Cu82gokasjmWZsfTDFL3DU+ZJWhffL5puqk2it2wzrmLU6QgkOW3EOGLoS6p81DV24TfCTT21LmcZ+aVn2/B5OIWw3laIFCs+ZugYskYJlEg=="; const string signdatastr = "fV31Zq3K4ok5dpX8631v/bI59np6nxDd224oihKKNz10FT2aCiXbKDeOEAOD7RgiKs/dIJ9AXJulVXpPk7FacxWyglqn6PHa8sjMWt/qGBzF5R8RqsoJuPQW5gHTSgtIsPXsf+S3lMEFme9+/JvoWHUXfQ14VrAB7DMLjrg8kesVnun7LCU6TutFMhle8n942x7+TgyBFqzsWwAe3L8GPvsV+Lvi9jIc35BgtxzG1b9/3QMBJ3EgeD1oRDDaf0GKfBkq3JYitEKJIWTaAWHfku1zPeqTWN7wDqBrqrLkq2qbeO0gE96Feo5jZJhSh2rM41Kmpqd7ALSrgnlHJgJkMQ=="; var key = Convert.FromBase64String(keystr); var iv = Convert.FromBase64String(ivstr); var signdata = Convert.FromBase64String(signdatastr); var result1 = Decryption.Decrypt(str, "RSADecry", key, iv, signdata); Assert.AreEqual("测试数据加密,中英汇合acdefg", result1); }
private void buttonDecrypt_Click(object sender, EventArgs e) { try { string result = string.Empty; string text = textBoxText.Text; string key = textBoxKey.Text; if (!string.IsNullOrEmpty(textBoxText.Text) && !string.IsNullOrEmpty(textBoxKey.Text)) { result = Decryption.Decrypt(text, key); } textBoxresult.Text = result; } catch { MessageBox.Show("Error occurred", "Encryption Decryption Tool", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public static SettingData getSettingDetails() { SettingData settingData = new SettingData(); RegistryKey key = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\EventViewerVisualizer"); if (key != null) { settingData.SystemName = Decryption.Decrypt(key.GetValue("SystemName").ToString(), "EventViewerVisualizer"); settingData.TXNPath = Decryption.Decrypt(key.GetValue("TXNPath").ToString(), "EventViewerVisualizer"); settingData.UserFilter = key.GetValue("TellerFilter").ToString(); settingData.TXNFilter = key.GetValue("TXNFilter").ToString(); settingData.CustomFilter = key.GetValue("CustomFilter").ToString(); key.Close(); } else { settingData = null; } return(settingData); }
// Use this for initialization void Start() { try { var url = Application.absoluteURL; //var url = "https://ydeagames.github.io/FlipTheCat/#/B4B8tTIWa7TA78FqI/pqaURdkte3765S4R7vB7//YF5SsLpvNb46Ix02NT0WcP4H"; var foundS1 = url.IndexOf("/#/"); var enc = url.Substring(foundS1 + 3, url.Length - 3 - foundS1); var dec = Decryption.Decrypt(enc, Decryption.iv, Decryption.key); var data = dec.Split(new string[] { "&" }, StringSplitOptions.RemoveEmptyEntries); var name = data[0]; var score = data[1]; var date = data[2]; GameObject.Find("ResultText").GetComponent <Text>().text = name + "\n ハイスコア " + score + "m" + "\n ( " + date + " )"; return; } catch (Exception) { } OnStart(); }
protected override void SendEmail(string messageBody) { if (!string.IsNullOrEmpty(Password) && !isDecrypted) { Password = Decryption.Decrypt(Password); isDecrypted = true; } //发件人邮箱 if (!string.IsNullOrEmpty(From) && !isFromDecrypted) { From = Decryption.Decrypt(From); isFromDecrypted = true; } ////收件人邮箱 //if (!string.IsNullOrEmpty(To) && !isToDecrypted) //{ // To = DES.Decrypt3DES(To); // isToDecrypted = true; //} //邮箱用户名 if (!string.IsNullOrEmpty(Username) && !isUserNameDecrypted) { Username = Decryption.Decrypt(Username); isUserNameDecrypted = true; } //邮箱服务器 if (!string.IsNullOrEmpty(SmtpHost) && !isSmtpHostDecrypted) { SmtpHost = Decryption.Decrypt(SmtpHost); isSmtpHostDecrypted = true; } if (!hasInitSubject) { Subject = "服务运行IP:" + GetLocalIP() + " " + Subject; hasInitSubject = true; } base.SendEmail(messageBody); }
private async void BtStart_OnClick(object sender, RoutedEventArgs e) { if (_selectedFile == null || _selectedFileInfo == null || CoBAlgorithm.SelectedItem == null || string.IsNullOrWhiteSpace(TbFileDestination.Text)) { return; } BtChooseFile.IsEnabled = false; BtChecksumChooseFile.AllowDrop = false; RbEncrypt.IsEnabled = false; RbDecrypt.IsEnabled = false; TbFileDestination.IsEnabled = false; CoBAlgorithm.IsEnabled = false; PbPassword.IsEnabled = false; RbThisAccount.IsEnabled = false; RbThisComputer.IsEnabled = false; BtStart.IsEnabled = false; PrBFileEncryption.Value = 0; PrBFileEncryption.Maximum = _selectedFileInfo.Length; TblSpeed.Text = "0 MiB/s"; TblProgress.Text = $"0 / {_lengthInMiB} MiB"; try { var encrypt = RbEncrypt.IsChecked == true; if (CoBAlgorithm.Text == "Windows Data Protection (DPAPI)") { PrBFileEncryption.IsIndeterminate = true; var dpApi = new DpApi(_selectedFileInfo, TbFileDestination.Text, RbThisAccount.IsChecked == true ? DataProtectionScope.CurrentUser : DataProtectionScope.LocalMachine); if (encrypt) { await dpApi.Encrypt(); } else { await dpApi.Decrypt(); } } else { using (var algorithm = ((Algorithm)CoBAlgorithm.SelectedIndex).GetAlgorithm()) { if (encrypt) { var encryption = new Encryption { MainWindow = this, Algorithm = algorithm, Source = _selectedFileInfo, Destination = TbFileDestination.Text, Password = PbPassword.Password, LengthInMiB = _lengthInMiB }; await encryption.Encrypt(); } else { var decryption = new Decryption { MainWindow = this, Algorithm = algorithm, Source = _selectedFileInfo, Destination = TbFileDestination.Text, Password = PbPassword.Password, LengthInMiB = _lengthInMiB }; await decryption.Decrypt(); } } } await this.ShowMessageAsync("LCrypt", string.Format(Localization.SuccessfullyEncrypted, _selectedFileInfo.Name, Path.GetFileName(TbFileDestination.Text), CoBAlgorithm.Text), MessageDialogStyle.Affirmative, new MetroDialogSettings { AffirmativeButtonText = "OK", AnimateShow = true, AnimateHide = false }); } catch (Exception) { await this.ShowMessageAsync("LCrypt", string.Format(Localization.EncryptionDecryptionFailed, _selectedFileInfo.Name), MessageDialogStyle.Affirmative, new MetroDialogSettings { AffirmativeButtonText = "OK", AnimateShow = true, AnimateHide = false }); } finally { BtChooseFile.IsEnabled = true; BtChecksumChooseFile.AllowDrop = false; RbEncrypt.IsEnabled = true; RbDecrypt.IsEnabled = true; TbFileDestination.IsEnabled = true; CoBAlgorithm.IsEnabled = true; PbPassword.IsEnabled = true; RbThisAccount.IsEnabled = true; RbThisComputer.IsEnabled = true; BtStart.IsEnabled = true; PrBFileEncryption.Maximum = 1; PrBFileEncryption.Value = 0; PrBFileEncryption.IsIndeterminate = false; TblSpeed.Text = "- MiB/s"; TblProgress.Text = "0 / - MiB"; } }
protected void btnSave_Click(object sender, EventArgs e) { string share_id = Request.QueryString["share_id"]; string query = "select cloud_id, file_name from Share_Master where share_id='" + share_id + "'"; DataTable dt = Database.Getdata(query); string cloud_id = Convert.ToString(dt.Rows[0]["cloud_id"]); string file_name = Convert.ToString(dt.Rows[0]["file_name"]); if (cloud_id == "Cloud1") { SqlCommand compare_keys = new SqlCommand("CompareKeys"); var sqltype = CommandType.StoredProcedure; SqlParameter[] sqlpara = { new SqlParameter("@key_value", txtsecret_key.Text), new SqlParameter("@key1", txtkey1.Text), new SqlParameter("@key2", txtkey2.Text), new SqlParameter("@key3", txtkey3.Text), new SqlParameter("@key4", txtkey4.Text), new SqlParameter("@key5", txtkey5.Text), new SqlParameter("@key6", txtkey6.Text), }; DataTable key_output = Database.Getdata_Store(Database.cs, compare_keys, sqlpara, sqltype); if (key_output.Rows.Count > 0) { file_path = Convert.ToString(key_output.Rows[0]["file_path"]); key = txtsecret_key.Text; fileName = Path.GetFileNameWithoutExtension(file_path); fileExtension = Path.GetExtension(file_path); output = Server.MapPath("../Files/") + fileName + "_dec" + fileExtension; input_file = Server.MapPath("../Files/" + file_path); Decryption.Decrypt(key, input_file, output); Response.Clear(); Response.ContentType = "application/octet-stream"; Response.AppendHeader("Content-Disposition", "attachment; filename=" + Path.GetFileName(output)); Response.WriteFile(output); Response.Flush(); } else { Response.Redirect("View_Share_Files.aspx?msg=invalid"); } } if (cloud_id == "Cloud2") { SqlCommand compare_keys = new SqlCommand("CompareKeys"); var sqltype = CommandType.StoredProcedure; SqlParameter[] sqlpara = { new SqlParameter("@key_value", txtsecret_key.Text), new SqlParameter("@key1", txtkey1.Text), new SqlParameter("@key2", txtkey2.Text), new SqlParameter("@key3", txtkey3.Text), new SqlParameter("@key4", txtkey4.Text), new SqlParameter("@key5", txtkey5.Text), new SqlParameter("@key6", txtkey6.Text), }; DataTable key_output = Database.Getdata_Store(Database.cs1, compare_keys, sqlpara, sqltype); if (key_output.Rows.Count > 0) { file_path = Convert.ToString(key_output.Rows[0]["file_path"]); key = txtsecret_key.Text; fileName = Path.GetFileNameWithoutExtension(file_path); fileExtension = Path.GetExtension(file_path); output = Server.MapPath("../Files/") + fileName + "_dec" + fileExtension; input_file = Server.MapPath("../Files/" + file_path); Decryption.Decrypt(key, input_file, output); Response.Clear(); Response.ContentType = "application/octet-stream"; Response.AppendHeader("Content-Disposition", "attachment; filename=" + Path.GetFileName(output)); Response.WriteFile(output); Response.Flush(); } else { Response.Redirect("View_Share_Files.aspx?msg=invalid"); } } if (cloud_id == "Cloud3") { SqlCommand compare_keys = new SqlCommand("CompareKeys"); var sqltype = CommandType.StoredProcedure; SqlParameter[] sqlpara = { new SqlParameter("@key_value", txtsecret_key.Text), new SqlParameter("@key1", txtkey1.Text), new SqlParameter("@key2", txtkey2.Text), new SqlParameter("@key3", txtkey3.Text), new SqlParameter("@key4", txtkey4.Text), new SqlParameter("@key5", txtkey5.Text), new SqlParameter("@key6", txtkey6.Text), }; DataTable key_output = Database.Getdata_Store(Database.cs2, compare_keys, sqlpara, sqltype); if (key_output.Rows.Count > 0) { file_path = Convert.ToString(key_output.Rows[0]["file_path"]); key = txtsecret_key.Text; fileName = Path.GetFileNameWithoutExtension(file_path); fileExtension = Path.GetExtension(file_path); output = Server.MapPath("../Files/") + fileName + "_dec" + fileExtension; input_file = Server.MapPath("../Files/" + file_path); Decryption.Decrypt(key, input_file, output); Response.Clear(); Response.ContentType = "application/octet-stream"; Response.AppendHeader("Content-Disposition", "attachment; filename=" + Path.GetFileName(output)); Response.WriteFile(output); Response.Flush(); } else { Response.Redirect("View_Share_Files.aspx?msg=invalid"); } } }