Renci.SshNet.Security.Cryptography.Ciphers.Arc4Cipher.Encrypt C# (CSharp) Method

Encrypt() public method

Encrypts the specified input.
public Encrypt ( byte input, int offset, int length ) : byte[]
input byte The input.
offset int The zero-based offset in at which to begin encrypting.
length int The number of bytes to encrypt from .
return byte[]
        public override byte[] Encrypt(byte[] input, int offset, int length)
        {
            var output = new byte[length];
            ProcessBytes(input, offset, length, output, 0);
            return output;
        }

Usage Example

示例#1
0
        public void Encrypt_DischargeFirstBytes_False1()
        {
            const string key = "Key";
            const string plainText = "Plaintext";
            var encoding = Encoding.ASCII;
            var cipher = new Arc4Cipher(encoding.GetBytes(key), false);
            var expectedCipherText = new byte[] { 0xBB, 0xF3, 0x16, 0xE8, 0xD9, 0x40, 0xAF, 0x0A, 0xD3 };

            var actualCipherText = cipher.Encrypt(encoding.GetBytes(plainText));

            Assert.IsNotNull(actualCipherText);
            Assert.AreEqual(expectedCipherText.Length, actualCipherText.Length);
            Assert.AreEqual(expectedCipherText[0], actualCipherText[0]);
            Assert.AreEqual(expectedCipherText[1], actualCipherText[1]);
            Assert.AreEqual(expectedCipherText[2], actualCipherText[2]);
            Assert.AreEqual(expectedCipherText[3], actualCipherText[3]);
            Assert.AreEqual(expectedCipherText[4], actualCipherText[4]);
            Assert.AreEqual(expectedCipherText[5], actualCipherText[5]);
            Assert.AreEqual(expectedCipherText[6], actualCipherText[6]);
            Assert.AreEqual(expectedCipherText[7], actualCipherText[7]);
            Assert.AreEqual(expectedCipherText[8], actualCipherText[8]);
        }
All Usage Examples Of Renci.SshNet.Security.Cryptography.Ciphers.Arc4Cipher::Encrypt