This documentation is archived and is not being maintained.

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
)
public final int TransformBlock (
	byte[] inputBuffer, 
	int inputOffset, 
	int inputCount, 
	byte[] outputBuffer, 
	int outputOffset
)
public final function TransformBlock (
	inputBuffer : byte[], 
	inputOffset : int, 
	inputCount : int, 
	outputBuffer : byte[], 
	outputOffset : int
) : int

Parameters

inputBuffer

The input to compute to base 64.

inputOffset

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

inputCount

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

outputBuffer

The output to which to write the result.

outputOffset

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

Return Value

The number of bytes written.

Exception typeCondition

ObjectDisposedException

The current ToBase64Transform has already been disposed.

CryptographicException

The data size is not valid.

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);
}

int inputBlockSize = base64Transform.get_InputBlockSize();
while (inputBytes.get_Length() - inputOffset > inputBlockSize) {
    base64Transform.TransformBlock(inputBytes, inputOffset, 
        inputBytes.get_Length() - inputOffset, outputBytes, 0);
    inputOffset += base64Transform.get_InputBlockSize();
    outputFileStream.Write(outputBytes, 0, base64Transform.
        get_OutputBlockSize());
}

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

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

.NET Framework

Supported in: 2.0, 1.1, 1.0
Show: