DOCUMENTATION:
  name: b64encode
  author: ansible core team
  version_added: 'historical'
  short_description: Encode a string as Base64
  description:
    - Base64 encoding function.
  positional: _input
  options:
    _input:
      description: A string to encode.
      type: string
      required: true
    encoding:
      description:
        - The encoding to use to transform from a text string to a byte string.
        - Defaults to using 'utf-8'.
      type: string
      required: false
    urlsafe:
      description:
        - Encode string using URL- and filesystem-safe alphabet,
          which substitutes I(-) instead of I(+) and I(_) instead of I(/) in the Base64 alphabet.
      type: bool
      default: false
      required: false
      version_added: 2.19

EXAMPLES: |
  # Base64 encode a string
  b64lola: "{{ 'lola'| b64encode }}"

  # Base64 encode the content of 'stuff' variable
  b64stuff: "{{ stuff | b64encode }}"

  # Base64 encode the content with different encoding
  b64stuff: "{{ 'Ansible - くらとみ\n' | b64encode(encoding='utf-16-le') }}"
  # => 'QQBuAHMAaQBiAGwAZQAgAC0AIABPMIkwaDB/MAoA'

  # URL-safe Base64 encoding
  b64stuff: "{{ 'https://www.python.org/example-1' | b64encode(urlsafe=True) }}"
  # => 'aHR0cHM6Ly93d3cucHl0aG9uLm9yZy9leGFtcGxlLTE='

RETURN:
  _value:
    description: A Base64 encoded string.
    type: string
