Result = Base64EncoderBuffer(*Input, InputOffset, InputSize, *Output, OutputOffset, OutputSize [, Flags])
Encodes the specified buffer using the Base64 algorithm. This is widely used in e-mail programs but can be useful for any other programs which need an ASCII only (7 bit, only from 32 to 127 characters) encoding for raw binary files.


*Input The buffer containing the plain 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 encoded 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 should be at last 33% bigger than the input buffer, with a minimum size of 64 bytes. It's recommended to get a slightly larger buffer, like 35% bigger to avoid overflows.
Flags (optional) It can be a combination of the following values:
  #PB_Cipher_NoPadding: it will not insert additional '=' at the end of the encoded buffer to pad it to 3 bytes boundary.
  #PB_Cipher_URL      : it will use a slightly different encoding, mainly used in URL. The usual '+' and '/' encoded characters
                        will be respectively encoded to '-' and '_'

Return value

Returns the length of the encoded data in bytes.


  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


Supported OS


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