Export (0) Print
Expand All

ToBase64Transform.TransformBlock Method

Converts the specified region of the input byte array to base 64 and copies the result to the specified region of the output byte array.

Namespace:  System.Security.Cryptography
Assembly:  mscorlib (in mscorlib.dll)

public int TransformBlock(
	byte[] inputBuffer,
	int inputOffset,
	int inputCount,
	byte[] outputBuffer,
	int outputOffset
)

Parameters

inputBuffer
Type: System.Byte[]

The input to compute to base 64.

inputOffset
Type: System.Int32

The offset into the input byte array from which to begin using data.

inputCount
Type: System.Int32

The number of bytes in the input byte array to use as data.

outputBuffer
Type: System.Byte[]

The output to which to write the result.

outputOffset
Type: System.Int32

The offset into the output byte array from which to begin writing data.

Return Value

Type: System.Int32
The number of bytes written.

Implements

ICryptoTransform.TransformBlock(Byte[], Int32, Int32, Byte[], Int32)

ExceptionCondition
ObjectDisposedException

The current ToBase64Transform object has already been disposed.

CryptographicException

The data size is not valid.

ArgumentException

The inputBuffer parameter contains an invalid offset length.

-or-

The inputCount parameter contains an invalid value.

ArgumentNullException

The inputBuffer parameter is null.

ArgumentOutOfRangeException

The inputBuffer parameter requires a non-negative number.

The ToBase64Transform class is a block algorithm that processes input blocks of 3 bytes and creates output blocks of 4 bytes. The TransformBlock method transforms an input block of 24 bits into 32 bits of character data. You must maintain 3 byte input boundaries to 4 byte output boundaries in order to match the block transform.

The following code example demonstrates how to call the TransformBlock method to iterate through inputBytes transforming by blockSize. This code example is part of a larger example provided for the ToBase64Transform class.

int inputBlockSize = base64Transform.InputBlockSize;

while(inputBytes.Length - inputOffset > inputBlockSize)
{
    base64Transform.TransformBlock(
        inputBytes,
        inputOffset,
        inputBytes.Length - inputOffset,
        outputBytes,
        0);

    inputOffset += base64Transform.InputBlockSize;
    outputFileStream.Write(
        outputBytes, 
        0, 
        base64Transform.OutputBlockSize);
}

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft