base64.encode: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
m (Conversion script moved page Base64.encode to base64.encode: Converting page titles to lowercase)
m (Text replacement - "<source" to "<syntaxhighlight")
Line 7: Line 7:


|usage=
|usage=
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
base64.encode(string)
base64.encode(string)
</source>
</source>
Line 16: Line 16:
Encode a string and then decode it.
Encode a string and then decode it.


<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
[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></source>
'''Returns:'''
'''Returns:'''
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
Four score and seven years ago...  
Four score and seven years ago...  
Rm91ciBzY29yZSBhbmQgc2V2ZW4geWVhcnMgYWdvLi4u  
Rm91ciBzY29yZSBhbmQgc2V2ZW4geWVhcnMgYWdvLi4u  

Revision as of 17:34, 14 March 2023

base64.encode() Function

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

Usage

<syntaxhighlight lang="mtmacro" line> base64.encode(string) </source> Parameters

  • string - The text string to be encoded.

Example

Encode a string and then decode it.

<syntaxhighlight lang="mtmacro" line> [r: txt = "Four score and seven years ago..."]
[r: encTxt = base64.encode(txt)]
[r: base64.decode(encTxt)]
</source> Returns: <syntaxhighlight lang="mtmacro" line> Four score and seven years ago... Rm91ciBzY29yZSBhbmQgc2V2ZW4geWVhcnMgYWdvLi4u Four score and seven years ago...

</source>

See Also