Επεξεργασία

Κοινή χρήση μέσω


ToBase64Transform.TransformBlock(Byte[], Int32, Int32, Byte[], Int32) Method

Definition

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.

public:
 virtual int TransformBlock(cli::array <System::Byte> ^ inputBuffer, int inputOffset, int inputCount, cli::array <System::Byte> ^ outputBuffer, int outputOffset);
public int TransformBlock (byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset);
abstract member TransformBlock : byte[] * int * int * byte[] * int -> int
override this.TransformBlock : byte[] * int * int * byte[] * int -> int
Public Function TransformBlock (inputBuffer As Byte(), inputOffset As Integer, inputCount As Integer, outputBuffer As Byte(), outputOffset As Integer) As Integer

Parameters

inputBuffer
Byte[]

The input to compute to base 64.

inputOffset
Int32

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

inputCount
Int32

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

outputBuffer
Byte[]

The output to which to write the result.

outputOffset
Int32

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

Returns

The number of bytes written.

Implements

Exceptions

The current ToBase64Transform object has already been disposed.

The data size is not valid.

The inputOffset parameter contains an invalid offset length.

-or-

The inputCount parameter contains an invalid value.

The inputBuffer parameter is null.

The inputCount parameter requires a non-negative number and less than or equal to the length of inputBuffer.

Examples

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.InputBlockSize;

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

    inputOffset += base64Transform.InputBlockSize;
    outputFileStream.Write(
        outputBytes, 
        0, 
        base64Transform.OutputBlockSize);
}
Dim inputBlockSize As Integer = 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)
End While

Remarks

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.

Applies to

See also