CryptoSys PKI Toolkit Manual

CNV_BytesFromB64Str

CNV_BytesFromB64Str decodes a base64-encoded string into an array of Bytes.

VB6/VBA Syntax

Public Declare Function CNV_BytesFromB64Str Lib "diCrPKI.dll" (ByRef abData As Byte, ByVal nDataLen As Long, ByVal strB64 As String) As Long

nLen = CNV_BytesFromB64Str(abData(0), nDataLen, strB64)

Parameters

abData
[out] Byte array suitably dimension to receive output.
nDataLen
[in] Long specifying the length of the byte array.
strB64
[in] String of base64 data to be decoded.

C/C++ Syntax

long _stdcall CNV_BytesFromB64Str(unsigned char *output, long out_len, const char *input);

Returns (VB6/C)

Long: If successful, the return value is the number of bytes in the decoded array; otherwise it returns a negative error code.

.NET Equivalent

Use the in-built method System.Convert.FromBase64String.

Remarks

Call the function with an empty array to find the required length.

Example

Public Function cnvBytesFromB64Str(strB64 As String) As Variant
    Dim abData() As Byte
    Dim nDataLen As Long
    Dim nB64Len As Long
    
    cnvBytesFromB64Str = abData
    nDataLen = CNV_BytesFromB64Str(0, 0, strB64)
    If nDataLen <= 0 Then
        Exit Function
    End If
    ReDim abData(nDataLen - 1)
    nDataLen = CNV_BytesFromB64Str(abData(0), nDataLen, strB64)
    ReDim Preserve abData(nDataLen - 1)
    cnvBytesFromB64Str = abData
End Function

See Also

CNV_B64StrFromBytes CNV_B64Filter

[Contents] [Index]

[HOME]   [NEXT: CNV_BytesFromHexStr...]

Copyright © 2004-9 D.I. Management Services Pty Ltd. All rights reserved.