This project is read-only.

How can i use TripleDesCipher.EncryptBlock method?

Aug 10, 2012 at 9:16 AM
Edited Aug 10, 2012 at 9:18 AM

when i run my program, it alawys catch the exception "input buffer to small", what should I care about when i use this method.

these are my code:

 private void button1_Click(object sender, RoutedEventArgs e)
            string str = wantEncode.Text;
            byte[] key = Encoding.UTF8.GetBytes("1234567890abcdefgh");
            byte[] iv = Encoding.UTF8.GetBytes("123ABC4D");
            byte[] data = Encoding.UTF8.GetBytes(str);
            Renci.SshNet.Security.Cryptography.Ciphers.CipherMode mode = new Renci.SshNet.Security.Cryptography.Ciphers.Modes.CbcCipherMode(iv);
            Renci.SshNet.Security.Cryptography.Ciphers.CipherPadding padding = new Renci.SshNet.Security.Cryptography.Ciphers.Paddings.PKCS7Padding();
            Renci.SshNet.Security.Cryptography.Ciphers.TripleDesCipher cipher = new Renci.SshNet.Security.Cryptography.Ciphers.TripleDesCipher(key,mode,padding);
            byte[] dataEncryptBytes=new byte[data.Length];
            cipher.EncryptBlock(data, 0, data.Length, dataEncryptBytes, 0);
            str = Convert.ToBase64String(dataEncryptBytes);
            endEncode.Text = str;


if have the code best.
Thanks in advance

Aug 10, 2012 at 9:40 AM

oh I have solve this problem.