[Home] [Downloads] [Search] [Help/forum]

MUSHclient scripting

Description of MUSHclient world function: world.Base64Encode


Name Base64Encode
Type Method
Summary Encodes a string using base-64 encoding.
Prototype VARIANT Base64Encode(BSTR Text, BOOL MultiLine);

View list of data type meanings

Description

Encodes a string (like "swordfish") returning it as base-64 characters (eg. "c3dvcmRmaXNo").

Each 3 characters of input become 4 characters of output. This can be used:

a) as a primitive form of encryption (or 'information hiding')
b) to send non-printable characters as a text stream

Note that due to the way strings are represented internally, it is not possible for the encoded string to contain the NULL character (hex 0x00) and be returned correctly, however see below for a work-around for Lua.

If "multiline" is true, then the returned string will have a carriage-return/linefeed after every 76 characters, otherwise it will be one long text stream.


Note: Available in version 3.22 onwards.


VBscript example
world.note world.base64encode ("swordfish", 0)
Jscript example
world.note (world.base64encode ("swordfish", 0));
PerlScript example
$world->note ($world->base64encode ("swordfish", 0));
Python example
world.note (world.base64encode ("swordfish", 0))
Lua example
Note (Base64Encode ("swordfish", 0))
Lua notes
The multi-line flag is optional, and defaults to false.

---

In MUSHclient version 3.57 onwards you can also use 

encoded_string = utils.base64encode (s, [, linebreaks] )

This works the same as described above, however it will correctly handle strings with the null (hex 00) character in them.
Returns The encoded string.
Introduced in version 3.22

See also ...

Function Description
Base64Decode Takes a base-64 encoded string and decodes it.

Search for script function

Enter a word or phrase in the box below to narrow the list down to those that match.

The function name, prototype, summary, and description are searched.

Search for:   

Leave blank to show all functions.


Return codes

Many functions return a "code" which indicates the success or otherwise of the function.

You can view a list of the return codes


Function prototypes

The "prototype" part of each function description lists exactly how the function is called (what arguments, if any, to pass to it).

You can view a list of the data types used in function prototypes


View all functions

[Back]

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]