base64.encode: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
m (Text replacement - "<source" to "<syntaxhighlight")
m (Text replacement - "source>" to "syntaxhighlight>")
 
Line 9: Line 9:
<syntaxhighlight lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
base64.encode(string)
base64.encode(string)
</source>
</syntaxhighlight>
'''Parameters'''
'''Parameters'''
{{param|string|The text string to be encoded.}}
{{param|string|The text string to be encoded.}}
Line 19: Line 19:
[r: txt = "Four score and seven years ago..."]<br>
[r: txt = "Four score and seven years ago..."]<br>
[r: encTxt = base64.encode(txt)]<br>
[r: encTxt = base64.encode(txt)]<br>
[r: base64.decode(encTxt)]<br></source>
[r: base64.decode(encTxt)]<br></syntaxhighlight>
'''Returns:'''
'''Returns:'''
<syntaxhighlight lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
Line 25: Line 25:
Rm91ciBzY29yZSBhbmQgc2V2ZW4geWVhcnMgYWdvLi4u  
Rm91ciBzY29yZSBhbmQgc2V2ZW4geWVhcnMgYWdvLi4u  
Four score and seven years ago...
Four score and seven years ago...
</source>
</syntaxhighlight>


|also=
|also=

Latest revision as of 17:39, 14 March 2023

base64.encode() Function

Introduced in version 1.5.2
Takes the supplied text string and encodes it to Base64.

Usage

base64.encode(string)

Parameters

  • string - The text string to be encoded.

Example

Encode a string and then decode it.
[r: txt = "Four score and seven years ago..."]<br>
[r: encTxt = base64.encode(txt)]<br>
[r: base64.decode(encTxt)]<br>

Returns:

Four score and seven years ago... 
Rm91ciBzY29yZSBhbmQgc2V2ZW4geWVhcnMgYWdvLi4u 
Four score and seven years ago...

See Also