Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Published by Scroll Versions from space DEV and version next

D toc

Excerpt

Converts an input value to base64 encoding with optional padding with an equals sign (=). Input can be of any type. Output type is String.

  • base64 is a method of representing data in a binary format over text protocols. During encoding, text values are converted to binary values 0-63. Each value is stored as an ASCII character based on a conversion chart. 
    • Typically, base64 is used to transmit binary information, such as images, over transfer methods that use text, such as HTTP. 

      Info

      NOTE: base64 is not an effective method of encryption.

    • For more information on base64, see https://en.wikipedia.org/wiki/Base64.

D s lang vs sql

D s
snippetBasic

Column reference example:

D lang syntax
RawWrangletrue
Typeref
showNotetrue
WrangleTextderive type:single value:base64encode(mySource)

base64encode(mySource)

Output: Returns the values from the mySource column written in base64 format. 

String literal example:

D lang syntax
RawWrangletrue
Typeref
showNotetrue
WrangleTextderive type:single value:base64encode('Hello, World. ', true)

base64encode('Hello, World. ', true)

Output: Returns the string: GVsbG8sIFdvcmxkLiA=. Note that the output string is padded with the equals sign at the end of the output value. 

D s
snippetSyntax

D lang syntax
RawWrangletrue
Typesyntax
showNotetrue
WrangleTextderive type:single value:base64encode(column_string,bool_padding)

base64encode(column_string,bool_padding)


ArgumentRequired?Data TypeDescription
column_stringYstringName of the column or string literal to be applied to the function
bool_paddingNBooleanWhen true, excess padding in the data stream is padded with an equals sign ( =) in the output. Default is true.

D s lang notes

column_string

Name of the column or string constant to be converted.

  • Missing string or column values generate missing string results.
  • String constants must be quoted ('Hello, World').
  • Multiple columns and wildcards are not supported.

D s
snippetusage

Required?Data TypeExample Value
YesString literal or column referencemyColumn

bool_padding

Boolean value that determines if spaces are padded with the equals sign. 

Base64 represents six-bit values (0-63). These values are represented in encoded values as ASCII characters, which are 8-bit values (0-255). 

For any arbitrary input, it is possible that the number of bits required to represent it as a base64 value (number of characters * 6) won't precisely match up ASCII representation. Four sextets of base64 encoding map to three octets of ASCII encoding. If the input string has been fully encoded, but there are extra ASCII octets so that the number of output octets is divisible by four. 

When this parameter is set to true, the output value is padded with the equals sign (=) to represent output octets that are generated but do not contain any data encoded from the input. The default is true.

For more information on base64 padding, see https://en.wikipedia.org/wiki/Base64


D s
snippetusage

Required?Data TypeExample Value
NoBooleanfalse

D s
snippetExamples

Example - base64 encoding and decoding

Include Page
EXAMPLE - Base64 Encoding Functions
EXAMPLE - Base64 Encoding Functions

D s also
labelstring