Base64DecoderBuffer()

Syntax

Result = Base64DecoderBuffer(*Input, InputOffset, InputSize, *Output, OutputOffset, OutputSize)
Description
Decodes the specified Base64 encoded buffer.

Parameters

*Input The buffer containing the encoded data. It has to be allocated with AllocateMemory().
InputOffset The offset (in bytes) in the input buffer.
InputSize The size of the input buffer.
*Output The output buffer where the plain data will be copied. It has to be allocated with AllocateMemory() and be different than the input buffer.
OutputOffset The offset (in bytes) in the output buffer.
OutputSize The size of the output buffer.

The output buffer can be up to 33% smaller than the input buffer, with a minimum size of 64 bytes. It's recommended to get a slightly larger buffer, like 30% smaller to avoid overflows.

Return value

Returns the length of the decoded data in bytes.

Example

  Text$ = "This is a test string!"

  *Text = AllocateMemory(100)
  PokeS(*Text, 0, Text$)

  *Encoded = AllocateMemory(200)
      
  Base64EncoderBuffer(*Text, 0, Len(Text$), *Encoded, 0, MemorySize(*Encoded))
  Debug "Encoded: " + PeekS(*Encoded, 0, -1, #PB_Ascii)
    
  *Decoded = AllocateMemory(1024)
  Base64DecoderBuffer(*Encoded, 0, MemorySize(*Encoded), *Decoded, 0, 1024)
  Debug "Decoded: " + PeekS(*Decoded, 0, -1, #PB_UTF8)

See Also

Base64EncoderBuffer()

Supported OS

All

<- Base64Decoder() - Cipher Index - Base64Encoder() ->