XtScript Function: Base64 Encode and Decode
Encode and Decode string using base64 encoding standard
XtScript base64_encode function can encode and base64_decode can decode the encoded string using base64 encoding standard.
Example of usage of base64 encoding we might often see is in a get parameter passed in the URL query. Use XtScript base64_encode to encode passed parameter in the URL and decode it when it needed, we can hide the true information passed in the URL parameter from general visitors.
XtScript base64_encode and base64_decode function basic syntax:
<!--parser:xtscript--> # Encode string using base64 standard call base64_encode $val=... # Decode a base64 encoded string call base64_decode $val=... <!--/parser:xtscript-->
Learn XtScript base64 encode and base64 decode function from examples
Encoding and decoding string with base64 standard
- Code:<!--parser:xtscript--> var $question = How are you today? var $encoded_question = call base64_encode $val=$question var $answer = SnVzdCBmaW5lLCB0aGFua3Mu var $decoded_answer = call base64_decode $val=$answer print Q: $question | Encoded: $encoded_question <br/> print A: $answer | Decoded: $decoded_answer<br/> <!--/parser:xtscript-->- Result:
Q: How are you today? | Encoded: SG93IGFyZSB5b3UgdG9kYXk/
A: SnVzdCBmaW5lLCB0aGFua3Mu | Decoded: Just fine, thanks.
A: SnVzdCBmaW5lLCB0aGFua3Mu | Decoded: Just fine, thanks.
Last edited on