Convert.FromBase64CharArray Method (Char[], Int32, Int32)

 

Converts a subset of a Unicode character array, which encodes binary data as base-64 digits, to an equivalent 8-bit unsigned integer array. Parameters specify the subset in the input array and the number of elements to convert.

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

static member FromBase64CharArray : 
        inArray:char[] *
        offset:int *
        length:int -> byte[]

Parameters

inArray
Type: System.Char[]

A Unicode character array.

offset
Type: System.Int32

A position within inArray.

length
Type: System.Int32

The number of elements in inArray to convert.

Return Value

Type: System.Byte[]

An array of 8-bit unsigned integers equivalent to length elements at position offset in inArray.

Exception Condition
ArgumentNullException

inArray is null.

ArgumentOutOfRangeException

offset or length is less than 0.

-or-

offset plus length indicates a position not within inArray.

FormatException

The length of inArray, ignoring white-space characters, is not zero or a multiple of 4.

-or-

The format of inArray is invalid. inArray contains a non-base-64 character, more than two padding characters, or a non-white-space character among the padding characters.

inArray is composed of base-64 digits, white-space characters, and trailing padding characters. The base-64 digits in ascending order from zero are the uppercase characters "A" to "Z", lowercase characters "a" to "z", numerals "0" to "9", and the symbols "+" and "/".

The white-space characters, and their Unicode names and hexadecimal code points, are tab (CHARACTER TABULATION, U+0009), newline (LINE FEED, U+000A), carriage return (CARRIAGE RETURN, U+000D), and blank (SPACE, U+0020). An arbitrary number of white-space characters can appear in inArray because all white-space characters are ignored.

The valueless character, "=", is used for trailing padding. The end of inArray can consist of zero, one, or two padding characters.

System_CAPS_importantImportant

The FromBase64CharArray method is designed to process a single character array that contains all the data to be decoded. To decode base-64 character data from a stream, use the System.Security.Cryptography.FromBase64Transform class.

The following example demonstrates the use of the FromBase64CharArray(Char[], Int32, Int32) method to decode UUencoded (base-64) data and save it as binary output.

No code example is currently available or this language may not be supported.

The following example demonstrates the ToBase64CharArray(Byte[], Int32, Int32, Char[], Int32, Base64FormattingOptions) and FromBase64CharArray(Char[], Int32, Int32) methods. The input is divided into groups of three bytes (24 bits) each. Consequently, each group consists of four 6-bit numbers where each number ranges from decimal 0 to 63. In this example, there are 85 3-byte groups with one byte remaining. The first group consists of the hexadecimal values 00, 01, and 02, which yield four 6-bit values equal to decimal 0, 0, 4, and 2. Those four values correspond to the base-64 digits, "A", "A", "E", and "C", at the beginning of the output.

If an integral number of 3-byte groups does not exist, the remaining bytes are effectively padded with zeros to form a complete group. In this example, the value of the last byte is hexadecimal FF. The first 6 bits are equal to decimal 63, which corresponds to the base-64 digit "/" at the end of the output, and the next 2 bits are padded with zeros to yield decimal 48, which corresponds to the base-64 digit, "w". The last two 6-bit values are padding and correspond to the valueless padding character, "=".

No code example is currently available or this language may not be supported.

Universal Windows Platform
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top
Show: