private void btnDES2_Click(Object sender, EventArgs e) { var buf = GetSource(); var pass = GetPass(); var des = new DESCryptoServiceProvider(); buf = des.Decrypt(buf, pass); SetResult(buf); }
private void btnDES2_Click(Object sender, EventArgs e) { var buf = GetBytes(); var pass = GetBytes(rtPass.Buffer.Text); var des = new DESCryptoServiceProvider(); buf = des.Decrypt(buf, pass); SetResult2(buf); }
private void btnDES2_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.Decrypt(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); }