Result$ = Base64Encoder(*Input, InputOffset, InputSize [, 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.
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 encoded data as a string.


  Text$ = "This is a test string!"

  *Text = AllocateMemory(100)
  PokeS(*Text, 0, Text$)
  Encoded$ = Base64Encoder(*Text, 0, Len(Text$))
  Debug "Encoded: " + Encoded$
  *DecodedBuffer = AllocateMemory(1024)
  Base64Decoder(Encoded$, *DecodedBuffer, 0, 1024)
  Debug "Decoded: " + PeekS(*DecodedBuffer, 0, -1, #PB_UTF8)

See Also

Base64Decoder(), Base64DecoderBuffer(), Base64EncoderBuffer()

Supported OS


<- Base64DecoderBuffer() - Cipher Index - Base64EncoderBuffer() ->