EncodeToBase64String | encodeToBase64String method

CryptographicBuffer.EncodeToBase64String | encodeToBase64String method

Encodes a buffer to a base64 string.

Syntax


var string = Windows.Security.Cryptography.CryptographicBuffer.encodeToBase64String(buffer);

Parameters

buffer

Type: IBuffer

Input buffer.

Return value

Type: String [JavaScript] | System.String [.NET] | Platform::String [C++]

Base64-encoded output string.

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.

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


Requirements (Windows 10 device family)

Device family

Universal, introduced version 10.0.10240.0

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0

Namespace

Windows.Security.Cryptography
Windows::Security::Cryptography [C++]

Metadata

Windows.Foundation.UniversalApiContract.winmd

Requirements (Windows 8.x and Windows Phone 8.x)

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8.1 [Windows Runtime apps only]

Namespace

Windows.Security.Cryptography
Windows::Security::Cryptography [C++]

Metadata

Windows.winmd

See also

CryptographicBuffer

 

 

Show:
© 2016 Microsoft