ph_base64encode PowerHome formula function
Description
Converts a string to its base64 representation.
Syntax
ph_base64encode ( as_input )
ph_base64encode ( as_input, ai_type )
Argument | Description |
as_input | String. A string of data or full path and
filename of data you wish to base64 encode |
ai_type | Integer (Optional). Determines how the base64
encoding is to be done. Valid values are 0, 1, 2, and 3. If parameter
is not included, then a value of 0 is assumed. See Usage below |
Return value
String. Returns the base64 representation of the data.
Usage
Use this function to base64 encode a
supplied string of data or a specified path/filename. When used to validate
authorization via a webpage, the format is the userid, a colon, and then
the password.
Valid values for ai_type are:
0 - Interpret the data in as_input as an ASCII string
1 - Interpret the data in as_input as a UTF-8 string
2 - Decode the hex encoded string in as_input and then encode as base64
3 - Interpret as_input as a path/filename. Open the specified file and encode its contents
Any other value will result in an empty string "" being
returned
Examples
The following examples demonstrate typical syntax/usage for this function.
• ph_base64encode("username:password")
- Returns the base64 encoded string: "dXNlcm5hbWU6cGFzc3dvcmQ=
"
• ph_base64encode()