Renci.SshNet.Security.Cryptography.Ciphers.RsaCipher.Decrypt C# (CSharp) Method

Decrypt() public method

Decrypts the specified input.
Only block type 01 or 02 are supported. Thrown when decrypted block type is not supported.
public Decrypt ( byte data, int offset, int length ) : byte[]
data byte The input.
offset int The zero-based offset in at which to begin decrypting.
length int The number of bytes to decrypt from .
return byte[]
        public override byte[] Decrypt(byte[] data, int offset, int length)
        {
            var paddedBlock = Transform(data, offset, length);

            if (paddedBlock[0] != 1 && paddedBlock[0] != 2)
                throw new NotSupportedException("Only block type 01 or 02 are supported.");

            var position = 1;
            while (position < paddedBlock.Length && paddedBlock[position] != 0)
                position++;
            position++;

            var result = new byte[paddedBlock.Length - position];
            Buffer.BlockCopy(paddedBlock, position, result, 0, result.Length);
            return result;
        }

Same methods

RsaCipher::Decrypt ( byte data ) : byte[]

Usage Example

Esempio n. 1
0
 public void DecryptTest()
 {
     RsaKey key = null; // TODO: Initialize to an appropriate value
     RsaCipher target = new RsaCipher(key); // TODO: Initialize to an appropriate value
     byte[] data = null; // TODO: Initialize to an appropriate value
     byte[] expected = null; // TODO: Initialize to an appropriate value
     byte[] actual;
     actual = target.Decrypt(data);
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
All Usage Examples Of Renci.SshNet.Security.Cryptography.Ciphers.RsaCipher::Decrypt