private void btnDES_Click(Object sender, EventArgs e) { var buf = GetBytes(); var pass = GetBytes(rtPass.Text); var des = new DESCryptoServiceProvider(); buf = des.Encrypt(buf, pass); SetResult(buf); }
private void btnDES_Click(Object sender, EventArgs e) { var buf = GetBytes(); var pass = GetBytes(rtPass.Text); var des = new DESCryptoServiceProvider(); buf = des.Encrypt(buf, pass); rtResult.Text = buf.ToHex() + Environment.NewLine + Environment.NewLine + buf.ToBase64(); }
private void btnDES_Click(Object sender, EventArgs e) { var buf = GetSource(); var pass = GetPass(); var mode = (CipherMode)Enum.Parse(typeof(CipherMode), cmbCipher.SelectedItem + ""); var padding = (PaddingMode)Enum.Parse(typeof(PaddingMode), cmbPadding.SelectedItem + ""); var des = new DESCryptoServiceProvider(); buf = des.Encrypt(buf, pass, mode, padding); SetResult(buf); }
public void TestDESAlgorithm() { var provider = new DESCryptoServiceProvider(); provider.Key = new Byte[] { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 }; provider.IV = new Byte[] { 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01 }; provider.Padding = PaddingMode.Zeros; provider.Mode = CipherMode.CBC; var encodedData = provider.Encrypt(_clearData); var decodedData = provider.Decrypt(encodedData); CollectionAssert.AreEqual(_clearData, decodedData); }
/// <summary> /// ############# ######## ###### ## ######### DES. /// </summary> /// <param name="password">###### ### ##########.</param> /// <returns>######, ############## ############### ######.</returns> public string GetConvertedPasswordValue(string password) { if (string.IsNullOrEmpty(password)) { return(string.Empty); } var cryptoServiceKey = ConfigurationManager.AppSettings["MsgUserPasswordDESCryptoServiceKey"]; if (string.IsNullOrEmpty(cryptoServiceKey)) { var resourceStorage = UserConnection.Workspace.ResourceStorage; var errorMessage = new LocalizableString(resourceStorage, "CryptographicService", "LocalizableStrings.CryptoServiceKeyExceptionMessage.Value"); throw new NullReferenceException(errorMessage); } string msgUserPasswordKey = cryptoServiceKey.ToString(); using (var cryptoServiceProvider = new DESCryptoServiceProvider(msgUserPasswordKey)) { return(cryptoServiceProvider.Encrypt(password)); } }