Skip to content

Commit

Permalink
doc/userguide: document Lua base64 library
Browse files Browse the repository at this point in the history
Ticket: #7074
  • Loading branch information
jasonish committed Jan 30, 2025
1 parent 97d9f03 commit 1fbf5c8
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
55 changes: 55 additions & 0 deletions doc/userguide/lua/libs/base64.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
Base64
------

Base64 functions are expose to Lua scripts with the
``suricata.base64``. For example::

local base64 = require("suricata.base64")

Functions
~~~~~~~~~

``encode(string)``
^^^^^^^^^^^^^^^^^^

Encode a buffer with standard base64 encoding. This standard encoding
includes padding.

``decode(string)``
^^^^^^^^^^^^^^^^^^

Decode a base64 string that contains padding.

``encode_nopad(string)``
^^^^^^^^^^^^^^^^^^^^^^^^

Encode a buffer with standard base64 encoded but don't include any
padding.

``decode_nopad(string)``
^^^^^^^^^^^^^^^^^^^^^^^^

Decode a base64 buffer that contains no padding.

``decode_padopt(string)``
^^^^^^^^^^^^^^^^^^^^^^^^^

Decode a base64 buffer that may or may not contain trailing padding.

``decode_rfc2045(string)``
^^^^^^^^^^^^^^^^^^^^^^^^^^

Decode RFC 2045 formatted base64.

``decode_rfc4648(string)``
^^^^^^^^^^^^^^^^^^^^^^^^^^

Decode RFC 4648 formatted base64.

Implementation Details
~~~~~~~~~~~~~~~~~~~~~~

The base64 functions provided come from the Rust base64 library
documented at https://docs.rs/base64 and corresponse to the
``STANDARD`` and ``STANDARD_NO_PAD`` base64 engines provided in that
library.
1 change: 1 addition & 0 deletions doc/userguide/lua/libs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ environment without access to additional modules.

.. toctree::

base64
hashlib

0 comments on commit 1fbf5c8

Please sign in to comment.