Dela via


CryptographicBuffer.EncodeToBase64String(IBuffer) Method

Definition

Encodes a buffer to a base64 string.

public:
 static Platform::String ^ EncodeToBase64String(IBuffer ^ buffer);
 static winrt::hstring EncodeToBase64String(IBuffer const& buffer);
public static string EncodeToBase64String(IBuffer buffer);
function encodeToBase64String(buffer)
Public Shared Function EncodeToBase64String (buffer As IBuffer) As String

Parameters

buffer
IBuffer

Input buffer.

Returns

String

Platform::String

winrt::hstring

Base64-encoded output string.

Examples

public void EncodeDecodeBase64()
{
    // Define a Base64 encoded string.
    String strBase64 = "uiwyeroiugfyqcajkds897945234==";

    // Decoded the string from Base64 to binary.
    IBuffer buffer = CryptographicBuffer.DecodeFromBase64String(strBase64);

    // Encode the buffer back into a Base64 string.
    String strBase64New = CryptographicBuffer.EncodeToBase64String(buffer);
}

Remarks

Base64 processes data as 24-bit groups, mapping each group to four encoded 8-bit characters. Base64 encoding is sometimes referred to as 3-to-4 encoding. Each 6 bits of the 24-bit group is used as an index into a mapping table (the base64 alphabet) to obtain a character for the encoded data.

Applies to