CryptographicBuffer 클래스

정의

암호화 작업에 공통적인 데이터 관리 기능을 구현하는 정적 메서드를 포함합니다.

public ref class CryptographicBuffer abstract sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class CryptographicBuffer final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public static class CryptographicBuffer
Public Class CryptographicBuffer
상속
Object Platform::Object IInspectable CryptographicBuffer
특성

Windows 요구 사항

디바이스 패밀리
Windows 10 (10.0.10240.0에서 도입되었습니다.)
API contract
Windows.Foundation.UniversalApiContract (v1.0에서 도입되었습니다.)

예제

public void CryptographicBufferOverview()
{
    // 1. Generate random data.
    UInt32 buffLength = 32;
    IBuffer buffRnd = CryptographicBuffer.GenerateRandom(buffLength);
    String strRndData = CryptographicBuffer.EncodeToHexString(buffRnd);

    // 2. Generate a random number.
    UInt32 Rnd = CryptographicBuffer.GenerateRandomNumber();

    // 3. Decode a Base 64 string to a buffer and encode the buffer to a Base64 string.
    String strBase64v1 = "uiwyeroiugfyqcajkds897945234==";
    IBuffer buffFromBase64 = CryptographicBuffer.DecodeFromBase64String(strBase64v1);
    String strBase64v2 = CryptographicBuffer.EncodeToBase64String(buffFromBase64);

    // 4. Decode a hexadecimal string to a buffer and encode the buffer to a hexadecimal string.
    String strHexv1 = "30310AFF";
    IBuffer buffFromHex = CryptographicBuffer.DecodeFromHexString(strHexv1);
    String strHexv2 = CryptographicBuffer.EncodeToHexString(buffFromHex);

    // 5. Convert a strings to binary data and convert binary data to strings.
    String strIn = "Input String";
    IBuffer buffUTF16BE = CryptographicBuffer.ConvertStringToBinary(strIn, BinaryStringEncoding.Utf16BE);
    String  strUTF16BE  = CryptographicBuffer.ConvertBinaryToString(BinaryStringEncoding.Utf16BE, buffUTF16BE);
    IBuffer buffUTF16LE = CryptographicBuffer.ConvertStringToBinary(strIn, BinaryStringEncoding.Utf16LE);
    String  strUTF16LE  = CryptographicBuffer.ConvertBinaryToString(BinaryStringEncoding.Utf16LE, buffUTF16LE);
    IBuffer buffUTF8 = CryptographicBuffer.ConvertStringToBinary(strIn, BinaryStringEncoding.Utf8);
    String  strUTF8  = CryptographicBuffer.ConvertBinaryToString(BinaryStringEncoding.Utf8, buffUTF8);

    // 6. Create a buffer from a byte array and create a byte array from a buffer,
    byte[] arrByte = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
    IBuffer buffFromByteArr = CryptographicBuffer.CreateFromByteArray(arrByte);
    byte[] arrByteNew;
    CryptographicBuffer.CopyToByteArray(buffFromByteArr, out arrByteNew);

    // 7. Compare two buffers. The following Boolean value is true because the code points are equal.
    String strHex = "30310aff";
    String strBase64 = "MDEK/w==";
    IBuffer buff1 = CryptographicBuffer.DecodeFromHexString(strHex);
    IBuffer buff2 = CryptographicBuffer.DecodeFromBase64String(strBase64);
    Boolean bVal = CryptographicBuffer.Compare(buff1, buff2);

}

메서드

Compare(IBuffer, IBuffer)

개의 IBuffer 개체를 비교합니다.

ConvertBinaryToString(BinaryStringEncoding, IBuffer)

버퍼를 인코딩된 문자열로 변환합니다.

ConvertStringToBinary(String, BinaryStringEncoding)

문자열을 인코딩된 버퍼로 변환합니다.

CopyToByteArray(IBuffer, Byte[])

버퍼를 바이트 배열에 복사합니다.

CreateFromByteArray(Byte[])

입력 바이트 배열에서 버퍼를 만듭니다.

DecodeFromBase64String(String)

base64로 인코딩된 문자열을 디코딩합니다.

DecodeFromHexString(String)

16진수로 인코딩된 문자열을 디코딩합니다.

EncodeToBase64String(IBuffer)

버퍼를 base64 문자열로 인코딩합니다.

EncodeToHexString(IBuffer)

버퍼를 16진수 문자열로 인코딩합니다.

GenerateRandom(UInt32)

임의 데이터가 포함된 버퍼를 만듭니다.

GenerateRandomNumber()

난수를 만듭니다.

적용 대상